Click to See Complete Forum and Search --> : Confused ? getting the hWnd
I am making a program for my friend in C++ using MSVC++ 6.0.
it is not a MFC(he doesnt want runtimes) app.
how do I get the hWnd of an item in a resource file I have.
it is called
res.rc it has an Icon and a Dialog box,
how would I get the hWnd of this??
I am pretty sure I can show it using ShowWindow, but I just dont know how to get the hWnd,
Thanks,
Dennis Wrenn
parksie
Aug 6th, 2000, 07:50 AM
When you create the window using CreateDialog or equiv., it returns the hWnd of the window. You need to keep this in a global variable of something like that.
huh?
what do you mean?
I made the dialog and added it to a resource file,
how do I get the hWnd of that and show it?(the window)
parksie
Aug 6th, 2000, 12:21 PM
The resource file only stores a template for a window. You have to create a new window for it. MSDN has a full example project, but this is the gist of it: Create a WndProc, with format
BOOL CALLBACK WndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
Then, create the dialogue box:
INT_PTR DialogBox(
HINSTANCE hInstance, // handle to module
LPCTSTR lpTemplate, // dialog box template
HWND hWndParent, // handle to owner window
DLGPROC lpDialogFunc // dialog box procedure
);
For the template, use MAKEINTRESOURCE(IDD_YOUR_DIALOG_ID). Pass the WndProc for the dialogue box procedure.
Here's a full sample project: http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/sdk_begin_generic.exe
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.