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 6101569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:30:52+00:00 2026-05-23T13:30:52+00:00

I have an MFC application (using a legacy library that I can’t change). When

  • 0

I have an MFC application (using a legacy library that I can’t change). When the application starts, it loads a couple of drivers and shows message boxes if some drivers couldn’t be loaded. The loading of the drivers and the showing of the message boxes is done by a method inside the library that can’t be changed (let’s call this method Init). I would like to disable those message boxes (preventing them from “popping”). Is there something I could call before calling Init to disable Message Boxes temporarily and then re-enable them after?

(Note that if it is impossible to re-enable them after, I can very well live with that, I mostly want to disable them)

Thanks to all,

Note: If someone wonders about why I would like to do that, it is because my application exposes a COM interface and will be used by other applications. The only reason it is an application is that the library I use is much more easy to use when creating an MFC application (and not a dll). When it is called by my other applications, I don’t want the message boxes to show, I just want to get the errors if something goes wrong.

  • 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-23T13:30:52+00:00Added an answer on May 23, 2026 at 1:30 pm

    I am not sure whether this could work. I use it for subclassing some messageboxes not to preven them to popup and they are not from a dll.

    I set a hook to capture message boxes before poping up:

    HHOK hMessageBoxHook_ = SetWindowsHookEx(WH_CBT, 
                                             &CbtHookProc, 
                                             ::GetModuleHandle(NULL), 
                                             GetCurrentThreadId());
    

    The new hook procedure (CbtHookProc) would be like this:

    LRESULT CALLBACK CbtHookProc(   int nCode, 
                                                WPARAM wParam, 
                                                LPARAM lParam)
    {
        if(nCode < 0)
        {
            return ::CallNextHookEx(    hMessageBoxHook_, 
                                        nCode, 
                                        wParam, 
                                        lParam); 
        }
    
        switch(nCode)
        {
            case HCBT_CREATEWND: // a window is about to be created
                return -1;
        }
    
        return ::CallNextHookEx(    hMessageBoxHook_, 
                                    nCode, 
                                    wParam, 
                                    lParam); 
    }
    

    From microsoft documentation for HCBT_CREATEWND:

    If the hook procedure returns a
    nonzero value, the system destroys the
    window

    Then after calling Init you can remove the hook and message boxes will pop up again:

                ::UnhookWindowsHookEx(hMessageBoxHook_);
                hMessageBoxHook_ = 0;
    

    As I told you I can’t assure it works but give it a try.

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

Sidebar

Related Questions

I have a mature MFC C++ application that displays on screen and prints using
I have an MFC application. What scripting library can I use to give users
I have a legacy application written using VC++ MFC. For a latest feature, I
We have a MFC 8 application compiled with /CLR that contains a larger amount
I have a std::map declared thusly in a legacy MFC application: typedef std::map<long, CNutrientInfo>
I am working with a legacy MFC (VC 6) application that needs to be
I have an MFC application that has a webcontrol. When clickable links are clicked,
I have an MFC application that I was given (without source code) which opens
We have a very big MFC application that have 16 projects in the solution.
I have a long-running console-based application Sender that sends simple text to STDOUT using

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.