Solved

Pop up box is hidden!!??

Posted on 2002-07-22
15
818 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
  • 5
  • 4
  • 2
  • +3
15 Comments
 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
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
Comment Utility
Is ::MessageBox(... working fine?
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
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
 

Author Comment

by:rw8
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Panda2.5's Release Date The latest Google Panda algorithm update was released late on Tuesday, September 27th, and was noticed to have started affecting website traffic on Wednesday, September 28th.  Google did not proactively announce this update,…
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
An overview of how to create reports in Adobe Analytics (formerly Omniture Site Catalyst) using pageNames, events, eVars and props. This video will show you how to install the Omniture Debugger tool so can see (and test) what is being passed int…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now