I have created a dlbBox with an dit control with the dialog editor.
#define dlg 1000
#define textEd 1001
dlg DIALOGEX 6,6,194,106
CAPTION "Dialog"
FONT 8,"MS Sans Serif"
STYLE 0x10CF0000
EXSTYLE 0x00000000
BEGIN
CONTROL "",textEd,"Edit",NOT 0x00820000|0x50010000,-34,1,190,102,0x00000200
END
How do I get invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
to load and display this dlg Box?

This is the code from Icelions tutorial 10 with the menu removed:
.data
ClassName db "DLGCLASS",0
DlgName db "Dialog",0
AppName db "Our First Dialog Box",0

.data?
hInstance HINSTANCE ?
buffer db 512 dup(?)

.const
dlgWin equ 1000
textEd equ 1001

.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hDlg:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
mov hDlg,eax
invoke SetFocus,eax
INVOKE ShowWindow, hDlg,SW_SHOWNORMAL
INVOKE UpdateWindow, hDlg
.WHILE TRUE
INVOKE GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke IsDialogMessage, hDlg, ADDR msg
.if eax==FALSE
INVOKE TranslateMessage, ADDR msg
INVOKE DispatchMessage, ADDR msg
.endif
.ENDW
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.iF uMsg==WM_CREATE
.ELSEIF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
.IF lParam==0
invoke DestroyWindow,hWnd
.ENDIF
.ELSE
mov edx,wParam
shr edx,16

.ENDIF
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
xor eax,eax
ret
WndProc endp
end start


The program compiles and links but doesn't display the dialog.
:stupid:

Any suggestions?
Posted on 2003-10-11 19:32:33 by Klod
The only way you can load a dialog by name is if you give it an ID of 0, you have given your dialog an ID of 1000 so it must be loaded by resource number:
invoke CreateDialogParam, hInstance, [b]1000[/b], NULL, NULL, NULL

Also if you wish to use a custom window class you must specify that class in the properties window of the editor. It will appear as follows in the RC:

CLASS "DLGCLASS"
Posted on 2003-10-11 19:46:23 by donkey
Thanks Donkey for your reply.
Are RadAsm dialog boxes custom Controls?
If I put CLASS "DLGCLASS in RC I get an ERROR
RadDlg.rc (3): error RC2135 : file not found: "DLGCLASS"
Posted on 2003-10-11 21:02:49 by Klod
RadASM dialogs are standard DialogEx type dialogs, they are not custom controls.

Do not ever add anything directly to an RC file generated by RadASM until you understand exactly how they are generated and even then never to an RC file in the RES folder. To set the class of your dialog use the dialog editor, select the dialog by clicking on it's caption bar, in the propertes window you will find a field that is labeled "Class" just enter the class name there, RadASM will add it to the RC file for you.
Posted on 2003-10-11 21:48:34 by donkey
Thx Donkey
The dialog displays correctly.
The next question would be how to get text to and fro the edit box?:stupid:
Posted on 2003-10-11 22:11:47 by Klod
You can use the WM_SETTEXT, WM_GETTEXT messages, the function SendDlgItemMessage is probably the easiest way to send messages with a dialog box as it doesn't require getting a handle (though that is pretty simple to do with GetDlgItem):
; In your data section:

.data
Text db "Some Text",0 ; <- the ,0 is very very important, it terminates the string
buffer db 256 DUP (0)

; In your code
; assuming your edit control has an ID of 1001
; hWin is the handle of your dialog, it is the first parameter in any message
invoke SendDlgItemMessage, hWin, 1001, WM_SETTEXT, 0, OFFSET Text
invoke SendDlgItemMessage, hWin, 1001, WM_GETTEXT, SIZEOF buffer -1, OFFSET buffer
Posted on 2003-10-11 22:18:09 by donkey
When I want to show a dialog box with menu ( I choose menu from Dialog Editor ).
and use the following code
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,ADDR DlgProc,NULL
.if eax==-1
invoke MessageBox,NULL,ADDR DlgName,ADDR TestString,MB_OK
.endif
invoke ExitProcess,eax

It's not show my Dialog and eax equ -1

Please help me !
Posted on 2003-10-18 02:49:54 by dreamweaver
You have probably used a common control in the dialog box, try to put InitCommonControls in there:
invoke GetModuleHandle,NULL

mov hInstance,eax
[b]invoke InitCommonControls[/b]
invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,ADDR DlgProc,NULL
.if eax==-1
invoke MessageBox,NULL,ADDR DlgName,ADDR TestString,MB_OK
.endif
invoke ExitProcess,eax
Posted on 2003-10-18 02:58:39 by donkey
Hi dreamweaver

There might be another problem. Check the main RC file and verify that the menu is included first.

#include "Res/MyProgMnu.rc"
#include "Res/MyProgDlg.rc"

The reason is that the dialog reference the menu by it's name and the name must be defined before it is referenced.

KetilO
Posted on 2003-10-18 03:12:32 by KetilO
no I'm not include any common controls .
Here's my source:


.386
.model flat,stdcall
option casemap:none

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

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

.data
DlgName db "MyDialog",0
AppName db "Test App",0
TestString db "Test String"

.data?

hInstance HINSTANCE ?
buffer db 512 dup(?)
.const


;testing.dlg
IDD_DLG1 equ 1000
IDC_BTN1 equ 1001
IDC_EDT1 equ 1002

;testing.mnu
IDM_FILE equ 10001
IDM_OPEN equ 10002
IDM_GETTEXT equ 10003
IDM_EXIT equ 10004

.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,ADDR DlgProc,NULL
.if eax==-1
invoke MessageBox,NULL,ADDR DlgName,ADDR TestString,MB_OK
.endif
invoke ExitProcess,eax

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

DlgProc endp
end start
Posted on 2003-10-18 03:22:37 by dreamweaver
Why not zip the project and post it, it would make it easier to find the problem.
Posted on 2003-10-18 03:29:22 by donkey
ok it's my source .
Please check it . Great Thanks !
Posted on 2003-10-19 07:09:12 by dreamweaver