Finding name/type of CWnd object

Posted on 2009-02-19
Last Modified: 2013-11-20
I am getting a CWnd * using GetActiveWindow().

I want to forward a message to this CWnd * if it is a certain type of dialog.

How can I go about ascertaining the type/name etc of the CWnd * so I can conditionally post a message to it?

Many thanks for any suggestions.
Question by:Attack_Trax
    LVL 19

    Accepted Solution

    First way: use the class type:

    CWnd* pWnd = GetActiveWindow();

    if ( pWnd->IsKindOf( RUNTIME_CLASS( CYourClass )))
       ... do something

    Second way: use the title

    CWnd* pWnd = GetActiveWindow();

    Cstring strTitle;
    pWnd->GetWindowText( strTitle )

    if ( strTitle == "Your title" )
       ... do something

    Author Comment

    I had to use IsKindOf() as the Window Text is being used to display status (its a pocket pc app).


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    Perl Awk Need Help 3 85
    Tab names are off by one 5 48
    Named range not carried over 10 53
    countEvens challenge 2 46
    In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
    Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now