CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Dialog Window Property Question?

    Quote Originally Posted by tboygee View Post
    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.

  2. #17
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Dialog Window Property Question?

    Quote Originally Posted by tboygee View Post
    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).

  3. #18
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Dialog Window Property Question?

    Quote Originally Posted by tboygee View Post
    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:
    Quote Originally Posted by tboygee View Post
    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

  4. #19
    Join Date
    Mar 2008
    Posts
    21

    Re: Dialog Window Property Question?

    Thank you very much CGDEF and Igor. The insight you provided has allowed me to solve my problem.

  5. #20
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,241

    Re: Dialog Window Property Question?

    Quote Originally Posted by 2kaud View Post
    [...]
    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?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Page 2 of 2 FirstFirst 12

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
  •  





Click Here to Expand Forum to Full Width

Featured