centering an external app

S

Silvester

Hi,

I'm using shellwait to launch an external app exe in my A2000 app.

How can I ensure that the external app starts in the center of the screen ?

TIA
 
A

Alastair MacFarlane

Tia,

There is probably an easier way would but I would get the
the hwnd of the form, calculate its rectangle dimensions,
convert the dimensions to to pixels and move it. Possible
code that you would need to alter to suit your needs could
be as follows:

Declare Function GetWindowRect Lib "user32" (ByVal hWnd As
Long, lpRect As RECT) As Long
Declare Function GetDC Lib "user32" (ByVal hWnd As Long)
As Long
Declare Function ReleaseDC Lib "user32" (ByVal hWnd As
Long, ByVal hDC As Long) As Long
Declare Function Rectangle Lib "gdi32" (ByVal hDC As Long,
ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long,
ByVal y2 As Long) As Long

Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim V as RECT

Private sub moveform
GetWindowRect [hwnd of form], v
Call ConvertPIXELSToTWIPS(v.Top, v.Left, v.Right, v.Bottom)
DoCmd.MoveSize [move the form to your liking when you have
the handle]
End Sub

Public Sub ConvertPIXELSToTWIPS(t As Long, L As Long, B As
Long, R As Long)
Dim hDC As Long, hWnd As Long, retval As Long
Dim XPIXELSPERINCH, YPIXELSPERINCH
Const LOGPIXELSX = 88
Const LOGPIXELSY = 90
hDC = GetDC(0)
XPIXELSPERINCH = GetDeviceCaps(hDC, LOGPIXELSX)
YPIXELSPERINCH = GetDeviceCaps(hDC, LOGPIXELSY)
retval = ReleaseDC(0, hDC)
t = (t / XPIXELSPERINCH) * TWIPSPERINCH
L = (L / YPIXELSPERINCH) * TWIPSPERINCH
B = (B / YPIXELSPERINCH) * TWIPSPERINCH
R = (R / YPIXELSPERINCH) * TWIPSPERINCH
End Sub
 

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