Solved

Q about CButton: BN_CLICK + BN_DISBALE

Posted on 1998-11-28
12
419 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now