Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Im makeing a simple calculator useing the Win32 API. I do not have any Window per say, all I have is a dialog box. The dialog box is created inside WinMain.
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CALCULATOR), NULL, DlgProc);
As you can see there is no handle for a parent window as my Dialog box is the only window. I have a Text controll. As a test, inside my dialog procedure, for the message WM_INITDIALOG I use SetDlgItemText to set some default text into my Text controll (Calculator display).
Here is my problem, SetDlgItemText requires a handle for my dialog box. Since I dont have a parent window I dont know how to get a handle for my dialog box. GetDlgItem requires a handle for the dialog box which is no good.
How can I get a handle for my dialog box so I can pass it to SetDlgItemText?
Please help.

The HWND parameter in the dialog procedure you caught WM_INITDIALOG in, is the handle to your dialog. Your dialog does not have a parent, since it is free-standing, and the dialog is the parent window for all the controls on it.
Cheers

Thank you. Useing the hwnd passed to my dialog procedure as you stated, I got it to work, thanks so much.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |