I am trying to create dialog with one button from memory template, here is how:



.data?

align 4
mydlg DLGTEMPLATE <WS_VISIBLE or WS_SYSMENU or DS_CENTER, 0,1,0,0,150,70>
dw 0
dw 0
dw 0
align 4
btnok DLGITEMTEMPLATE <WS_VISIBLE or WS_CHILD, 0,0,0,20,10,675>
dw 0FFFFh
dw 0080h
DW 0
dw 0
.code
start:
invoke GetModuleHandle,0
mov hInstance,eax
invoke DialogBoxIndirectParam,hInstance,addr mydlg,0,ADDR dlgproc,0


But DialogBoxIndirectParam, and GetLastError is of no help it returns "The operation completed successfully". Can someone give me a hint how to do this (I need it done this way rather than using macros from dialog.asm)
Posted on 2004-03-16 21:29:41 by Mikky
Here is how I did it:

http://www.asmcommunity.net/board/index.php?topic=14782

and here is a tool made by Vortex to simplify the process:
http://www.asmcommunity.net/board/index.php?topic=16671

edit: Wrong link :tongue:
Posted on 2004-03-17 03:19:09 by Delight
.686

.MMX
.XMM
.MODEL FLAT, STDCALL
OPTION SCOPED
OPTION CASEMAP:NONE

INCLUDE C:\masm32\include\windows.inc
INCLUDE C:\masm32\include\kernel32.inc
INCLUDELIB C:\masm32\lib\kernel32.lib
INCLUDE C:\masm32\include\user32.inc
INCLUDELIB C:\masm32\lib\user32.lib

LD MACRO lpStr:REQ
FORC wchar, <lpStr>
DW "&wchar"
ENDM
DW 0
ENDM

.CONST

IDE_EDIT = 5000

.DATA

ALIGN 4

pMainDlg DD WS_POPUP+WS_VISIBLE+WS_SYSMENU+WS_CAPTION+WS_MINIMIZEBOX+DS_MODALFRAME+DS_SETFONT ;style
DD 0 ;extended style
DW 2 ;# of child controls
DW 10 ;x
DW 10 ;y
DW 300 ;width
DW 300 ;height

;User Defined Data

DW 0 ;Do we have a menu? 0 = false; -1 = true
;DW MENUID ;Optional if above is -1
DW 0 ;Class specifier. 0 = no custom class, -1 = custom class ---+
;DW ATOM ;Optional if above is -1. +>> I'm not quite sure
;or +>> about this. :)
;LD <text> ;Optional if above is -1. ---+
LD <Test> ;Window caption
DW 8 ;only if DS_SETFONT is used on one of the window styles. Font Size.
LD <MS Sans Serif> ;only if DS_SETFONT is used on one of the window styles. Font Face.

ALIGN 4
pChild1 DD WS_CHILD+WS_VISIBLE ;style
DD 0 ;extended style
DW 10 ;x
DW 10 ;y
DW 100 ;width
DW 100 ;height
DW 2000 ;Control ID = IDC_EDIT1 ... IDE_EDIT2 ... IDB_BUTTON1 ...

;User Defined Data

DW -1 ;must be -1 then follow a value of a predefined class.
;This can be also be a string specifying a window class.

DW 80h ;Button = 80h
;Edit = 81h
;Static = 82h
;Listbox = 83h
;Scrollbar = 84h
;Combobox = 85h
;...

LD <Click> ;If the control contains a text or
;DW 0 ;otherwise or
;DW -1 ;if the control is a resource then follow
;DW RES_ID ;a word value containing the resource ID. string is not allowed.

;Creation Data Here can be of any size.

ALIGN 4
pChild2 DD WS_CHILD+WS_VISIBLE ;style
DD 0 ;extended style
DW 10 ;x
DW 150 ;y
DW 100 ;width
DW 100 ;height
DW IDE_EDIT ;Control ID = IDC_EDIT1 ... IDE_EDIT2 ... IDB_BUTTON1 ...

;User Defined Data

DW -1 ;must be -1 then follow a value of a predefined class.
;This can be also be a string specifying a window class.

DW 81h ;Button = 80h
;Edit = 81h
;Static = 82h
;Listbox = 83h
;Scrollbar = 84h
;Combobox = 85h
;...

LD <Type> ;If the control contains a text or
;DW 0 ;otherwise or
;DW -1 ;if the control is a resource then follow
;DW RES_ID ;a word value containing the resource ID. string is not allowed.

;Creation Data Here can be of any size.

.CODE

MainProc PROC hDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

mov eax, uMsg

.IF(eax == WM_INITDIALOG)

.ELSEIF(eax == WM_CLOSE)
invoke DestroyWindow, hDlg
.ELSE
mov eax, FALSE
ret
.ENDIF

mov eax, TRUE
ret

MainProc ENDP

start:

invoke GetModuleHandle, 0
invoke DialogBoxIndirectParam, eax, OFFSET pMainDlg, 0, OFFSET MainProc, 0

invoke ExitProcess, 0
ret

END start
:grin:
Posted on 2004-03-17 13:26:41 by arkane
:grin:

This one can be coded with much more less pain.


.386
.model flat,stdcall
option casemap:none


include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
DlgBoxTemplate db 1,0,255,255,0,0,0,0,0,0,0,0,196,0,200,144
db 2,0,10,0,10,0,217,0,105,0,0,0,0,0,68,0
db 105,0,97,0,108,0,111,0,103,0,32,0,98,0,111,0
db 120,0,0,0,8,0,188,2,0,1,77,0,83,0,32,0
db 83,0,97,0,110,0,115,0,32,0,83,0,101,0,114,0
db 105,0,102,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,1,80,72,0,19,0,78,0,31,0,186,11,0,0
db 255,255,128,0,66,0,117,0,116,0,116,0,111,0,110,0
db 0,0,0,0,0,0,0,0,0,0,0,0,128,0,129,80
db 36,0,62,0,145,0,24,0,184,11,0,0,255,255,129,0
db 0,0,0,0 ;Res2bin Rsrc.res + Bintodb tool
.code
start:
invoke GetModuleHandle, NULL
invoke DialogBoxIndirectParam,eax,ADDR DlgBoxTemplate,NULL,ADDR DlgProc,NULL
invoke ExitProcess,eax

DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM


.IF uMsg==WM_CLOSE

invoke EndDialog, hWnd,NULL

.ELSE
mov eax,FALSE
ret
.ENDIF
mov eax,TRUE
ret
DlgProc endp
END start


:grin:
Posted on 2004-03-17 14:13:17 by Vortex