Solved

message boxes and "always on top" forms

Posted on 2004-08-08
7
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

756 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