Solved

message boxes and "always on top" forms

Posted on 2004-08-08
7
213 Views
Last Modified: 2012-08-14
When I make a form always on top and then try to show a message box from that form , the message box is displayed behind the form . how can I make the message box appear if front of the form ?
0
Comment
Question by:adeljad
  • 4
  • 2
7 Comments
 
LVL 22

Accepted Solution

by:
DarkoLord earned 50 total points
ID: 11746128
Hi, try this:

MsgBox "Hello World", vbApplicationModal

Darko
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11749327
What code are you using? I can't get a message box to be concealed by the form.

Module1
-----
Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Sub KeepOffTop(Form As Form)
    SetWindowPos Form.hWnd, -2, 0, 0, 0, 0, 2 Or 1
End Sub

Sub KeepOnTop(Form As Form)
    SetWindowPos Form.hWnd, -1, 0, 0, 0, 0, 2 Or 1
End Sub
-----

Form1
----
Private Sub Command1_Click()
    MsgBox "hi"
End Sub

Private Sub Form_Load()
    KeepOnTop Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    KeepOffTop Me
    Unload Me
    Set Form1 = Nothing
End Sub
-----

Maybe it is an operating system problem? I am using Windows Millenium.

-Burbble
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11750984
vbApplicationModal should put it on top in all cases...

Darko
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 7

Expert Comment

by:Burbble
ID: 11752362
True, but there is no reason for the message box being concealed to begin with. Unless it is being called from another form?

-Burbble
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11763711
Looks like you got it working. I would still like to see why the message box was being concealed, but if it works for you, then I guess that's all that matters :-)

Good luck

-Burbble
0
 

Author Comment

by:adeljad
ID: 11776918
I think that the code I was using for Keeping on top where wrong

==================================
----------------
-Module1
-----------------
Declare Function SetWindowPos Lib "user32" (ByVal hWND As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Global Const conHwndTopmost = -1
Global Const conHwndNoTopmost = -2
Global Const conSwpNoActivate = &H10
Global Const conSwpShowWindow = &H40
--------------
-Form1
--------------
Private Sub Form_Load()
If mnuStayOnTop.Enabled = True Then
SetWindowPos hWND, conHwndTopmost, 0, 0, 774, 120, conSwpNoActivate Or conSwpShowWindow
Else
mnuStayOnTop.Enabled = False
SetWindowPos hWND, conHwndNoTopmost, 0, 0, 774, 120, conSwpNoActivate Or conSwpShowWindow
End If
End Sub
=====================


It's a wrong code I now when I use the other one it works
I wanted to Accept the tow answers and I didn't now that i have to accept only one
sory  :(
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11777099
Ahh, ok.

If you want to have the answer "unaccepted" so you can select both, you can post a question in http://www.experts-exchange.com/Community_Support/

-Burbble
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

14 Experts available now in Live!

Get 1:1 Help Now