size the program window at start up

G

Guest

The database opens to a startup form that has a defined size. I want to
maximize form and then size the access program window screen itself so it
doesn't take up the whole screen and there is no gray area. Is there a way
to do that automatically?
 
A

Arvin Meyer [MVP]

eye59 said:
The database opens to a startup form that has a defined size. I want to
maximize form and then size the access program window screen itself so it
doesn't take up the whole screen and there is no gray area. Is there a way
to do that automatically?

Here's some code written by MVP Syephen Lebans that should do the job:

Put this Declaration in the Forms General Declaration area.

Private Declare Function MoveWindow Lib "user32" _
(ByVal hWnd As Long, ByVal x As _
Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal _
bRepaint As Long) As Long

' Here's the code to MoveSize the
' Access Main window behind a Command button
Private Sub CmdSizeWin_Click()
Dim lngRet As Long
lngRet = MoveWindow(Application.hWndAccessApp, 10, 10, 800, 600, -1)
End Sub
 
A

Arvin Meyer [MVP]

I need to double check my typing, here's a better version of Stephen Leban's
code:

Option Compare Database
Option Explicit

Private Declare Function MoveWindow Lib "user32" _
(ByVal hWnd As Long, ByVal x As _
Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal _
bRepaint As Long) As Long

' Here's the code to MoveSize the
' Access Main window behind a Command button
Private Sub cmdSizeWindow_Click()
Dim lngRet As Long
lngRet = MoveWindow(Application.hWndAccessApp, 10, 10, 800, 600, -1)
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
G

Guest

Just what I needed. Thanks

Arvin Meyer said:
I need to double check my typing, here's a better version of Stephen Leban's
code:

Option Compare Database
Option Explicit

Private Declare Function MoveWindow Lib "user32" _
(ByVal hWnd As Long, ByVal x As _
Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal _
bRepaint As Long) As Long

' Here's the code to MoveSize the
' Access Main window behind a Command button
Private Sub cmdSizeWindow_Click()
Dim lngRet As Long
lngRet = MoveWindow(Application.hWndAccessApp, 10, 10, 800, 600, -1)
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 

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