Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6030713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:04:40+00:00 2026-05-23T05:04:40+00:00

After quite some effort, I managed to capture Windows Messages from a third party

  • 0

After quite some effort, I managed to capture Windows Messages from a third party MFC dll (I asked about that here). To make it short, I had to create a Message-only window with a message loop which captured the third party dll’s messages.

Said Message-only window must remain hidden. And it does, initially, since I pass HWND_MESSAGE to CreateWindowEx and call ShowWindow with SW_HIDE.
However, my C++ dll has some callbacks into managed code. And I noticed that when I perform the user actions that trigger the first of them, a console window appears. And it doesn’t go away until I close my app.

Since the console window has my app’s executable path as its title, I thought that the window was somehow being associated to my app. So I passed NULL to CreateWindowEx’s hInstance parameter, but it didn’t work.

Here’s my Message-only window code:

DWORD WINAPI CDRTech::MessageLoopThread( void * pParams ){
    HWND hwnd;
    MSG mensaje;
    WNDCLASSEX wincl;
    const string windowClass = "DR_TECH_MESSAGE_HANDLER";

    // Window class
    wincl.hInstance = ::GetModuleHandle(NULL);
    wincl.lpszClassName = windowClass.c_str();
    wincl.lpfnWndProc = ::DefWindowProc;
    wincl.style = CS_DBLCLKS;
    wincl.cbSize = sizeof (WNDCLASSEX);
    wincl.hIcon = ::LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = ::LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = ::LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    wincl.hbrBackground = ::GetSysColorBrush(COLOR_BACKGROUND);
    if(!::RegisterClassEx(&wincl)){
        ::GetErrorLoggerInstance()->Log( LOG_TYPE_ERROR, "CDRTech", "MessageLoopThread", "Could not register Message Handling Window" );
        return 0;
    }

    //Create Window (hidden)
    hwnd = ::CreateWindowEx(
            0,                      //Default ExStyle
            windowClass.c_str(),    //Window class
            "DRTech",               //Window Title
            WS_OVERLAPPEDWINDOW,    //Default Style
            CW_USEDEFAULT,          //Let Windows decide position
            CW_USEDEFAULT,
            10,                     //Width
            10,                     //Height
            HWND_MESSAGE,           //Message-only window
            NULL,                   //No Menu
            NULL,                   //Handle to application
            NULL                    //Window creation data
    );
    ::ShowWindow( hwnd, SW_HIDE );

    CDRTech* pThis = reinterpret_cast<CDRTech*>( pParams );
    pThis->InitDRTechLibrary();
    //Start message loop
    while(TRUE == GetMessage(&mensaje, NULL, 0, 0)){
        TranslateMessage(&mensaje);
        DispatchMessage(&mensaje);
    }
    return mensaje.wParam;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:04:41+00:00Added an answer on May 23, 2026 at 5:04 am

    The window you create is not related to the console window you see. Something that you call creates a console window (or you program is marked as a console application in which case the console is created when your application is launched).

    Put a breakpoint at AllocConsole() to find who is creating the console.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After quite some time debugging my code, I tracked down the reason for my
I am trying to make some enhancements to a production web app. After quite
I am new to JavaScript and after reading related books for quite some time,
I have been working on XNA for quite some time, but was asked to
I am developing some Hid Managment classes on osx and after googling for quite
After seeing quite some more cryptic error message, I realize they may be due
After living with Java IDE's for quite some time now, I'm back into the
After some work, I managed to get HipHop up and running on my server.
After working on a page for quite some time, the customer now decided that
After quite a few hours playing with rebase, the repo still looks different from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.