Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows API

Status
Not open for further replies.

billoddie

Technical User
Joined
Dec 16, 2001
Messages
3
Location
AU
Has anyone used the Windows API to control the size and position of the access window.
 
I remembered a sample shareware that I had seen from
Peter's Software (Look on the web). He originally
provided a database with a ton of Windows API routines.
This is something that I evolved from that.

Put the following in a module:
(They are each one line only)

Declare Function WM_apiGetParent Lib "user32" _
Alias "GetParent" (ByVal hndWindow As Long) As Long _

Declare Function WM_apiSetWindowPos Lib "user32" _
Alias "SetWindowPos" (ByVal hndAccessWindow 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

I put this on my main form.

Private Sub Form_Current()
'
' This is based on an old shareware sample from
' "Peter's Software"
'
Dim WM_SWP_NOZORDER As Integer
Dim WM_SWP_SHOWWINDOW As Integer

Dim hndWindow As Long
Dim hndAccessWindow As Long
Dim lngXLeft As Long
Dim lngYTop As Long
Dim lngWidth As Long
Dim lngHeight As Long

WM_SWP_NOZORDER = &H4
WM_SWP_SHOWWINDOW = &H40

lngXLeft = 700
lngYTop = 300
lngWidth = 800
lngHeight = 300


hndWindow = Screen.ActiveForm.hwnd
hndAccessWindow = hndWindow
'
' The Access window has no parent
'
While hndWindow <> 0
hndAccessWindow = hndWindow
hndWindow = WM_apiGetParent(hndWindow)
Wend


Call WM_apiSetWindowPos(hndAccessWindow, 0, lngXLeft, _
lngYTop, lngWidth, lngHeight, WM_SWP_NOZORDER Or _
WM_SWP_SHOWWINDOW)

End Sub

HTH,
Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top