Positioning a form on the screen

S

Simon

I would like to be able to position a form on the screen when the Access
Window is minimized. I'm using the apiShowWindow to minimize the Access
Window and the form has to be set to popup. You can't use DoCmd.MoveSize
whent he Access window is minimized, right?
Thanks
 
S

Simon

sure was hoping that an expert would be able to answer this...
anyone know how to position a popup form on the screen?? -- not in the
Access window.
 
S

Stuart McCall

Simon said:
I think I got it working now.
Thanks for the help!

Great. My apologies for the sloppy variable declarations. Here's a
cleaned-up version:

Public Function CenterPopupForm(f As Object, Optional CenterOnScreen As
Boolean)
'Centers a Popup window
Dim sr As Rect, fr As Rect
Dim X As Long, Y As Long
Dim hw As Long

If IsZoomed(f.hWnd) Then ShowWindow f.hWnd, 1
hw = IIf(CenterOnScreen, GetDesktopWindow(), Application.hWndAccessApp)
sr = WinRect(hw)
fr = FormRect(f)
X = (sr.Left + (sr.Right - sr.Left) / 2) - ((fr.Right - fr.Left) / 2)
Y = (sr.Top + (sr.Bottom - sr.Top) / 2) - ((fr.Bottom - fr.Top) / 2)
SetWindowPos f.hWnd, 0&, X, Y, 0&, 0&, SWP_NOSIZE Or SWP_NOZORDER
End Function
 
S

Stuart McCall

Simon said:
your function works well and does the job with a minimal amount of code
nice!

Thanks. Minimal code is what I like. I hope it serves you well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top