?
Solved

HANDLE --> HWND

Posted on 1998-11-12
2
Medium Priority
?
1,048 Views
Last Modified: 2013-11-20
How can I convert a 'HANDLE' (retrieved from CreateProcess) to a 'HWND' or a 'CWnd *' ?

My application has launched an other application (Netmeting) with 'CreateProcess' and I want to minimize or not this application.

Can someone help me ?
0
Comment
Question by:mike_marquet
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 40 total points
ID: 1324563
You can use a 'EnumWindowsProc()' in the following way:

// globals:
HWND    g_hwnd;


    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory  (   &si,    sizeof  (   STARTUPINFO));

    if  (   CreateProcess   (   "netmeeting.exe",...))  //  notepad is running
        {
            g_hwnd  =   NULL;

            EnumWindows (   FindCreatedTask,    ( LPARAM) pi.dwProcessId));

            // ...

            // if 'g_hwnd' is not NULL, we found it...
        }

// ...

BOOL CALLBACK FindCreatedTask( HWND hwnd, LPARAM lParam)
{
    DWORD   dwPID2Find  =   ( DWORD) lParam;
    DWORD   dwPID       =   0;

    if  (   GetWindowThreadProcessId    (   hwnd,   &dwPID))
        {
            if  (   dwPID   ==  dwPID2Find)
                {
                    g_hwnd  =   hwnd;

                    return  (   FALSE);
                }
        }

    return  (   TRUE);
}

0
 

Author Comment

by:mike_marquet
ID: 1324564
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

840 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