Positioning (Not Centered) Enhanced Message Box

dgreen

Member
Local time
Today, 17:22
Joined
Sep 30, 2018
Messages
397
Hi. Since your new message box uses API calls, then I guess you will also have to use API calls to position it.
 
DBG, does the API thing mean that MoveSize method won't work on such a form?
 
Looking at the underlying code it appears the section you need to change is here . . .

Code:
 ' At this point, we know how to place the dialog on the monitor
    ' However, we can't use DoCmd.MoveSize to place the window as it relies on Twips that are limited
    ' to integers, so they will overflow on a large screen. We also have the issue that DoCmd.MoveSize
    ' will place the window on the main monitor, not where the parent form or the Access app is.
    ' Here we need to use API functions, and they use pixels not twips
    
     Dim screenX As Long, screenY As Long
     formWidth = ConvertTwipsToPixels(formWidth, 0)
     formHeight = ConvertTwipsToPixels(formHeight, 0)
     With MonitorInfo.rcWork
        screenX = .Left + (Abs(.Right - .Left) - formWidth) \ 2
        screenY = .Top + (Abs(.Bottom - .Top) - formHeight) \ 2
     End With
    
     ' http://msdn.microsoft.com/en-us/library/ms633545.aspx
     SetWindowPos Me.hwnd, 0, screenX, screenY, formWidth, formHeight, &H20
 
DBG, does the API thing mean that MoveSize method won't work on such a form?
My guess is a no. It didn't look like his new message box is a "form." It would be like trying to use MoveSize against a MsgBox. Not sure that is possible. If it's a form though, then MoveSize should work. Cheers!
 
Hmmm, now I don't know, but I thought it is a form. From the website
One thing of note is the way the form is kept modal.
Rather than using DoCmd.OpenForm and DoCmd.Close I use the form as a class and create an instance manually (see the code in Dialog.Box and Dialog.Richbox). I keep this instance alive until I got the form’s result back.
If you are interested in knowing how the form is made modal, this is the code in FormDialog.ShowModal() what keeps the form open until the user clicks a button:
 
Hmmm, now I don't know, but I thought it is a form. From the website
I didn't review the website, 'cause I was on my phone. I just saw it was using APIs. I guess we'll see. Cheers!
 
As you look at this, does this mean I just get one option in terms of placing this message box? That I couldn't change the position to different locations for different message boxes?

Looking at the underlying code it appears the section you need to change is here . . .
 
have you tried the Better Messagebox (Sample Database).
 
It is what we're talking about. Same thing.
Hi. Since you don't want the message box in the center of the screen, where would you like to put it? Just curious...
 
My situation that generated this thought started when I was generating Outlook emails from my Access database. The messages and popups were all centering on the same screen. When youre trying to multi-task you're having to move things out of the way to see the message box. I figure if I can put the box somewhere else on the screen, the user won't have to search for it.
1585276509746.png
 
My situation that generated this thought started when I was generating Outlook emails from my Access database. The messages and popups were all centering on the same screen. When youre trying to multi-task you're having to move things out of the way to see the message box. I figure if I can put the box somewhere else on the screen, the user won't have to search for it.
View attachment 80206
Well, based on your last response, I put the message box on the top left corner of the screen. Is that not good? Now, you want it on the bottom left or top right corner instead?
 
I was thinking I'd like a flexible option but I see what you did. Changing the code and commenting out the portion that determines the screen size and divides it in half.

Code:
     With MonitorInfo.rcWork
        screenX = .Left ' + (Abs(.Right - .Left) - formWidth) \ 2
        screenY = .Top ' + (Abs(.Bottom - .Top) - formHeight) \ 2
 

Users who are viewing this thread

Back
Top Bottom