Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain Windows Handle

Status
Not open for further replies.

sweep123

Technical User
May 1, 2003
185
GB
Can someone please tell me how to obtain the Windows handle when you know the windows resource. Its a MFC application.

I need to pass the handle for a push button to another routine. The resource is IDC_TEST1

I have been trying code snips like:

CWnd *pWnd = FindWindow( "IDC_TEST", NULL );
HWND hWnd = pWnd->GetSafeHwnd();

Note it is the hWnd that I require.

I am lost, too many APIs and handles!
 
You need to specify the Window class name, not the resource name to use FindWindow().

Is the window part of the running app, or a seperate app?

If it is a seperate app, did you write it? If so, you just need to specify the Window class name used in the app.
 
The class names is CHoverButton, but they are several on the dialog. How do I determine the handle for each HoverButton?

The window (Button1 for CHoverButton) is part of my application. I just need the handle to resize Button1's window.
 
I would say what you can not get the window handle from the name or ID of resource. Resource is a template for something. Real object instances of resources cound have very different HWND handles. For example you create two windows from the same resource...

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top