473,396 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Make msgbox appear ontop of a form

Jerry Maiapu
259 100+
Hi everyone,
I have just created a form and made it to stay on top of non-Microsoft Access forms and windows using examples modules here: http://support.microsoft.com/kb/210500. Which works fine.

But the problem occurs when a message box is populated on the form; it appears at the back of the active form.
Can one genius tell how to make the msg box appear on top of the active form as usual.
I know that this is a result of the modules making active form to stay on top of the msgbox but can one smart person know any way around this to make the msgbox stay on top of the form?

For those who are interested in the code module:
This is how I did it.

I created a module called FormsOnTop:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. '.........................................................................
  4.  
  5. Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
  6.                                  ByVal hWndInsertAfter As Long, _
  7.                                  ByVal X As Long, _
  8.                                  ByVal y As Long, _
  9.                                  ByVal cx As Long, _
  10.                                  ByVal cy As Long, _
  11.                                  ByVal wFlags As Long) As Long
  12.  
  13.  
  14. Global Const HWND_TOPMOST = -1
  15. Global Const SWP_NOSIZE = &H1
  16. Global Const SWP_NOMOVE = &H2
  17.  
  18. Function TopMost(F As Form)
  19.    Call SetWindowPos(F.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
  20.                      SWP_NOMOVE Or SWP_NOSIZE)
  21. End Function
Then on the OnTimer event of the formI set the following properties:
Popup: Yes
OnTimer: =TopMost(Form)
TimerInterval: 50



I have absolutely know idea on how to make the msgbox appear ontop of the form.

Hope someone helps..


Thanks

Jerry
Jun 10 '10 #1
8 4405
jimatqsi
1,271 Expert 1GB
Why not surround your message box call with code to turn off these form properties (before the call) and reset them after the msgbox call?

Jim
Jun 10 '10 #2
Jerry Maiapu
259 100+
Can you give an hint on how to do this please
Jun 11 '10 #3
MMcCarthy
14,534 Expert Mod 8TB
Unfortunately Jerry, I'm not familar with the function you are using so I'm not sure how to turn it off. But Jim is right in that it's the only way to achieve this. Your code is actually overwriting the normal behavior of the msgbox which is in itself a popup dialog box that would normally have total focus until the user actions it. Someone more familar with the code you are using may know the code for reversing it.
Jun 11 '10 #4
Jerry Maiapu
259 100+
@msquared
If any smart person knows how to go around this like @msquared
says, please do so as this is like Banging my Head against the Brickwall. I would very much appreciate.

Thanks
Jun 15 '10 #5
jimatqsi
1,271 Expert 1GB
Okay, so you've got this function called TopMost that makes a form stay on top. I suppose the parameter value HWND_TOPMOST is the one controlling the behavior that keeps this window on top.

So how do you reverse that setting? I see that HWND_TOPMOST has a value of True/-1. So do you put a False/zero in place of that HWND_TOPMOST value that goes to the SetWindowPos API call? I don't know, but let's say that's how you do it. What you need to do is make another function called
NotTopMost

This function will call the SetWindowPos API call with the parameter values that will turn off this feature. Once you have created NotTopMost, then you will change your code for the msgbox so it is like this ...

Expand|Select|Wrap|Line Numbers
  1. Call NotTopMost  ' turn off the always on top setting
  2. Msgbox "whatever that message is"
  3. Call TopMost   ' turn the always on top setting back on
That will solve your problem.

Jim
Jun 15 '10 #6
Jerry Maiapu
259 100+
@jimatqsi
Honestly you're smart I'll try and get around this and see what happens
Jun 16 '10 #7
jimatqsi
1,271 Expert 1GB
Jerry, you thing I'm smart? You should see some of the solves the experts here at Bytes come up with. We have a lot of geniuses here. :)

Please tag the best reply. I don't know why, but I know they request that be done.

Jim
Jun 16 '10 #8
Jerry Maiapu
259 100+
Well, thank you ladies and gents you're all smart. I very much appreciate this community.
I'll tag the best answer as soon as am done.
Thanks.
Jun 17 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Howard Jess | last post by:
Apparently, form elements of type <input type="image" src="...> are not included in the form's elements collection. I don't understand why not; according to DOM2, all form control elements...
8
by: Nhmiller | last post by:
How is that done? Thanks. Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
0
by: Emmanouel | last post by:
Hello everybody, I have a program that i would like to run as a system tray application. This means that i do not need the main form to appear. I found in net help that : “To make the main...
2
by: chanmmn | last post by:
How to make dll appear in .Net tag when Add References? Please help chanmm
2
by: Russell G | last post by:
Hi Please help.. I have a form updating a table. When data is entered into a Combo box, I would like to use the BeforeUpdate or AfterUpdate (??) to verify if this information already exists in...
2
by: windsorben | last post by:
I'd like to have an image appear after the student answers each short answer question correctly. I can't seem to get it to work properly. See code below. Thanks! <html> <head>...
10
by: ApexData | last post by:
I can't seem to make a PopUp Dialog form Invisible! 'My main form calls the PopUp DoCmd.OpenForm "F-PAUSE", WindowMode:=acDialog 'My PopUp form "F-PAUSE" contains this code Private Sub...
14
by: wassimdaccache | last post by:
Hello everybody :) is there any function in Visual basic that I can use it to have a message box for my form for a certain second and after it will hide automatically for example : ...
10
by: moondaddy | last post by:
Hi, I have 3 tiny content controls and each has a Path in it to draw some lines. These need to be very small and I'm having trouble making the lines clear. the lines have a stroke thickness of "1",...
8
by: puT3 | last post by:
I have a form where user will insert any suggestion that they may have. I want to know how to make each suggestion appear according to the newest to oldest where the newest is on top and oldest...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.