| 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 AddOfficeBorder(Text1.hWnd) Code ' 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 lngRetVal = lngRetVal Or WS_EX_STATICEDGE And Not WS_EX_CLIENTEDGE 'Apply the changes SetWindowLong hWnd, GWL_EXSTYLE, lngRetVal SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or _ SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED End Function |
Getting the Office Look |
India web developer web development India | Freelance web development ecommerce web developer | Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design