|
|
|
Visual Basic doesn't let you change the Style property of a CheckBox or an OptionButton control at runtime. However, you can easily do it by manipulating the control's style bit, with the SetWindowLong API function. Here's a routine that does the trick:
Using the routine is straightforward. For example, this code changes the style of all the OptionButton controls in the Option1 array |
Click here to copy the following block | 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 newValue As Long) As Long
Const GWL_STYLE = (-16) Const BS_PUSHLIKE = &H1000&
Sub SetButtonStyle(Ctrl As Control, ByVal Graphical As Boolean) If Graphical Then SetWindowLong Ctrl.hWnd, GWL_STYLE, GetWindowLong(Ctrl.hWnd, _ GWL_STYLE) Or BS_PUSHLIKE Else SetWindowLong Ctrl.hWnd, GWL_STYLE, GetWindowLong(Ctrl.hWnd, _ GWL_STYLE) And Not BS_PUSHLIKE End If Ctrl.Refresh End Sub |
|
|
|
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 ) |
|
|