Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > C++

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-03-2009, 09:29 AM
anjana anjana is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
Setting focus to a message box

Hi ,
I am creating a message box for the following scenario.
One s/w is getting installed.During installation a pop up message box is coming asking whether to add some feature.The message box is having only 2 options.Yes/No.The problem happens over here.The message box is getting displayed.But the focus is still in the parent window.I have tried Setfocus(::GetActiveWindow());But its not working.Any suggestions?
Reply With Quote
  #2  
Old 11-03-2009, 11:24 AM
Hack's Avatar
Hack Hack is offline
Super Moderator
 
Join Date: Apr 2007
Location: Sterling Heights, Michigan
Posts: 7,719
What code are you using to display the message box?
__________________
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista

Microsoft MVP 2005/2006/2007/2008/2009
Reply With Quote
  #3  
Old 11-03-2009, 10:49 PM
anjana anjana is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
The code I have used is as below
Code:
 MessageBox( ::GetActiveWindow(),strSoftInstMSg,strCaption, MB_YESNO|MB_SYSTEMMODAL |MB_DEFBUTTON1   )
I have one more doubt.What parameter MB_SYSTEMMODAL does is "All applications are suspended until the user responds to the message box".I am trying out this in XP machine.Here the focus is not coming to the message box.Also other applications are still accessible.What could be the reason?
Reply With Quote
  #4  
Old 11-04-2009, 10:49 AM
jonnin jonnin is offline
Senior Member
 
Join Date: Dec 2003
Posts: 3,008
A normal message box is normally modal, unless the program is doing something odd to prevent this (always on top main window, borderless or unmovable windows, certain thread like activity, or, well, odd stuff!).

A simple
MessageBox("Hit Yes and stuff!");
*should*, if everything is normal, pop up a message box "modally" (that means it jacks control and the only thing you can do is move the message box around until you hit yes or no) that behaves the way you expect. You should not need all those fancy parameters to accomplish this task.

If that does not work, we have to figure out why first.


Lets get that far, and we can worry about system modal after. System modal is normally bad, you reserve it for extremely critical things. Word's message about saving your file over the old one should not prevent you from opening your internet browser, and thats what system modal does, it makes un-related programs affect each other, in a very bad way. Are you sure you want to do this?

Last edited by jonnin; 11-04-2009 at 10:52 AM.
Reply With Quote
  #5  
Old 11-05-2009, 01:20 AM
anjana anjana is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
But here what you have specified about system modal is not exactly what it does in my program.Its not behaving as "save as a file" window which exactly what I need.I tried to figure out why its not working in many ways and tried putting the handle of the installation window as the first parameter in messagebox.It was working for the first time but later it gave memory leak errors.The following is the change that I made in the code.
[code]
HWND hWind=NULL;
hWind = GetActiveWindow();
MessageBox( hWind,strSoftInstMSg,strCaption, MB_YESNO | MB_SYSTEMMODAL );[\Code]

I am new in MFC.I might be wrong in the usage of certain parameters.Please correct me if I am wrong.
Reply With Quote
  #6  
Old 11-05-2009, 09:36 AM
jonnin jonnin is offline
Senior Member
 
Join Date: Dec 2003
Posts: 3,008
It looks fine to me. How do you know it has a memory leak? There should not be one caused by this code, but certain memory check tools may be confused by your void * being assigned and not freed (which is correct, it should NOT be freed).

If this code works for you, it should be fine. If you really believe the tool that it causes a memory leak, trace it out to see (this is extremely frustrating and time consuming). You may have one (perhaps the strings used in the messagebox are broken or something) but I do not see one from the small code sample you gave.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MSN Message Box THL C++ 0 10-13-2005 03:18 AM
Setting focus to a text box cmoore Web 1 06-21-2001 11:25 AM
Setting focus to a text box cmoore Web 1 06-20-2001 05:19 PM
Postmessage function - Program focus message?? Chris L. VB Classic 2 04-14-2001 03:38 PM
Postmessage function - Program focus message?? Chris L. VB Classic 0 04-14-2001 12:41 PM


All times are GMT -4. The time now is 08:11 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.