Hi,
Is it possible to change the appearance (3D to Flat and vice versa) of command buttons at run time. I can change it during design time. Please Help.
Thank You
Printable View
Hi,
Is it possible to change the appearance (3D to Flat and vice versa) of command buttons at run time. I can change it during design time. Please Help.
Thank You
hey, just make sure that you add the button.refresh after.
orCode:cmd.appearance = 1
cmd.refresh
Does that make any difference?Code:cmd.appearance = 0
cmd.refresh
A regulat command button in VB? Wak : You can do this? :confused:
mm, well if I go
I get 2 message boxes, one says '1' and the other says '2'.Code:cmd.appearance = 1
cmd.refresh
msgbox cmd.appearance
cmd.appearance = 1
cmd.refresh
msgbox cmd.appearance
Yeh, I used a 'regulat' button ;) ... BUT I didn't see any aesthetic changes hey...
mmm
I think you might be able to do this with SetWindowLong (but I haven't tested it).
VB Code:
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 ' Frame Changed Private Const SWP_NOMOVE = &H2 Private Const SWP_NOOWNERZORDER = &H200 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOZORDER = &H4 Private Function ThinBorder(ByVal lhWnd As Long, ByVal bState As Boolean) Dim rtnVal As Long ' Get current border style rtnVal = GetWindowLong(lhWnd, GWL_EXSTYLE) ' Set new border style according to bState If Not (bState) Then ' make the button look normal rtnVal = rtnVal Or WS_EX_CLIENTEDGE And Not WS_EX_STATICEDGE Else ' make it flat rtnVal = rtnVal Or WS_EX_STATICEDGE And Not WS_EX_CLIENTEDGE End If ' Apply the change SetWindowLong lhWnd, GWL_EXSTYLE, rtnVal SetWindowPos lhWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or _ SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED End Function Private Sub Form_Load() ThinBorder Command1.hwnd, True End Sub