Not a Member Yet,
Click here to Register

ID: 285
Viewed: 2756
Added: Jul 26, 2002
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Getting the Office Look

Fancy giving your application that Office 2000 feel?

Get with it by giving all your controls a groovy new Office 2000-like border style, all thanks to this neat copy-and-paste code snippet.

This code uses the API to alter the border of a control, giving it a very faint and rather cool-looking 3D border.

For best results, change the Appearance and BorderStyle properties of your control(s) to Flat and None, respectively.

To run this code, simply call the AddOfficeBorder method, passing it the hWnd property of your control.

Sample Usage


Highlight all by clicking in box

Highlight All
' Insert this code into a module

Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd 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

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CLIENTEDGE = &H200
Private Const WS_EX_STATICEDGE = &H20000

Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOOWNERZORDER = &H200
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4

Public Function AddOfficeBorder(ByVal hWnd As Long)

Dim lngRetVal As Long

'Retrieve the current border style
lngRetVal = GetWindowLong(hWnd, GWL_EXSTYLE)

'Calculate border style to use

'Apply the changes
SetWindowLong hWnd, GWL_EXSTYLE, lngRetVal
SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or _

End Function

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!