I need to create a Dialog Box from a dialog box template in memory. I use 'CreateDialogIndirectParam' ... but my app crash! :( In the API reference: "In a standard dialog box template, the DLGTEMPLATE structure and each of the DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation data array that follows a DLGITEMTEMPLATE structure must also be aligned on a DWORD boundary. All of the other variable-length arrays in the template must must be aligned on WORD boundaries." I dont understand this ... any ideas? help? source? ... Thx
Posted on 2001-05-17 12:23:00 by unknow
Hi! I don't know if this exactly what you need but take a look at it :) Btw close the window with alt+f4 :) Cheers! Latigo

.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 


.data 

DlgTemplate	DLGTEMPLATE <>
	; Menu	
	DW	0
	; Class
	DW	0	
	; the title of the dialog
	DB	'L',0,'a',0,'t',0,'e',0,'x',0,'X',0,0,0 
		
.data?

	Msg	MSG	
.code 

Start:

	MOV DlgTemplate.style,WS_VISIBLE OR WS_POPUP OR WS_BORDER 
	MOV DlgTemplate.dwExtendedStyle,0
	MOV DlgTemplate.cdit,0
	MOV DlgTemplate.x,150
	MOV DlgTemplate.y,80
	MOV DlgTemplate.lx,150
	MOV DlgTemplate.ly,80
	
	INVOKE GetModuleHandle,0
	PUSH 0				; LPARAM lParamInit
	LEA EBX,WinProk	
	ADD EBX,EDI  
	PUSH EBX			; DLGPROC lpDialogFunc	
	PUSH 0				; HWND hWndParent
	LEA EBX,DlgTemplate
	ADD EBX,EDI
	PUSH EBX			; LPCDLGTEMPLATE lpTemplate						
	PUSH EAX			; HINSTANCE hInstance
	CALL CreateDialogIndirectParam

	LoopHere:
	; The GetMessage function retrieves a message from the calling thread's message queue 
	; and places it in the specified structure
	PUSH 0
	PUSH 0
	PUSH 0
	LEA EAX,Msg
	PUSH EAX
	CALL GetMessage
	; Is the message we retrieved a WM_QUIT msg?
	CMP EAX,0
	JZ LoopEnd
	; The TranslateMessage function translates virtual-key messages into character messages.
	; which are read later by GetMessage
	LEA EAX,Msg
	PUSH EAX
	CALL TranslateMessage
	; Now the message is dispatched to the proper WinProk
	LEA EAX,Msg
	PUSH EAX
	CALL DispatchMessage
	JMP LoopHere
	LoopEnd:
	RET

WinProk proc USES ESI EDI EBX hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM


	MOV EAX,uMsg
	CMP EAX,WM_CLOSE
	JZ close
	
	XOR EAX,EAX
	RET
	
	close:
	INVOKE EndDialog,hWnd,0
	RET

	
WinProk endp

end Start

Posted on 2001-05-17 14:24:00 by latigo
The app crash under windows2000 :( ... any ideas?
Posted on 2001-05-17 16:34:00 by unknow
Really strange .. the app crash "sometimes" under windows2000 ... can anyone post some example, ideas or something?. Thx a lot.
Posted on 2001-05-19 12:41:00 by Unknow
It works now!! .. but another question X) ... If i put the DLGTEMPLATE struc in .DATA section it works but if i put between the program`s code (i really need it) the dialog doesnt appear :( !HELP! Thxx.
Posted on 2001-05-21 19:08:00 by unknow