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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

center forms according to resolution of screen..possible?

Status
Not open for further replies.

subbywrx

Technical User
Mar 23, 2006
4
0
0
US
Hello. I have a menu bar at the top and a main screen that updates when you
press a command at the top menu. What I want is a way to center the menu
bar at the top of the page and center the center screen underneath or in the
middle of the screen. Then when anyone tries to resize the screen it will
automatically center to any screen size.

Possible??
 
Never played with it but I snagged some code from a technet article awhile ago that may be helpful...
Hopefully you can still find it.

'Tech Net article
'ACC: How to Use the GetSystemMetrics() API Call
'PSS ID Number: Q88922

Public Const SM_CXSCREEN = 0 ' Width of screen
Public Const SM_CYSCREEN = 1 ' Height of screen
Public Const SM_CXFULLSCREEN = 16 ' Width of window client area
Public Const SM_CYFULLSCREEN = 17 ' Height of window client area
Public Const SM_CYMENU = 15 ' Height of menu
Public Const SM_CYCAPTION = 4 ' Height of caption or title
Public Const SM_CXFRAME = 32 ' Width of window frame
Public Const SM_CYFRAME = 33 ' Height of window frame
Public Const SM_CXHSCROLL = 21 ' Width of arrow bitmap on
' horizontal scroll bar
Public Const SM_CYHSCROLL = 3 ' Height of arrow bitmap on
' horizontal scroll bar
Public Const SM_CXVSCROLL = 2 ' Width of arrow bitmap on
' vertical scroll bar
Public Const SM_CYVSCROLL = 20 ' Height of arrow bitmap on
' vertical scroll bar
Public Const SM_CXSIZE = 30 ' Width of bitmaps in title bar
Public Const SM_CYSIZE = 31 ' Height of bitmaps in title bar
Public Const SM_CXCURSOR = 13 ' Width of cursor
Public Const SM_CYCURSOR = 14 ' Height of cursor
Public Const SM_CXBORDER = 5 ' Width of window frame that cannot
' be sized
Public Const SM_CYBORDER = 6 ' Height of window frame that cannot
' be sized
Public Const SM_CXDOUBLECLICK = 36 ' Width of rectangle around the
' location of the first click. The
' second click must occur in the
' same rectangular location.
Public Const SM_CYDOUBLECLICK = 37 ' Height of rectangle around the
' location of the first click. The
' second click must occur in the
' same rectangular location.
Public Const SM_CXDLGFRAME = 7 ' Width of dialog frame window
Public Const SM_CYDLGFRAME = 8 ' Height of dialog frame window
Public Const SM_CXICON = 11 ' Width of icon
Public Const SM_CYICON = 12 ' Height of icon
Public Const SM_CXICONSPACING = 38 ' Width of rectangles the system
' uses to position tiled icons
Public Const SM_CYICONSPACING = 39 ' Height of rectangles the system
' uses to position tiled icons
Public Const SM_CXMIN = 28 ' Minimum width of window
Public Const SM_CYMIN = 29 ' Minimum height of window
Public Const SM_CXMINTRACK = 34 ' Minimum tracking width of window
Public Const SM_CYMINTRACK = 35 ' Minimum tracking height of window
Public Const SM_CXHTHUMB = 10 ' Width of scroll box (thumb) on
' horizontal scroll bar
Public Const SM_CYVTHUMB = 9 ' Width of scroll box (thumb) on
' vertical scroll bar
Public Const SM_DBCSENABLED = 42 ' Returns a non-zero if the current
' Windows version uses double-byte
' characters, otherwise returns
' zero
Public Const SM_DEBUG = 22 ' Returns non-zero if the Windows
' version is a debugging version
Public Const SM_MENUDROPALIGNMENT = 40
' Alignment of pop-up menus. If zero,
' left side is aligned with
' corresponding left side of menu-
' bar item. If non-zero, left side
' is aligned with right side of
' corresponding menu bar item
Public Const SM_MOUSEPRESENT = 19 ' Non-zero if mouse hardware is
' installed
Public Const SM_PENWINDOWS = 41 ' Handle of Pen Windows dynamic link
' library if Pen Windows is
' installed
Public Const SM_SWAPBUTTON = 23 ' Non-zero if the left and right
' mouse buttons are swapped

Declare Function GetSystemMetrics& Lib "User32" (ByVal nIndex&)
 
Thanks for the info. I'm very new to this so I'm a bit confused but as I catch on quick I should be able to
figure something out.

thank you!
 
Youll have to use GetSystemMetrics to get the screen size... Then based on that position the form on the screen by setting its properties. I would guess that they are left and top but whatever they are, it should be pretty intuitive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top