|
-
Sep 27th, 2002, 10:49 PM
#1
Thread Starter
New Member
Command Button - Flat Appearence ??? HELP
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
-
Sep 29th, 2002, 05:05 PM
#2
Hyperactive Member
mm, its works for me.
hey, just make sure that you add the button.refresh after.
Code:
cmd.appearance = 1
cmd.refresh
or
Code:
cmd.appearance = 0
cmd.refresh
Does that make any difference?
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Sep 29th, 2002, 06:29 PM
#3
PowerPoster
Well
A regulat command button in VB? Wak : You can do this?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Sep 29th, 2002, 06:48 PM
#4
Hyperactive Member
mm, well if I go
Code:
cmd.appearance = 1
cmd.refresh
msgbox cmd.appearance
cmd.appearance = 1
cmd.refresh
msgbox cmd.appearance
I get 2 message boxes, one says '1' and the other says '2'.
Yeh, I used a 'regulat' button ... BUT I didn't see any aesthetic changes hey...
mmm
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Sep 30th, 2002, 09:07 AM
#5
Software Eng.
I think you might be able to do this with SetWindowLong (but I haven't tested it).
-
Sep 30th, 2002, 09:11 AM
#6
Try this...
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|