getting a window handle

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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?

Share on other sites
If you know the windows title you could use FindWindow like so:

HWND hwnd = FindWindow(NULL,"YourWindowTitle");

Share on other sites
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);

Share on other sites
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 :)