News:

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

Unable to show a Dialog Box

Started by Bokepatza, July 06, 2009, 01:50:45 AM

Previous topic - Next topic

Bokepatza

Hi all again,

I'm now trying to show an "About Dialog Box" I create with RadASM.

My "About Dialog Box" is defined in resources as follows:

#define IDD_DLG_ACERCADE 2000
#define IDC_GRP1 2001
#define IDC_STC_NOMPROG 2002
#define IDC_STC_COPYRIGHT 2003
#define IDC_IMG1 2004

IDD_DLG_ACERCADE DIALOGEX 10,10,145,100
CAPTION "Acerca de"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|DS_MODALFRAME
EXSTYLE WS_EX_DLGMODALFRAME
BEGIN
  CONTROL "&Aceptar",IDOK,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,48,81,54,15
  CONTROL "",IDC_GRP1,"Button",WS_CHILD|WS_VISIBLE|BS_GROUPBOX,3,0,138,99
  CONTROL "Bessel 1.0",IDC_STC_NOMPROG,"Static",WS_CHILD|WS_VISIBLE,48,12,54,9
  CONTROL "Copyright (c) 2009",IDC_STC_COPYRIGHT,"Static",WS_CHILD|WS_VISIBLE,48,27,90,21
  CONTROL "",IDC_IMG1,"Static",WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,12,15,21,18
END


In my WndProc I have:

.elseif uMsg==WM_COMMAND
mov eax,wParam
.if ax==IDM_ORDENASC
invoke OrdenaListView,ORDENASC
.elseif ax==IDM_ORDENDES
invoke OrdenaListView,ORDENDES
.elseif ax==IDM_ACERCADE
invoke CreateDialogParam, hInstance, addr DlgName, hWnd, OFFSET DlgProc, NULL
mov hWndDlg,eax

where
DlgName DB "IDD_DLG_ACERCADE",0


And my DlgProc is defined as follows:

DlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
.if iMsg==WM_INITDIALOG
invoke GetDlgItem,hWnd,IDOK
invoke SetFocus,eax
.elseif iMsg==WM_CLOSE
invoke EndDialog, hWnd, NULL
mov hWndDlg,0
.elseif iMsg==WM_COMMAND
mov eax,wParam
mov edx,eax
shr edx,16
.if dx==BN_CLICKED
.if eax==IDOK
invoke SendMessage, hWnd, WM_CLOSE, NULL, NULL
.endif
.endif
.else
mov eax,FALSE
ret
.endif
mov  eax,TRUE
ret
DlgProc endp


What's wrong?
If it is relevant, the "About Dialog Box" must be modal.

Thanks for your attention.

Ramon Sala

Hi Bokepatza,

When creating the dialog box, you write the following code:

CreateDialogParam, hInstance, addr DlgName, hWnd, OFFSET DlgProc, NULL


Try to replace addr DlgName with IDD_DLG_ACERCADE, that is:

CreateDialogParam, hInstance, IDD_DLG_ACERCADE, hWnd, addr DlgProc, NULL

Good luck!
Greetings from Catalonia

Bokepatza

Thank you a lot Ramon  :U

It now runs for me.

I thought I tried this yesterday because I read it in this forum, but didn't run. I did something wrong.

The Dialog Box appears now, but it is not a modal one. What could be the problem?

I trusted the Dialog Box definition given by RadASM, maybe there is the problem.

Thanks again.

Edit:
It is now modal.

I replace

invoke CreateDialogParam, hInstance, IDD_DLG_ACERCADE, hWnd, OFFSET DlgProc, NULL

with

invoke DialogBoxParam, hInstance, IDD_DLG_ACERCADE, hWnd, OFFSET DlgProc, NULL

Now I can continue programming.

Thanks again Ramon, I spent several hours yesterday trying to show the Dialog Box, till I decide ask here.

Bokepatza

#3
I have now 2 Dialog Box, an About one and another one to ask user to introduce some values.

It is supposed I need 2 DlgProc differents or I can use the same DlgProc for both DialogBox testing the hWnd parameter or just asigning different identifiers to buttons on both DialogBox?

fearless

Best keep seperate procs for each dialog box and seperate controls. RadASM will allow you to specify the starting id for the dialog box you are creating.

So for the main window you could have 1000 as IDD_Dialog, followed by 1001 - 1099 for your controls on this dialogbox/window. The about dialog could be IDD_About with an id as 2000, and all its controls are 2001-2099 for example. Then you can have say an options dialog IDD_Options with id of 3000 and controls from there onwards. Here is an example of what i use with a little project of mine that has a main window an about dialog and an options dialog, and a main menu

;AUUploader.dlg
IDD_Project equ 1000
IDC_ProjectSettings equ 1003
IDC_CboServers equ 1001
IDC_LblServer equ 1004
IDC_AppFileSource equ 1005
IDC_BrowseAppFile equ 1006
IDC_LblAppFileSource equ 1007
IDC_BrowseDataFile equ 1008
IDC_LblDataFileSource equ 1009
IDC_DataFileSource equ 1010
IDC_DestFolder equ 1011
IDC_LblDestFolder equ 1012
IDC_DataVersion equ 1013
IDC_LblDataVersion equ 1014
IDC_LblAppVersion equ 1015
IDC_AppVersion equ 1016
IDC_EXIT equ 1002
IDC_HELPINDEX equ 1017
IDC_UPLOAD equ 1018
IDC_NEW equ 1019
IDC_SITE equ 1020
IDC_SAVE equ 1021
IDC_OPEN equ 1022
IDC_ChkIncludeApp equ 1023
IDC_ChkIncludeData equ 1024

;AUUploader.mnu
IDM_MENU equ 10000
IDM_FILE_NEW equ 10001
IDM_FILE_OPEN equ 10002
IDM_FILE_UPLOAD equ 10004
IDM_FILE_EXIT equ 10006
IDM_OPTIONS_SITE equ 10021
IDM_OPTIONS_OPTIONS equ 10022
IDM_HELP_HELP equ 10031
IDM_HELP_ABOUT equ 10032

IDM_MRU_1 equ 19991 ; Menu MRU File
IDM_MRU_2 equ 19992 ; Menu MRU File
IDM_MRU_3 equ 19993 ; Menu MRU File
IDM_MRU_4 equ 19994 ; Menu MRU File
IDM_MRU_5 equ 19995 ; Menu MRU File
IDM_MRU_6 equ 19996 ; Menu MRU File
IDM_MRU_7 equ 19997 ; Menu MRU File
IDM_MRU_8 equ 19998 ; Menu MRU File
IDM_MRU_9 equ 19999 ; Menu MRU File
IDM_TRAY_SEP equ 19990

; About Box
IDD_About equ 3000
IDC_ABOUTBANNER equ 3004
IDC_ABOUT_EXIT equ 3002

;AUUOptionsDialog.dlg
IDD_Options equ 1100
IDC_GRP3 equ 1103
IDC_ChkOptionsRenameExe equ 1101
IDC_OptionsOk equ 1102
IDC_ChkOptionsCreateFolder equ 1104
IDC_OptionsCancel equ 1105
IDC_ChkOptionsIncludeFiles equ 1106


So my protos are defined as so:

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
AboutDlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
OptionsDlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD


in my main windows proc i check the id of the menu items (or buttons to call options or about)

.elseif eax==IDM_OPTIONS_OPTIONS
invoke DialogBoxParam,hInstance, IDD_Options, hWin, OFFSET OptionsDlgProc, NULL

.elseif eax==IDM_HELP_ABOUT
invoke DialogBoxParam,hInstance, IDD_About, hWin, OFFSET AboutDlgProc, NULL


and have two procs for each dialog:

AboutDlgProc PROC hWin:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
...


and

OptionsDlgProc PROC hWin:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
...
ƒearless

Bokepatza

Thanks very much fearless  :U

Then, I'll do that.