Solved

Pop up box is hidden!!??

Posted on 2002-07-22
15
857 Views
Last Modified: 2013-11-28
i have a strange problem with my Dialog based application written in VC++6.0

in one of the dialog box (let's call it dialog box A) . it can call some other dialog box that should pops up in front of the dialog box A. (by calling something like dlg.DoModal() or AfxMessageBox ) But SOMETIMES those pop up dialog boxes just doesn't show up (i.e. dialog box A become inactive.. but the pop up dialog box can't be seen until you press the "alt" key).  it seems there is something wrong with the dialog box A because even the "afxmessagebox" dialog box won't appears when i have this problem.

not sure if i explained it clearly or not .. Any idea what is causing the problem and how can i fix it?

i was using the same dialog box and code for an earlier version of the software and it was running fine at that time

Thanks
0
Comment
Question by:rw8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +3
15 Comments
 
LVL 8

Expert Comment

by:VinExpert
ID: 7171246
Hi,

I have observed that kind of problem in Win-2k machines. Is that the one u r using? Well, I dont have a perfect solution but, I can suggest something for a try. From the OnInitDialog of the dialog that u r popping up, simulate the Alt key press. Add the following line of code before returning from the OnInitDialog function for each dialog that u pop up

PostMessage(WM_KEYDOWN, VK_MENU, 0);

Try it out.
VinExpert
0
 

Expert Comment

by:yossikally
ID: 7171248
Is ::MessageBox(... working fine?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 7171511
Hi VinExpert,

I have indeed also observed this kind of problem on Win2K machines when popping up a dialog from within another one via DoModal().
It's like it is hidden after some other window and just doesn't have the focus. Because, when I click with the mouse on the (MDI) application's main window then it appears. (I never tried pressing the <Alt> key)

But I also observed that quitting my program and launching it again, is enough to make the phenomenon disappear!

Did you observe that with apps you wrote yourself?
Did you try to solve it?

About your suggestion: won't it have the side-effect that the short cut keys will be underlined, while in Win2K they aren't (unless you press <Alt>)?
[Which is of course - I agree - better than the dialog not appearing at all]

I think there's something changed in Win2K concerning the focusing of windows.
Anyone else?
0
Technology Partners: 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!

 

Author Comment

by:rw8
ID: 7171521
yes i'm using win2k but i'm not sure if the problem only exists under win2k. (another ppl testing the software reported the same problem but i'm not sure if she is using win2k or not.. will try to find out tomorrow)

Yes the problem will usually disappear when i quit the application and run again!!  and when this problem occurs even the AfxMessageBox failed to appears (and it seems i can't get the correct result from a Yes/No afxmessagebox)

i was thinking there was something wrong with my "parent" dialog box.. but it now seems it's the OS issue?
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7171527
rw8,
    this is also not a tested solution but something you can try. Just put the following line in your OnInitDialog-function of the dialog that is supposed to be on top:

    BringWindowToTop();

Maybe this solves this issue without having sideeffects like posting an [Alt]-keypress.
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 7171535
Hi zzyx,

Yes, I have observed that in the applications that I have written. The main problem that I had faced was in fact the short cut keys were not getting underlined!!! And my users wanted it by default as it happens with all other MS-Os. I did not get any help in microsoft site too. So I solved it in that way. Showing the short cut keys underlined as soon as dialog comes up should have any implications as all other apps on all other OS behave in that way. Really people are not ok with that pressing of <Alt> just to see the keys.....
So, solving in this way should not bother much unless there is a better solution for it.
Yes, Win-2k has some criticle problem like that... definitly there is some change!!!

VinExpert
0
 

Author Comment

by:rw8
ID: 7173103
ok will try you guys solution.. but how can i solve the "Afxmessagebox" one?? i think i can't use any of you guys suggestion to fix this one?
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 7173687
Hi,

There will be workarounds for that also. Like set the timer before u call AfxMessageBox(...) and then in the timer handler after u kill the timer, get the active windoe handle by GetActiveWindow() and posting the <Alt> key press to that. That should solve, but, I feel its too much to do everytime. Why dont u consider a alternative method of having ur own dialog box which is similar to a AfxMessageBox and call that with the text. Usually it is good if u always pop up the Afx dialog with just OK button. Then it will be easy for u to impliment new dialog class which will behave similar to AfxMessageBox.

Try it out.
VinExpert
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7174202
VinExpert,

   there is more than meets the eye in an AfxMessageBox -- too much to do on your own. To name just 2 not so obvious properties: automatic sizing according to content and localization of buttons/tooltips.
0
 
LVL 8

Accepted Solution

by:
VinExpert earned 100 total points
ID: 7174899
fl0yd,

I understand that, thats why I told if the AfxMessageBoxes are simple, then u can go for a dummy one. But, if it has features like icons... different combination of Yes/No/Ok/Cancel... etc etc... it is difficult. There needs to be a compromise.

VinExpert
0
 

Author Comment

by:rw8
ID: 7175798
Sorry guys give me a day time and i'll come back and post my results.
the BringWindowToTop(); doesn't work
0
 

Author Comment

by:rw8
ID: 7182892
Thanks VinExpert and other guys for your comments. It works (although it's not the best solution, i can live with it at the moment)
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 7183186
rw8,

I know that its not the best. Yes, in most of the cases it solves the problem. Thats how my project also does. Unfortunately, I have not found any good solution for it yet.

All the best for ur project.
VinExpert
0
 

Expert Comment

by:Rockstar_North
ID: 12218652
Are there any dll files involved in this situation? I have an application that has a Main Frame window, this has a child dialog that is  loaded from a standard DLL file. This child dialog has a button that when pressed pops up a modal dialog. The Modal Dialog does not shoe untill the 'Alt' key is pressed.

I have had other problem with creating dialogs from a DLL. These involved messages going missing due to the main message look not calling the PreTranslateMessage method in the Child (Modeless) dialog that is provided by the DLL. This problem is covered my msdn articl ID: Q233263.

I have found no alternative solution to this problem but was wondering if the problems are related.

A.
0
 

Expert Comment

by:Rockstar_North
ID: 12218821
I found my the Accepted Answer did not work for my problem, although the symptoms were the same.

Instead i found my parent window was eating all messages that entered its PreTranslateMessage method. This was bad as the messages causing the dialog to get focus and be shown were being eaten too. I changed my PreTranslateMessage method to only eat Key presses (i deal with all of these myself the the dialog parent) and allow other messages through to the CDialog::PreTranslateMessage method.

A.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Read this article and get to know some best tips for outsourcing client PPC work to a white label PPC agency.
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.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

636 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