CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2000
    Posts
    28

    setting state of a button

    How do I make a NORMAL button (not toolbar button) look like it is pushed down? Is there some API function for this?

    thanx,

    ds


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: setting state of a button

    A normal command Button can't be kept pushed down.
    However you might want to look at the Option button and the Check Box controls. These controls, when you set their style property to Graphical, perform much like you want.
    Just drop one of each on a test form, Set their style to Graphical, run the program to see what I mean.

    John G

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: setting state of a button

    You can set the button down thus:


    'Declarations
    public Enum ButtonMessages
    BM_GETCHECK = &HF0
    BM_SETCHECK = &HF1
    BM_GETSTATE = &HF2
    BM_SETSTATE = &HF3
    BM_SETSTYLE = &HF4
    BM_CLICK = &HF5
    BM_GETIMAGE = &HF6
    BM_SETIMAGE = &HF7
    End Enum

    public Enum ButtonStates
    BST_UNCHECKED = &H0
    BST_CHECKED = &H1
    BST_INDETERMINATE = &H2
    BST_PUSHED = &H4
    BST_FOCUS = &H8
    End Enum

    private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, byval lParam as Long) as Long

    'Use
    Call SendMessageLong(Command1.hwnd, BM_SETSTATE, BS_PUSHED,0)




    Hope this helps,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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

Featured