News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How can i get the handle from an item in my Dialog Box

Started by ferby, March 26, 2009, 11:27:53 AM

Previous topic - Next topic

ferby

Hello,

i create a dialog box with the following code



CreateDialog proc
; sicher esi und edi
    push esi
    push edi

    ; speicher für struktur reservieren
    invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,1024
    mov esi, eax
    mov edi, esi

    ; Dialog allgemein
    mov DWORD PTR [edi+0],  DS_SETFONT or WS_OVERLAPPED or DS_CENTER or WS_VISIBLE ; Style
    mov WORD  PTR [edi+8],  3 ; anzahl controls
    ;mov WORD  PTR [edi+10], 0 ; x
    ;mov WORD  PTR [edi+12], 0 ; y
    mov WORD  PTR [edi+14], 166 ; breite
    mov WORD  PTR [edi+16], 70 ; höhe
    add edi, 22 ; ??

    ; Dialog Titel zu WideChar mappen
    invoke MultiByteToWideChar, CP_ACP,MB_PRECOMPOSED, ADDR AppNameDefault,-1, edi, LENGTHOF AppNameDefault
    add edi, LENGTHOF AppNameDefault * 2
    mov WORD PTR [edi], 9
    add edi, 2

    ; Schrift zu WideChar mappen
    invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED, ADDR fontClass,-1,edi,LENGTHOF fontClass
    add edi, LENGTHOF fontClass * 2

    ; Static
    add edi, 3 ; ??
    and edi, -4 ; ??
    mov DWORD PTR [edi+0],  WS_VISIBLE or WS_CHILD ; Style
    mov WORD  PTR [edi+8],  8 ; left
    mov WORD  PTR [edi+10], 8 ; top
    mov WORD  PTR [edi+12], 150 ; breite
    mov WORD  PTR [edi+14], 9 ; höhe
    mov WORD  PTR [edi+16], 100 ; id
    mov WORD  PTR [edi+18], 0FFFFh ; ??
    mov WORD  PTR [edi+20], 0082h ; ??
    add edi, 22 ; ??

    ; Hier erst Daten Pointer erhöhen da eax dazwischen überschrieben
    INC_DATA_POINTER 2
    ; Speicher String Position in ebx
    mov ebx, eax
    ; erhöhe den Pointer um String
    INC_DATA_POINTER_STR
    ; erechne String Länge (+1 wegen 0 Byte)
    sub eax, ebx
    inc eax

    ; Wandel Caption text in WideChar
    invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED, ADDR DATA[ebx],-1,edi, eax
    add edi, eax ; 2x wegen WideChar
    add edi, eax ; 2x wegen WideChar
    add edi, 1 ; ??
    and edi, -2 ; ??
    add edi, 5 ; ??
    and edi, -4 ; ??

    ; Edit
    mov DWORD PTR [edi+0],  WS_VISIBLE or WS_CHILD or WS_BORDER or WS_TABSTOP ; style
    mov WORD  PTR [edi+8],  8 ; left
    mov WORD  PTR [edi+10], 18 ; top
    mov WORD  PTR [edi+12], 150 ; breite
    mov WORD  PTR [edi+14], 12 ; höhe
    mov WORD  PTR [edi+16], 1000 ;id
    mov WORD  PTR [edi+18], 0FFFFh ;??
    mov WORD  PTR [edi+20], 0081h ; ??
    add edi, 26  ; ??
    add edi, 3  ; ??
    and edi, -4  ; ??

    ; Button
    mov DWORD PTR [edi+0],  WS_VISIBLE or WS_CHILD or WS_TABSTOP ;style
    mov WORD  PTR [edi+8],  8 ; left
    mov WORD  PTR [edi+10], 33 ; top
    mov WORD  PTR [edi+12], 150 ; breite
    mov WORD  PTR [edi+14], 15 ; höhe
    mov WORD  PTR [edi+16], IDOK ; id
    mov WORD  PTR [edi+18], 0FFFFh ;?
    mov WORD  PTR [edi+20], 0080h ;?
    add edi, 22 ;??

    ; Wandel Button Text in WideChar
    invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED, ADDR btnOk,-1,edi,LENGTHOF btnOk
    add edi, LENGTHOF btnOk*2 ; wide char Länge
    add edi, 1 ; ??
    and edi, -2 ; ??
    add edi, 2 ; ??

    ; Speicher für die Message Box
    invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT, 32
    invoke DialogBoxIndirectParamA,hInstance,esi,h_window, ADDR DlgProc,eax

    ; Speicher für Message Box und Struktur wieder freigeben
    push eax
    invoke GlobalFree,esi
    pop eax
    pop edi
    pop esi
    invoke GlobalFree, eax

ret
CreateDialog endp



How can i get the handle for the Edit Control?

Rainstorm

hi,

GetDlgItem retrieves the handle to a control, GetDlgCtrlID returns the ID
-

Vortex

Hi ferby,

You can use macros for in memory dialog templates to simplify coding :

\masm32\include\DIALOGS.INC

Examples :
\masm32\examples\dialogs