The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: pavellus on July 05, 2006, 09:35:03 AM

Title: Changing controls texts within dialogs
Post by: pavellus on July 05, 2006, 09:35:03 AM
See second post first.

I have one window and two children dialogs with buttons and static texts:

  invoke CreateWindowEx ....

  invoke CreateDialogParam,hInstance,addr DlgName,hWnd,addr WndProcDlg_1,NULL
  mov dlgHWnd_1,eax

  invoke CreateDialogParam,hInstance,addr SubDlgName,hWnd,addr WndProcDlg_2,NULL
  mov dlgHWnd_2,eax

I need to change static text from dialog 1 by clicking a button on dialog 2.
First I try to change static text on dialog 2 self.

    WndProcDlg_2 proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

        invoke GetDlgItem,dlgHWnd_2,1002 ;CONTROL "SUBWINDOW",IDC_STC2,"Static",...
   mov hDlgWndStaticText,eax
   invoke SetWindowText, hDlgWndStaticText, ADDR Text_1 ; Text_1  db 'SystemTray',0

I click on button and nothing happend.
Title: Re: Changing controls texts within dialogs
Post by: pavellus on July 05, 2006, 10:52:34 AM
I have parent window and two children dialogs.
I passed them different procedures in CreateDialogParam (post above).
Why dialogs share the same procedure from parent window? How to assign them their own procedure?
Title: Re: Changing controls texts within dialogs
Post by: ToutEnMasm on July 05, 2006, 01:36:06 PM

invoke sendmessage,Hdialbox,WM_SETTEXT,,
Where Hdialbox is the handle in the dlg wnproc,see the exact syntax of WM_SETTEXT to put the address of the string in the correct place.
                    ToutEnMasm
Title: Re: Changing controls texts within dialogs
Post by: Ehtyar on July 06, 2006, 01:52:20 AM
SetDlgItemText (http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/setdlgitemtext.asp)?
Title: Re: Changing controls texts within dialogs
Post by: ToutEnMasm on July 06, 2006, 06:27:14 AM

Try it !
                     ToutEnMasm
Title: Re: Changing controls texts within dialogs
Post by: pavellus on July 06, 2006, 08:47:02 AM
Ok, but my question now is:
Why dialogs share the same window procedure from parent window? How to assign them their own procedure?
Title: Re: Changing controls texts within dialogs
Post by: Tedd on July 06, 2006, 12:47:02 PM
You give the address of the dialog procedure when you call CreateDialogParam - so you can give different dialog-procs that way.

But I think this may not be what you mean :wink
When the parent or dialog receives a message (e.g. BN_CLICKED), the 'lParam' of the message gives the handle for who sent it, so you can use that to identify where it came from; also LOWORD(wParam) is the window identifier, so you could use the too. So the parent window doesn't need a different proc for each dialog, just a single one and it can identify the source of the messages.
Title: Re: Changing controls texts within dialogs
Post by: pavellus on July 06, 2006, 03:32:34 PM
OK, I will try to use one window procedure.
But during creating dialogs I give them the others windows procedures - different than main window procedure (see post 1).
After clicking on any of dialogs I see that parent window procedure (WndProc) is executing. I dont know how it is possible?