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

  • SEARCH
  • Home
  • 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 7509173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:49:46+00:00 2026-05-29T22:49:46+00:00

In the main view of my application, I create a modeless dialog i.e.: CMyDialog

  • 0

In the main view of my application, I create a modeless dialog i.e.:

CMyDialog dlg;
int returnval = dlg.doModal();

Now this is the first time this happens to me, but in this particular dialog, if I want to display a message box on a button press, it always appears behind the dialog. If I press the alt key on the keyboard, then it gains focus and comes up front.

int nResult = AfxMessageBox(_T("Are you sure you want to delete this file?"), MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL);
if(nResult == IDNO){
    return;
}
else{
...
}

I am wondering what have I done or what option I checked that would result in this behaviour ?


EDIT: Here is the small portion of code in my OnInitDialog function, I commented out all the rest and the same behaviour remains:

CDialog::OnInitDialog();
DEVMODE sDevMode;
ZeroMemory(&sDevMode, sizeof(DEVMODE));
sDevMode.dmSize = sizeof(DEVMODE);

EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&sDevMode);
_screenw = (int)sDevMode.dmPelsWidth;
_screenh = (int)sDevMode.dmPelsHeight;

_dlgx = (int) 50;
_dlgy = (int) 50;
_dlgw = (int) _screenw-100;
_dlgh = (int) _screenh-100;

this->MoveWindow(_dlgx,_dlgy,_dlgw,_dlgh);
  • 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-29T22:49:47+00:00Added an answer on May 29, 2026 at 10:49 pm

    AfxMessageBox would always be modal on the top window in Z-order. I don’t see any need to pass additional flags to bring it forward. Yes, if the application (main window) is not in focus, you may activate it explicitly before calling AfxMessageBox.

    The only situation I see message-box not coming forward is when parent window is created by other thread, and AfxMessageBox is being called from another thread.

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

Sidebar

Related Questions

In my Backbone application I have a main view that shows previews of posts.
I have an application composed of a main view and a secondary view which
I'm developing an iOS 4 application. I have a main view that contains another
I'm making a widget for a Yii application. The main layout view registers all
I'm creating a utility type application with a main and flipside view, and an
I have a web-view running JavaScript application, and sometimes it freezes/hangs when the main
I've got a Utility Application for iPhone 3.1.3. I have my main view loading
I have a application, and had to create another .h and .m file. This
My main form in my application has a datagrid view that can have 1
In my wpf application the main view has 5 tabs with 5 different usercontrols

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.