Advertisement

getting a window handle

Started by March 14, 2005 05:32 PM
2 comments, last by toxy 19 years, 8 months ago
I'm trying to retrieve a specific window handle and I'm not sure how to go about it in regular win32 programming. First I have to get a parent window of a dialog I create by using ::GetParent(hdlg) where hdlg is my dialog. Next I need to get a child of that window with an ID of lst2, but I'm not sure how to do that. Maybe a cleaner way to describe it is as it was shown in MFC: GetParent()->GetDlgItem(lst2); My problem is that I'm not using MFC. Can anyone help?
If you know the windows title you could use FindWindow like so:

HWND hwnd = FindWindow(NULL,"YourWindowTitle");
Advertisement
I think you can translate that directly. You can always check out MFC sources, they're often no more than WIN32 wrappers.
Try this:
GetDlgItem(GetParent(hdlg), lst2);
Wow, I am a true fool. I don't know how I missed GetDlgItem - it can't get much more straitforward than that!

Thanx for you help :)

This topic is closed to new replies.

Advertisement