Click to See Complete Forum and Search --> : setting state of a button


dsdsds
August 7th, 2001, 09:02 AM
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

John G Duffy
August 7th, 2001, 09:48 AM
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

Clearcode
August 7th, 2001, 10:24 AM
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.