Solved

Q about CButton: BN_CLICK + BN_DISBALE

Posted on 1998-11-28
12
425 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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