Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Centering a Window with a Taskbar Visual
[ All Languages » VB »  Api]

Total Hit ( 3098)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
Option Explicit
Private Const SPI_GETWORKAREA = 48
Private Declare Function SystemParametersInfo& Lib "User32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As _
Long, lpvParam As Any, ByVal fuWinIni As Long)

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Function CenterForm32(frm As Form)
Dim ScreenWidth&, ScreenHeight&, ScreenLeft&, ScreenTop&
Dim DeskTopArea As RECT
Call SystemParametersInfo(SPI_GETWORKAREA, 0, DeskTopArea, 0)
ScreenHeight = (DeskTopArea.Bottom - DeskTopArea.Top) * Screen.TwipsPerPixelY
ScreenWidth = (DeskTopArea.Right - DeskTopArea.Left) * Screen.TwipsPerPixelX
ScreenLeft = DeskTopArea.Left * Screen.TwipsPerPixelX
ScreenTop = DeskTopArea.Top * Screen.TwipsPerPixelY
frm.Move (ScreenWidth - frm.Width) \ 2 + ScreenLeft, (ScreenHeight - _
frm.Height) \ 2 + ScreenTop
End Function

'That's it! Now, to center a form, just use this call:

CenterForm32 Me


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.