Need help to bring a modeless dialog to top

[I'm using VC++7 on Windows 2000)

I have a modeless dialog and I need it to be on top & have focus
everytime I show this dialog. But for some reasons, this dialog (most
of the time) comes up behind another dialog (not its parent, but
sibling). I have tried all of these but nothing worked
SetActiveWindow
SetFocus
BringWindowToTop
SetForegroundWindow

The only thing that could bring this dialog to the top (but still
doesn't have focus) is SetWindowPos with wndTopMost, but of course it
keeps the dialog on top forever, which I don't want.

I also tried to combine
SetWindowPos (with wndTopMost) and
SetWindowPost(with wndNoTopMost) right after, but this combination
failed to bring the dialog to the top again.

The only thing that 'works' is that if the user actually clicks on
this dialog after it shows up

Could someone give me some advices on what to do?

Thanks in advance!

0
jkclub2000 (16)
12/2/2005 5:31:38 AM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
609 Views

Similar Articles

[PageSpeed] 45

You must be doing something different as far as its window styles are
concerned. For a typical modeless dialog this behavior is unexpected.
Are you modifying its styles at run time? Instead of calling any of the
above functions, what happens if you call ShowWindow(SW_SHOW)?

---------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
12/2/2005 2:50:19 PM
Is the sibling window created after the modeless dialog that you are trying
to bring to front?

AliR.


<jkclub2000@yahoo.com> wrote in message
news:1133501498.862448.19030@g44g2000cwa.googlegroups.com...
> [I'm using VC++7 on Windows 2000)
>
> I have a modeless dialog and I need it to be on top & have focus
> everytime I show this dialog. But for some reasons, this dialog (most
> of the time) comes up behind another dialog (not its parent, but
> sibling). I have tried all of these but nothing worked
> SetActiveWindow
> SetFocus
> BringWindowToTop
> SetForegroundWindow
>
> The only thing that could bring this dialog to the top (but still
> doesn't have focus) is SetWindowPos with wndTopMost, but of course it
> keeps the dialog on top forever, which I don't want.
>
> I also tried to combine
> SetWindowPos (with wndTopMost) and
> SetWindowPost(with wndNoTopMost) right after, but this combination
> failed to bring the dialog to the top again.
>
> The only thing that 'works' is that if the user actually clicks on
> this dialog after it shows up
>
> Could someone give me some advices on what to do?
>
> Thanks in advance!
>


0
AliR3470 (3236)
12/2/2005 3:34:00 PM
No, I did not change the window style.

ShowWindow(SW_SHOW) is what I currently use to pop up this modeless
dialog

Here is the whole story. I'll keep it short.

I have a modal dialog (let's call it dialog A), from this I launch a
modeless dialog (let's call it dialog B) BUT I use AfxGetMainWnd() to
be dialog B's parent. Still, I did not have the problem (mentioned in
my 1st post) until I did this:

Before launching dialog B, I disable some controls on dialog A

After that, the problem appeared!

0
jkclub2000 (16)
12/2/2005 3:50:56 PM
If the last window you created has topmost set it will be on top of your 
dialog regardless of what you do.

I have an application where I start a non-modal dialog and my main UI has a 
toolbar button that pops it back up if it goes behind the main application. 
Actually, it's not really for that, I just leave it open so if the user 
tries to close it the window just gets hidden.  Then when the user presses 
the "Open ..." button it pops back up.  If it is just behind the UI it 
simply jumps to the front.  Since my main app created the dialog I know the 
object to call to tell the dialog to pop itself up.  I find that kind of 
safety net really helps because there doesn't seem to be any good way for 
Windows to always second guess which window I actually want on top.

Key: call function in dialog and have it pop "itself" to the front.

Tom

<jkclub2000@yahoo.com> wrote in message 
news:1133501498.862448.19030@g44g2000cwa.googlegroups.com...
> [I'm using VC++7 on Windows 2000)
>
> I have a modeless dialog and I need it to be on top & have focus
> everytime I show this dialog. But for some reasons, this dialog (most
> of the time) comes up behind another dialog (not its parent, but
> sibling). I have tried all of these but nothing worked
> SetActiveWindow
> SetFocus
> BringWindowToTop
> SetForegroundWindow
>
> The only thing that could bring this dialog to the top (but still
> doesn't have focus) is SetWindowPos with wndTopMost, but of course it
> keeps the dialog on top forever, which I don't want.
>
> I also tried to combine
> SetWindowPos (with wndTopMost) and
> SetWindowPost(with wndNoTopMost) right after, but this combination
> failed to bring the dialog to the top again.
>
> The only thing that 'works' is that if the user actually clicks on
> this dialog after it shows up
>
> Could someone give me some advices on what to do?
>
> Thanks in advance!
> 


0
tserface (3861)
12/2/2005 4:10:31 PM
In your scenario, does the focus come back to Dialog A? I am thinking
perhaps disabling or something else is happening asynchronously and
that causes dialog A to come back in front.

----------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
12/2/2005 4:50:55 PM
Yes, dialog A has focus and stay in front of dialog B when I show
dialog B, that's my problem. I referred to dialog A as the sibling
(maybe wrong term here)

0
jkclub2000 (16)
12/2/2005 5:01:37 PM
Try this(not necessary elegant but may give some clue): After disabling
the controls, post a custom message(use PostMessage) to dialog A and in
its handler, call pDIgB->ShowWindow(SW_SHOW);

I am doing this to rule out timing issue.

-------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
12/2/2005 5:20:59 PM
Thank you all for your help. I finally found a solution. It's more
like a work around. The modeless dialog actually gets activated then
quickly loses focus. So inside OnActivate function of it, I set focus
on a control of the dialog, and the dialog is kept on top

Ajay, your theory about timing issue is correct.

0
jkclub2000 (16)
12/3/2005 3:43:33 PM
Reply:

Similar Artilces:

Help with saving files
Hi I'm having a big problem with my PC at the moment and a hard drive reformat is on the cards. Last time i did this i tried to back up all my emails and contacts to reinstall them after putting a clean XP home install on the drive. This ended in failure as only the folders appeared and nothing in them!!! Can anyone help with an idiots foolproof guide as to how to back up all my contacts and current emails and news groups etc so that i can restore them after re-installing Win XP Home and Office XP? Any help would be greatly appreciated. Rgds KEv The file you need to back up is your ...

Problem Please help me #2
Dear Friends I am putting the same question back. I had a problem in my Store which was currupted and hence it was not doing the backup correctly due to the same my stm file started growing. So to solve the problem we have use the repair tool on the Store and Deleted the STM file and created new file. NOw the problem i am facing is in the mailboxes of users they have some emails which they can not open, Delete it gives the error message Object access failuer. I have deleted and purge one of mailbox and It is showing the correct mails when logged on to the new computer but if i log on...

VBA Error NEED HELP!!!
I am trying to create a "smart" database intermediary. I am trying to use the item number from the import value into a SQL Select statement as show below in my code to match up with only GP items associated with the generic item number. I am getting an error 424 (Object required) at run-time. Private Sub ItemNumber_GotFocus() Dim rst As Recordset Dim db As Database Dim strSQL As String 'Sets the RowSourceType to a Query ExportedItems.RowSourceType = "Value List" 'SQL string to query dynamically from Item Number in Access database If (Not IsNull(Me.Control...

2 value formula help needed
Hi All Sorry new to this, and am fairly ok on excel but having problems figuring this one out I have some values that i want to total and show and additional currency + total. So as an example Cell A1 A2 A3 A4 (this is how I want it to look) 500.00 600.00 AUD 750.00 1100.00+AUD 750.00 can i do this and how ? thank you just realised i have posted this in access instead of excel - sorry karenp wrote: >Hi All > >Sorry new to this, and am fairly ok on excel but having proble...

exporting report to excel- Help!
Hello All, I need some help with Excel. I am exporting a report (from progra called Report Viewer) and saving it in Excel format. After it is save and I go and open the report in Excel, I get an error saying- ERROR WERE DETECTED IN REPORT.XLS BUT MICROSOFT OFFICE EXCEL WAS ABLE TO OPE THE FILE BY MAKING THE REPAIRS LISTED BELOW. SAVE THE FILE TO MAKE TH REPAIRS PERMANENT. The repair listed is- RENAMED INVALID SHEET NAME. Once the spreadsheet is opened, any cell with the value of *0*, come up as a whole heap of ####### or the words DEFAULT FORMAT. I can fix i by fomatting the effected cell...

can't use windows mail, help
have been using windows mail regularly for months and even last night however today it decides to ask to logon and when i put in username and password it doesnt accept it. I have gone to tools, accounts, properties, servers and the password authentication box is unchecked, but still it asks me to logon. First, test your password by logging in to your provider's webmail. . If that works, it proves you have the correct username and password. A likely reason for the username/password failing in Windows Mail is=20 account corruption. One thing you should try as a possible quick fi...

Create a FormView/Dialog in runtime execution in VC 05
He everyone I have a toolbar with only two buttons. The first button will be show a dialog/form view (any component where i can put buttons, scrolls, etc) in the left/right side in my viewport (client view). The second button will be hide the dialog/form view. I can't do it! Anyone can help me? thanks esmitt ramirez j. esmitt@gmail.com http://lcg.ciens.ucv.ve/~esmitt "You can do it!" You can't do what exactly? AliR. <esmitt@gmail.com> wrote in message news:388f1c24-6cee-4584-a0ea-3f3729d44098@64g2000hsw.googlegroups.com... > He everyone > > I have a to...

the whole screen in publisher 2000 is shades of green help
when I open publisher 2000 the background is a shade of dark green and the page is a bright green. I have tried uninstalling and reinstalling/repair anyone any ideas please as I cannot view any of the colours properly. It does print properly but the colour scheme is purely guess work. No other programs are affected Help here http://www.mvps.org/the_nerd/Publisher/FAQs.htm -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "rsheraa103" <rsheraa103@discussions.microsoft.com> wrote in message news:AEB4D3EA-04E0-4A18-8F6F...

Help Needed Fixing Code !!!!!!!!!!
I need someone to take a look at this code for me and telling me what I am doing wrong. What I am trying to do is delete any row where this condition is true: c.Offset(0, 2) <> "Completed" And c.Offset(0, 3) <> "Completed" And _ c.Offset(0, 4) <> "Completed" And c.Offset(0, 5) <> "Completed" In other words, if the values in these cells are anything but complete, delete the entire row. For Each c In Worksheets("Ready for DDS").Range("B2:B" & SL_lRow).Cells If c.Offset(0, 2) &l...

I need help with an Excel "table" formula
I have the formula: =SUMIF(InStateTravel[Dept ID],$A$2,InStateTravel[Meals]) in my worksheet that works fine. Howerver, the field: "Meals", is also the value of cell A11 on the same worksheet. Further, all the cells below A11 are the value of other fields in the table: InStateTravel. Is it possible to write the formula so I can just copy it down? For example: cell A12 has a value of "Lodging"; unfortunately, when I copy the formula down, it still refers to the field [Meals]. I would like it to refer to the field [Lodging]. Thanks in advance. ...

Help!!!!!!!!!! Word as my e-mail editor quit..took a hike
What happened? It was working fine... Now I get a message saying word isn't installed or there is a problem so Outlook is my e-mail editor.... The artist in my is crying WHYYYYY ME!! Any suggestions? There appear to be a whole host of causes for this error message. Most have no solution. Here are a few that do: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q284900 http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q319796 http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q196871 http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q223934 -- Russ Valentine [M...

Help! Mailbox move gone bad
Hi, I was moving a mailbox between 2 mail stores when the PC I was using to to do the move lost power. I now have a complete mailbox in the source mail store (which the user can still access) and a partial mailbox in the target mail store that is marked with a red X. The partial mailbox cannot be purged, and it tells me that the operation cannot be performed because the mailbox has been reconnected to an existing user account. The AD user account shows that its mailbox is the one in the original mail store. How do I get rid of the partial mailbox so I can try this again? Thanks fo...

very annoying problem Please help
Hi, I am very upset, sorry I am sure this is simple for most, but. I use excel more as a database. I do not use many formulas etc. And it serves me well. Excel 2003 why can I NOT paste a number into a cell???? without excel messing with it. ex: 123497865 I want that pasted exactly as it looks. I have tried all 4 paste options. It's driving me crazy. I want excel to do magic whebn I choose, is this not possible? Sucks really Luke Sorry, forgot. I also tried ALL formats of the cells,rows. etc. I want this I get stuff like this 7.4019E+22, not the numbers thanks Luke "Frank&quo...

Extra quotes in CSV file (""") Help !
If I write a excel file that has a string as follows: ( 1,"ABC",2 ) the csv file contains ( 1,"""ABC""",2 ). How do I trun off the 2 extra ( " ). ??? FredCollinsIII@EarthLink.net Fred, Those extra quotes are intentional and necessary. For a description read "Delimited Text file" at http://www.smokeylake.com/excel/textfiles.htm -- Regards from Virginia Beach, Earl Kiosterud www.smokeylake.com Note: Top-posting has been the norm here. Some folks prefer bottom-posting. But if you bottom-post to a reply that's ...

Help with: ...query that does not include specified expression .... as part of an aggregate function...
Good Afternoon, I keep getting "You tried to execute a query that does not include the specified expression '(Max([b].[AS OF DATE])) Between [a].[closedate] And [a].[trade date]' as part of an aggregate function." when runnng the query below. Any assistance offered is greatly appreciated. Thank you. UPDATE DISTINCTROW tbl_TXN_PortIncExp AS a LEFT JOIN tbl_HLD AS b ON (a.[CUSIP OR LOAN #] = b.[CUSIP OR LOAN #]) AND (a.[PORTFOLIO CODE] = b.[PORTFOLIO CODE]) SET a.XDate = (Max([b].[AS OF DATE])) Between [a].[closedate] And [a]. [trade date], a.TRANSTYPE = "I...

Can't view pic. attachm. in Outlook EXP. Help
I am using Outlook Express 2003. I received an e mail with a picture attachment after viewing the picture I created a folder for it in Outlook Express Inbox (File/New/Folder) named it and dragged the e mail to the folder. Later I re-opened the e mail and found that I couldn't click on the attachments (they were a muted color and wouldn't allow me to view the pictures. I have used this method before and have not had this trouble but obviously this is a new installation and there must have been some setting that is causing this problem>>>>>Please Help. JOE Joe <...

Hooking/editing the caption of a dialog
I asked a couple days ago about ascertaining if a file was read-only and got good help. Thanks to the responders. If a file is a read-only file, I would like to communicate that to the user of the dialog MFC app. My preference would be to get ahold of the caption of the dialog that is being executed and append "Read only" to the string. That's what Microsoft Word does - at least something like that. When I create the dialog, I right click on it and select "Properties." Then the string that I enter is put in a resource file. Any ideas how to get ahold of that caption...

Need help with SQL statement
Hello, I need to do the following: The Item price must be copied to Pricelevel C as back-up. Next the price entered in Pricelevel A must be copied to Item price Is this possible thrue an SQL statement? I don't have SQL knowledge, so I hope you can help me. -- Kind regards, Raymond Bakker ReBuS b.v. The Netherlands BACKUP FIRST. If at all possible, perform these operations when the store is closed. In Store Operations: UPDATE Item SET PriceC = Price then... UPDATE Item SET Price = PriceA If you are in an HQ environment, you'll need a different set of queries. Tom -- St...

Need Help Please
Hello, I have a simple code for spell check Private Sub Command542_Click() DoCmd.RunCommand acCmdSpelling End Sub However in usage I am finding that this code is not checking subforms and some memo fields. Do you have any sug. in modifying the code to check subforms.. thks a million la -- Message posted via http://www.accessmonster.com ...

help with header row format
Hi, The first row in my excel file is the header. When I insert a new row after that, the new row takes the format, color etc of the header. How can I avoid the new rows inserted form taking the format of the forst row? Thanks If it's Excel 2003, when you insert the new row under the header row youy should get a small icon appearing which has a drop down arrow providing format options. You can select to format the new row as the line above, the line below, or clear formatting. -- Noel O'K "Chris" wrote: > Hi, > The first row in my excel file is the header. W...

Help #32
In excel 2003 if I choose the office assistant and type a question to get help, topics come up. But, when I choose a help topic a blank white box just pops up. ...

Help! Cannot access Publisher keep getting installation error message
I downloaded the patches from the MS website to deal with the viruses out there. This messed up my MS Office professional program and I got installation error messages. I tried to reload MS OFfice pro 2000 and in so doing, have had tremendous difficulty with the disc 2 that has Publisher. I also tried to load publisher from an original publisher 2000 disk. It is actually on my system, but i cannot bring Publisher up or any publisher documents. I am desperate to get at some files and need Publisher for work. Can anyone help. I'm desperate and they've hung up on me at MS...

Help. I am brand new to Excel but need to quickly come up with a formula to do the following:
Help. I am brand new to Excel, but I need to quickly come up with a formula to do the following. In any programming language it would be a simple do while loop, or equivalent, but I can not find out how to do it in Excel: Input a Daily Amount, let's say $150 * or call it DA Multiply it times 365 for a yearly amount Input a Number of Years, let's say 5 * or call it Y Multiply the Yearly Amount times the number of years to get a Total Yearly Amount or call it YA Input an inflation Rate, let's say 5%* or call it IR Input a number of Years, let's say 20 * or call it NY...

Upgrading Outlook 2000 to 2003 help.
We currently have all our staff laptops running Office 2000. We have since then got our selves a Exchange 2003 box and have been told that under the Exchange 2003 licence we can install Outlook 2003 on all our laptops that connect to the Exchange box. (is this correct?) If so do we just send round the Outlook 2003 in a .msi package to the GPO that contains the Staff laptops. Will it just install on log on as normal ? Will the new Outlook launch with tall the settings it had from the old outlook? Need some help on how to do this please Check the Office 2003 Resource Kit. Also, please be a...

Need a ping API
I have searched.. is there a library or a chunk of code I can grab that lets me ping any IP address and time the response? BTW it's for PocketPC. Cheers. Look up CPing on http://www.naughter.com/ IIRC, the code demonstrates use of 2 different APIs. Hopefully, at least one should be supported on PocketPC. HTH, Serge. http://www.apptranslator.com - Localization tool for your MFC applications "Simon L" <silangdon@hotmail.com> wrote in message news:29087ab8-7ffd-40b2-bec9-5f4b4fafb27f@q77g2000hsh.googlegroups.com... >I have searched.. is there a library or a chunk o...