The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Mark_201 on June 06, 2006, 09:17:07 PM

Title: CreateDialogParam
Post by: Mark_201 on June 06, 2006, 09:17:07 PM
I just wanted to make sure the AboutDlgProc code is ok.


.elseif eax==IDM_HELP_ABOUT
invoke CreateDialogParam,hInstance,IDD_ABOUT_DLG,hWnd,ADDR AboutDlgProc,NULL
.endif

AboutDlgProc proc dWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

.if uMsg==WM_INITDIALOG            ; WM_INITDIALOG

.elseif uMsg==WM_CLOSE              ; WM_CLOSE
    invoke  EndDialog,dWin,0             ; end the dialog
.elseif uMsg==WM_COMMAND         ; WM_COMMAND
mov eax,wParam
and eax,0FFFFh                       ; get id
  .if eax==IDC_BTN_OK 
invoke  EndDialog,dWin,0 ; end the dialog
.endif
.else
    mov eax,FALSE                           ; delete unhandled message
    ret                                            ; and continue
  .endif
  mov    eax,TRUE                           ; message handled with success
  ret                                              ; and continue
AboutDlgProc      endp
Title: Re: CreateDialogParam
Post by: Tedd on June 07, 2006, 02:29:57 AM
Looks okay from here :wink
I would usually use SetFocus in WM_INITDIALOG, just to have control over what gets the focus. As the code currently is, it will fall through and return true, meaning windows will set the focus to the 'first' control. (If you choose your own focus, then you should return false.)
Title: Re: CreateDialogParam
Post by: Mark_201 on June 07, 2006, 03:27:55 AM
Quote from: Tedd on June 07, 2006, 02:29:57 AM
Looks okay from here :wink
I would usually use SetFocus in WM_INITDIALOG, just to have control over what gets the focus. As the code currently is, it will fall through and return true, meaning windows will set the focus to the 'first' control. (If you choose your own focus, then you should return false.)

I see what you mean.  If you have more then one controls (child window controls) in a dialog setfocus to what you want. I guess window will setfocus to the first non-static item as a default.