|
-
Feb 16th, 2004, 10:43 AM
#1
Thread Starter
Member
TopMost=True but not TopMost! / How to LOAD a form without Show
Background:
I have an application that runs in the background at all times, linked to a database. A component of this is the popup alert window. A key point of this form is that it must show without taking focus and always be on top. This I have done by setting ‘TopMost=True’.
This form has method (‘AddMessage’) that can add an additional msg from within the program itself and a ‘Check’ method that is called periodically and checks the database for messages. ‘AddMessage’ will immediately show the message box window if not already on display, ‘Check’ will only show the window if a msg was found in the database.
This is all working ok, until calls started to come in every now and then saying that the window was hidden behind there application windows.
Problem:
After some experimenting I have discovered that if the first message to popup originates from the database (‘Check’ method), then the window is indeed always ‘on top’ as planned and everything works fine.
If however the first message to popup originates from ‘AddMessage’ method, then it never stays on top – despite the fact that TopMost IS True (I have checked this at runtime too).
This has perplexed me since both ‘Check’ and ‘AddMessage’ call the same function to 'Show' the window when needed.
Theory:
I have a feeling this is something to do with the way the form loads, I noticed elsewhere on this same project that a form does not actually ‘load’ even when you use a user-defined method on it until you hit the ‘Show’ command.
As a test I then did a Form.Show for that form just before calling ‘AddMessage’ – and hey presto the form did stay on top. Trouble is, the AddMessage method does not always want the form to display (delayed/timed messages are entered here) so putting Form.Show before I call this results in empty popup alerts every so often.
Questions:
How do I FORCE a form to load without actually showing it?
Failing this, what on earth could be causing a TopMost=True form not to be TopMost?
Many thanks for any help
-
Feb 16th, 2004, 10:50 PM
#2
Re: TopMost=True but not TopMost! / How to LOAD a form without Show
aah man you wrote an article on your problem
umm well first, just making sure you understand this: topmost will set the form on top of other forms in your application only, not on top of other applications (ie, your form will not always be on top of other windows like notepad, internet explorer, etc)
as for loading a form without showing it:
VB Code:
Dim frm As someForm
' load the form!!!
frm = new someForm
' show it
frm.show
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 17th, 2004, 03:59 AM
#3
Thread Starter
Member
Um, well I've been using TopMost and it has been putting at the top above ALL applications - when it decides it wants to that is!
And I've tried the .Show - but you see that shows the Form which I don't want - I just want it loaded and ready to Show when I'm ready - but the forms don't seem to actually 'load' until you hit the .Show command. And if you don't 'Show' pretty much straight off, then weird things happen, like the TopMost=True not working (and when it doesn't it doesn't stay on top of the applications windows let alone any others - but TopMost=TRUE so it should!)
The other reason is that I want to pre-load all the forms at startup that take a while to initialise (from database) - without .Show they do not even if I use other methods in them - I just HAVE to .Show to get the bloody things to load - but then it looks lame cos I have screen appearing and disappearing on the screen while I .Show and .Hide them all ready for use!
Perhaps this is just cos I'm using VS.Net 2002 - full of bugs!?!
It's so darn infuriating - every major problem I have always seems to be something so seemingly simple and petty - and probably due to bugs or lack of functionaility of VB6 in VS!
-
Feb 17th, 2004, 03:41 PM
#4
topmost isnt supposed to put the form on top of all applications....
you are probably putting some code in form_load
You can "load" a form the way I showed you above. Your problem is that you are probably using soem code in Form_Load event. and I think that Load only is fired when the form is shown. I guess you can declare a public sub or function in your form. For example call it LoadDB() and then do something like this:
Dim frm as new frmDataBase
frm.LoadDB()
'at a later time
frm.Show
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 17th, 2004, 04:00 PM
#5
Thread Starter
Member
Will try that tomorrow.
Cheers
-
Feb 18th, 2004, 08:00 AM
#6
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|