|
-
January 22nd, 2015, 12:26 PM
#16
Re: Dialog Window Property Question?
 Originally Posted by tboygee
Wow.
Please, is there anyone willing to help me without judging my programming skills or motivation for daring to ask a question in the first place?
You've help a bunch Victor, I just need the rest of the puzzle - how do I use the newly obtained handle? I can't find a way to obtain handles of my other windows do a comparison. Can you give a quick example?
The piece you seem to be missing here is the difference between a HWND and a CWnd or CWnd*. Windows keep track of its resources, so a HWND is the identifier that you would would supply or get from Windows to know which resource you're referring to.
Visual Studio comes with MFC which is a class library that encapsulates a lot of the Windows API. If you see a CWnd or a pointer to one, it's an MFC object that represents a window. CWnd has a HWND operator, so you can pass a CWnd object to any function that's expecting an HWND, or you can use GetSafeHwnd() or m_hWnd if you need the Windows handle.
-
January 22nd, 2015, 12:49 PM
#17
Re: Dialog Window Property Question?
 Originally Posted by tboygee
Wow.
Please, is there anyone willing to help me without judging my programming skills or motivation for daring to ask a question in the first place?
It isn't about questioning your skills - it's about trying to help you solve the problem. If we understand what you are attempting to do in more detail, we might be able to help you solve it in a simple manner (without relying on something like GetForegroundWindow).
-
January 23rd, 2015, 08:18 AM
#18
Re: Dialog Window Property Question?
 Originally Posted by tboygee
Wow.
Please, is there anyone willing to help me without judging my programming skills or motivation for daring to ask a question in the first place?
As already been said, the question was about understanding the best way to help you. Now, consider this your question:
 Originally Posted by tboygee
I need to know the CWnd* type handles of my open windows so I can somehow compare to know which one is on top but I can't find a way to do that.
There is no such a thing like "CWnd* type handle". And dialog window handle has the same HWND type as the regular window handle does. You cannot distinguish your windows by handle types.
In case you need to distinguish your windows, you can do that by window text for example (GetWindowText() is the way to get that). The window text is what you can see in its caption.
In case you need to distinguish your windows by class (I mean window class, not C++ class), you can GetClassName(). The standard dialog window class name is "#32770".
You can inspect your window properties by means of Spy++ tool and choose one property, or combination of those, to rely on.
Best regards,
Igor
-
January 23rd, 2015, 11:47 AM
#19
Re: Dialog Window Property Question?
Thank you very much CGDEF and Igor. The insight you provided has allowed me to solve my problem.
-
January 23rd, 2015, 01:47 PM
#20
Re: Dialog Window Property Question?
 Originally Posted by 2kaud
[...]
GetForegroundWindow() for WIN32 doesn't return a pointer like the MFC version - it returns a value.
Indeed, Windows API GetForegroundWindow function does not return a pointer to an MFC object (as CWnd::GetForegroundWindow does) but returns a window handle (HWND) which IS A POINTER, as well.
HWND may be defined as void* or as a pointer to a structure. The second is currently used in actual Windows SDKs for STRICT Type Checking to detect at compile time, errors like for example passing a HBRUSH handle to a function that requires HWND.
See also: Visual C++: Why Watch window shows 'unused' for a HWND variable?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|