Results 1 to 6 of 6

Thread: Command Button - Flat Appearence ??? HELP

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    2

    Unhappy 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

  2. #2
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    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

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    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....

  4. #4
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298
    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

  5. #5
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    I think you might be able to do this with SetWindowLong (but I haven't tested it).

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Try this...

    VB Code:
    1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    2. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    3. 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
    4.  
    5. Private Const GWL_EXSTYLE = (-20)
    6. Private Const WS_EX_CLIENTEDGE = &H200
    7. Private Const WS_EX_STATICEDGE = &H20000
    8.  
    9. Private Const SWP_FRAMECHANGED = &H20 ' Frame Changed
    10. Private Const SWP_NOMOVE = &H2
    11. Private Const SWP_NOOWNERZORDER = &H200
    12. Private Const SWP_NOSIZE = &H1
    13. Private Const SWP_NOZORDER = &H4
    14.  
    15.  
    16. Private Function ThinBorder(ByVal lhWnd As Long, ByVal bState As Boolean)    
    17.     Dim rtnVal As Long
    18.    
    19.     ' Get current border style
    20.     rtnVal = GetWindowLong(lhWnd, GWL_EXSTYLE)
    21.    
    22.     ' Set new border style according to bState
    23.     If Not (bState) Then
    24.         ' make the button look normal
    25.         rtnVal = rtnVal Or WS_EX_CLIENTEDGE And Not WS_EX_STATICEDGE
    26.     Else
    27.         ' make it flat
    28.         rtnVal = rtnVal Or WS_EX_STATICEDGE And Not WS_EX_CLIENTEDGE
    29.     End If
    30.    
    31.     ' Apply the change
    32.     SetWindowLong lhWnd, GWL_EXSTYLE, rtnVal
    33.     SetWindowPos lhWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or _
    34.                  SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED    
    35. End Function
    36.  
    37. Private Sub Form_Load()
    38. ThinBorder Command1.hwnd, True
    39. 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
  •  



Click Here to Expand Forum to Full Width