Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

message boxes and "always on top" forms

Posted on 2004-08-08
7
Medium Priority
?
223 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 150 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

926 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