Jump to content
Sign in to follow this  
Ejoc

DllStruct Dev

Recommended Posts

Ejoc

That's cool, will make customizing GUIs pretty easy.


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
Jos

Already fixed up for udfs and sent to jdeb

<{POST_SNAPBACK}>

Looks pretty nice.

All i need now to be able to replace the 2 programs i wrote for SciTEconfig is that the default font and the default color to be used as default for the Dialog shown....

For Color its the "COLORREF rgbResult" that contains the default info and for Font its "TCHAR lfFaceName[LF_FACESIZE]" ...

What do you think ?

:(


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
GaryFrost

Looks pretty nice.

All i need now to be able to replace the 2 programs i wrote for SciTEconfig is that the default font and the default color to be used as default for the Dialog shown....

For Color its the "COLORREF rgbResult"  that contains the default info and for Font its "TCHAR lfFaceName[LF_FACESIZE]" ...

What do you think ?

:(

<{POST_SNAPBACK}>

ChooseColor

params

$i_ReturnType - Optional: determines return type

$i_colorref - Optional: COLORREF rgbColors

if $i_ReturnType == 0 then COLORREF is returned

if $i_ReturnType == 1 then Hex BGR Color is returned

if $i_ReturnType == 2 Hex RGB Color is returned

added optional colorref rgbcolor param

ChooseFont

params

$s_FontName - Optional: Default font name

$i_size - Optional: pointsize of font

$i_colorref - Optional: COLORREF rgbColors

returns an array

$array[0] - contains the number of elements

$array[1] - attributes = BitOr of italic:2, undeline:4, strikeout:8

$array[2] - fontname

$array[3] - font size = point size

$array[4] - font weight = = 0-1000

$array[5] - COLORREF rgbColors

$array[6] - Hex BGR Color

$array[7] - Hex RGB Color

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost

Sent the updated udf with the previous post enhancements added into them to jdeB.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Jos

ChooseColor

params

$i_ReturnType - Optional: determines return type

$i_colorref - Optional: COLORREF rgbColors

if $i_ReturnType == 0 then COLORREF is returned

if $i_ReturnType == 1 then Hex BGR Color is returned

if $i_ReturnType == 2 Hex RGB Color is returned

added optional colorref rgbcolor param

ChooseFont

params

$s_FontName - Optional: Default font name

$i_size - Optional: pointsize of font

$i_colorref - Optional: COLORREF rgbColors

returns an array

$array[0] - contains the number of elements

$array[1] - attributes = BitOr of italic:2, undeline:4, strikeout:8

$array[2] - fontname

$array[3] - font size = point size

$array[4] - font weight = = 0-1000

$array[5] - COLORREF rgbColors

$array[6] - Hex BGR Color

$array[7] - Hex RGB Color

<{POST_SNAPBACK}>

Works great ... implemented it in SciTeConfig scrip to be able to get rid of the 2 extra programs...

I will add these to the Misc.au3 UDF library....

Thanks !!

:(


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Josbe

Works great ...  implemented it in SciTeConfig scrip to be able to get rid of the 2 extra programs...

I will add these to the Misc.au3 UDF library....

Thanks !!

:(

<{POST_SNAPBACK}>

Very well! Thanks: Ejoc, gafrost and JdeB. :(

Share this post


Link to post
Share on other sites
Ejoc

Also... Is there a way to get a piece of a struct pointer? DLLStructGetMem?

Lar.

<{POST_SNAPBACK}>

Ok I see what you are asking, as I found I needed it for writing to the System Event Log. I added it to my UDF, I may add it to the AutoIt source, but I dont want it to get too bloated.

*Edit

Moved this to post #1

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
layer

Figure I'd ask this in here... Am I doing this right? I see no edge on my screen, I must be doing it wrong :(

#comments-start
BOOL DrawEdge(
  HDC hdc,     // handle to device context
  LPRECT qrc,   // rectangle coordinates
  UINT edge,     // type of edge
  UINT grfFlags  // type of border
);
#comments-end
$DC = DllCall("gdi32.dll", "int", "GetDC", "hWnd", "")
$coords = DllStructCreate("int;int;int;int")
DllStructSet($coords, 1, 100); x
DllStructSet($coords, 2, 200); y
DllStructSet($coords, 3, 200); width
DllStructSet($coords, 4, 200); height
DllCall("gdi32.dll", "int", "DrawEdge", "int", $DC, "ptr", DllStructPtr($coords), "int", 8, "int", 0x4000)
DllStructFree($coords)

And heres the MSDN site for it:

http://msdn.microsoft.com/library/default....ntdraw_6aat.asp

Thanks

:(


FootbaG

Share this post


Link to post
Share on other sites
GaryFrost

I believe your HDC be an "hwnd" instead of an "int"

also

edge

[in] Specifies the type of inner and outer edges to draw. This parameter must be a combination of one inner-border flag and one outer-border flag. The inner-border flags are as follows.

Global Const $BDR_RAISEDINNER = 0x4
Global Const $BDR_SUNKENINNER = 0x8

The outer-border flags are as follows.

Global Const $BDR_RAISEDOUTER = 0x1
Global Const $BDR_SUNKENOUTER  = 0x2

Alternatively, the edge parameter can specify one of the following flags.

Global Const $EDGE_BUMP = (BitOR($BDR_RAISEDOUTER,$BDR_SUNKENINNER))
Global Const $EDGE_ETCHED = (BitOR($BDR_SUNKENOUTER,$BDR_RAISEDINNER))
Global Const $EDGE_RAISED = (BitOR($BDR_RAISEDOUTER, $BDR_RAISEDINNER))
Global Const $EDGE_SUNKEN = (BitOR($BDR_SUNKENOUTER,$BDR_SUNKENINNER))
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Ejoc

RECT is : TOP,LEFT,RIGHT,BOTTOM

Not: TOP,LEFT,WIDTH,HEIGHT

DllStructSet($coords, 1, 100); left
DllStructSet($coords, 2, 200); top
DllStructSet($coords, 3, 300); right
DllStructSet($coords, 4, 400); bottom
Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
GaryFrost

Forgot the info about the last param

grfFlags

[in] Specifies the type of border. This parameter can be a combination of the following values.

Global Const $BF_ADJUST = 0X2000
Global Const $BF_BOTTOM = 0X8
Global Const $BF_BOTTOMLEFT = (BitOR($BF_BOTTOM,$BF_LEFT))
Global Const $BF_BOTTOMRIGHT = (BitOR($BF_BOTTOM,$BF_RIGHT))
Global Const $BF_DIAGONAL = 0X10
Global Const $BF_DIAGONAL_ENDBOTTOMLEFT = (BitOR($BF_DIAGONAL,$BF_BOTTOM,$BF_LEFT))
Global Const $BF_DIAGONAL_ENDBOTTOMRIGHT = (BitOR($BF_DIAGONAL,$BF_BOTTOM,$BF_RIGHT))
Global Const $BF_DIAGONAL_ENDTOPLEFT = (BitOR($BF_DIAGONAL,$BF_TOP,$BF_LEFT))
Global Const $BF_DIAGONAL_ENDTOPRIGHT = (BitOR($BF_DIAGONAL,$BF_TOP,$BF_RIGHT))
Global Const $BF_FLAT = 0X4000
Global Const $BF_LEFT = 0X1
Global Const $BF_MIDDLE = 0X800
Global Const $BF_MONO = 0X8000
Global Const $BF_RECT = (BitOR($BF_LEFT,$BF_TOP,$BF_RIGHT,$BF_BOTTOM))
Global Const $BF_RIGHT = 0X4
Global Const $BF_SOFT = 0X1000
Global Const $BF_TOP = 0X2
Global Const $BF_TOPLEFT = (BitOR($BF_TOP,$BF_LEFT))
Global Const $BF_TOPRIGHT = (BitOR($BF_TOP,$BF_RIGHT))

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
GaryFrost
:( I sure wasn't going to mess with, I believe you have to do beginpaint and endpaint, then you get into the paint structure also.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
Ejoc

Next beta should have:

DllStructElementPtr()

Modified DllStructCreate()

DllStructElementPtr($struct,$iElement); returns the ptr to that element in the struct

DllStructCreate("str"[,$iPtr]); you can give it a ptr to use instead of allocating memory, Handy for typecasting. And now when you allocate the memory, the memory is zero'd out on creation, so you should have to worry about zeroing out data when you create it.

$a          = DllStructCreate("int")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$b  = DllStructCreate("uint",DllStructElementPtr($a,1))
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$c  = DllStructCreate("float",DllStructElementPtr($a,1))
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

;set the data
DllStructSet($a,1,-1)

;=========================================================
;   Display the different data types of the same data
;=========================================================
MsgBox(0,"DllStruct",_
        "int: " & DllStructGet($a,1) & @CRLF & _
        "uint: " & DllStructGet($b,1) & @CRLF & _
        "float: " & DllStructGet($c,1) & @CRLF & _
        "")

DllStructFree($a)
Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
Ejoc

This is a heads up! Function names will be changing to make them more standardized. I feel these are good changes.

DllStructCreate ( "Struct" [,Pointer]) ------------------> DllStructCreate

Creates a C/C++ style structure for using in DllCall.

Question:

I am not sure to understand how a DllStructCreate( "Struct", Pointer) can be used.

Where does the pointer can come from? add remarks in the doc about it

DllStructElementPtr ( Struct, Element ) -----------------> DllStructGetPtr

Returns the pointer to the element in the struct.

Merge it with DllStructPtr as DllStructGetPtr( Struct [,Element])

DllStructFree ( Struct ) --------------------------------> DllStructDelete

Free the memory allocated during DllStructCreate.

It is better to have Delete which is more commonly use when the initial function is "Create"

Free has Allocate as the correpondance function.

DllStructGet ( Struct, Element [, index ] ) -------------> DllStructGetData

Returns the data in an element of the struct.

I prefer to add what we get to  differentiate data and ptr

DllStructPtr ( Struct ) ---------------------------------> DllStructGetPtr

Returns the pointer to the struct that will be used in DllCall.

Add the verb to show what the function is doing.

DllStructSet ( Struct, Element, value [, index ] ) ------> DllStructSetData

Sets the data in an element of the struct.

I prefer to add what we get to  differentiate data and ptr

DllStructSize ( Struct ) --------------------------------> DllStructGetSize

Returns the size of the struct in bytes.

Add the verb to show what the function is doing.

I wrote wrappers so when they hit a beta, you can use the wrappers as a temporary crutch until you get your functions updated.

#cs
vi:ts=4 sw=4:
DllStructWrapper Maps old functions to the new functions
#ce
#include-once

Func DllStructElementPtr($a,$i)
    Return DllStructGetPtr($a,$i)
EndFunc

Func DllStructGet($a,$i,$n="NOPARAM")
    if $n = "NOPARAM" Then Return DllStructGetData($a,$i)
    Return DllStructGetData($a,$i,$n)
EndFunc

Func DllStructSet($a,$i,$value,$n="NOPARAM")
    if $n = "NOPARAM" Then Return DllStructSetData($a,$i,$value)
    Return DllStructSetData($a,$i,$value,$n)
EndFunc

Func DllStructFree($a)
    Return DllStructDelete($a)
EndFunc

Func DllStructSize($a)
    Return DllStructGetSize($a)
EndFunc

Func DllStructPtr($a)
    Return DllStructGetPtr($a)
EndFunc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
Ejoc

Ok I made a script converter to update the Old DllStruct function names to the new names introduced in beta 3.1.1.24:

DllStructConvert.au3


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
jpm

Ok I made a script converter to update the Old DllStruct function names to the new names introduced in beta 3.1.1.24:

<{POST_SNAPBACK}>

Very good Ejoc, That's a great support I was afarid how many will ask for that.

You did it :(

Share this post


Link to post
Share on other sites
Ejoc

Made post #1 host my UDFs for DllStruct, I may try adding them to the beta as UDFs.

New DllStruct UDF _DllStructGetSizeFromStr($string)

#75472


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
Ejoc

I had a thought, would it be worth it to add:

DllStructReadFromFile($p,"file.bin")

DllStructWriteToFile($p,"file.bin")

Mostly I would see this as a way to read and write binary files.

Could do something like:

$file = "AutoIt.exe"
$p = DllStructCreate("byte[" & FileGetSize($file) & "]")
DllStructReadFromFile($p,$file)
;do stuff via DllStructSetData & DllStructGetData
DllStructWriteToFile($p,$file)
DllStructDelete($p)

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
jpm

I had a thought, would it be worth it to add:

DllStructReadFromFile($p,"file.bin")

DllStructWriteToFile($p,"file.bin")

Mostly I would see this as a way to read and write binary files.

Could do something like:

$file = "AutoIt.exe"
$p = DllStructCreate("byte[" & FileGetSize($file) & "]")
DllStructReadFromFile($p,$file)
;do stuff via DllStructSetData & DllStructGetData
DllStructWriteToFile($p,$file)
DllStructDelete($p)

<{POST_SNAPBACK}>

I am not sure it is a good idea to include in DllStruct functions such other way to read/write file.

I will prefer to have an _UDF using FileRead and FileWrite :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×