?
Solved

Q about CButton: BN_CLICK + BN_DISBALE

Posted on 1998-11-28
12
Medium Priority
?
427 Views
Last Modified: 2013-11-20
Hi guys,

I want to do different actions while a button is clicked, held and when it's released.
If anyone could give me a piece of code for that I would appreciate it.

Following to do:
When the button is clicked, function "start" is called and camera starts moving.
While it is clicked, nothing happens (= camera is still moving).
When button is released, function "stop" is called and camera stops.

How can I realize this ?
I played with GetState() but this seems to be the wrong way...?

Regards
Heike

P.S.:
Please tell me if the points aren't enough.
(unfortunately, this is the profile of my friend and he has just 65 left)
0
Comment
Question by:mitrakis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 2
  • 2
12 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1325416
OK, override the WM_KEYDOWN and WM_KEYUP.  

In your OnKeyDown, move the camera, set a flag, and start a timer.
In your timer function, move the camera... (or do nothing).

In your OnKeyUp, turn off your camera, (and turn off your timer if you used one).

Phillip
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325417
I do not have OnKeyUp nor OnKeyDown ?...I use CButton.

CButton just gives me "MyClass::OnMyButton".
I have to get the button status myself I think !
(but how can I determine when user releases the mouse button ?)
In message map I have ON_BN_CLICKED and ON_BN_DISABLE available for the button I want to do this.
My Problem now:
I have just ::OnMyButton, but have to check two button states (clicked and released)...have no idea how to find out *when* user releases button !
Some lines of code could be very helpful...

If you need more details please let me know.

Thank you very much
Heike
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325418
Hm...maybe I understood right now what you meant by "override on_Keydown"...but I don't know what to do with this info regarding my buttons (not keyboard keys) =;-(

Heike
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Author Comment

by:mitrakis
ID: 1325419
Aehh...in case it wasn't clear:
I offer a dialog.
Therein there are lots of buttons.
One of these buttons should behave as described above.

Thanks (and sorry)
Heike
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1325420
You will need to subclass CButton (i.e. derive a class from CButton) and use the new class instead of CButton for that particular button. Then in the new class, override WM_LBUTTONDOWN and WM_LBUTTONUP. In the OnLButtonDown() you will need to start a timer and call SetCapture(). OnTimer() will need to move the camera. OnLButtonUp() will call ReleaseCapture() and kill the timer.
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325421
thui,

sounds very good !
Unfortunately I cannot imagine how to generate code for this...maybe you can post some here ?
How about a few lines of the interaction between WM_LBUTTONUP and SetCapture ?

Spent my last points and hope I'll get help on that :)

Heike
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325422
I would like to credit psdavis :-)

After my friend came back he told me that it would be the easiest to use statics (instead of buttons) and lay bitmaps over these statics.
This way I can use WM_KEYDOWN, WM_KEYUP without overriding any CButton methods.
So psdavis' suggestion showed us the right/easiest way.

Thank you all
Heike
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325423
Oopss !
My fault...I meant LButtonUp and LButtonDown...and this was suggested by thui.
So sorry thui...please post an answer again, and you'll get credits...definitely.

Uhh, shame on me =;-))

Heike
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325424
thui,

please post an answer !

-Stavi-
0
 
LVL 3

Author Comment

by:mitrakis
ID: 1325425
ok...don't want to leave this Q unlocked till next year =;-)

psdavis:
Since thui didn't answer just post your answer again to get credits...

Regards
-Stavi-
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 210 total points
ID: 1325426
Glad you got things working.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1325427
Glad you saw your point thui!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question