
Click 1 button = click 2 button?
Quote:
> I have a modal dialog box has 2 buttons(or more).
> WHen I click on one button, another button look like being clicked
at
> the same time.
> My concept is : when i click on the button, the framework notifies
> this and sends the message to dialog box. Then the dialog box
> sends the message to the "clicked" button. The clicked button
receives
> the message and draws itself "lower" to show that it is clicked.
> Thus, I guess override CMyDialog::OnCommand(wparam, lparam) can
help.
> Just ask the dialog box to send "click" message to two buttons at
the
> same time.
> Am i right?
No, you are wrong. It works the other way round. When you click on a
button, the button receives WM_LBUTTONDOWN and captures the mouse.
Then it is painted in 'down' state when mouse is over it and in 'up'
state otherwise. The transition is done in WM_MOUSEMOVE hander STILL
in the button window proc. And only when you release mouse over the
button and thus send WM_LBUTTONUP to it, the button registers a click
and sends WM_COMMAND to your dialog (before that it repaints itself in
'up' state).
What you want to do is quite complicated. My first idea was to
subclass both buttons and whenever one of them receives any mouse
message (and keyboard message, since you can press a button with a
space key) it sends it to the other. But that will confuse the mouse
capture.
Another idea: create one big button and make it owner-drawn, so that
it will paint itself as if there are two buttons with an empty space
between them. DrawFrameControl function will be of great help here.
You'll also need to capture either WM_LBUTTONDOWN / WM_LBUTTONUP or
WM_NCHITTEST to prevent this big button from getting pressed when
clicked between two "pseudobuttons".
With best wishes,
Igor Tandetnik