-
April 12th, 2010, 04:22 AM
#1
progress bar mouse events
Is there a way to change the position of progress bar with mouse events in mfc?
-
April 12th, 2010, 04:55 AM
#2
Re: progress bar mouse events
Just use CProgressCtrl methods to advance the progress bar position (like CProgressCtrl::SetPos and so on).
Of course, you can call them from any mouse message handler.
Victor Nijegorodov
-
April 12th, 2010, 05:03 AM
#3
Re: progress bar mouse events
I want to set position with the mouse, at mouse events, the event argument is a point, is there any way to match it to the position of progress bar. I need something lbutton_down event of progress control with the event argument as position, not point.
-
April 12th, 2010, 05:24 AM
#4
Re: progress bar mouse events
Have you considered using a CSliderCtrl ? This is made exactly for what you are trying to do.
-
April 12th, 2010, 06:03 AM
#5
Re: progress bar mouse events
yes, I know about slider. as functionality it gives what I want but as view it does not. It does not fill the rect progressively. What I am trying to do is just in between slider and progress controlls. functionality like slider, view as progress bar.
-
April 12th, 2010, 03:55 PM
#6
Re: progress bar mouse events
I need something lbutton_down event of progress control with the event argument as position, not point.
If you know the point, you can calculate the position.
example:
The scrollbar has a window clientarea-width of 300.
You scrollbar goes from 1 to 100.
300 / 100 = 3. So 3 pixels is 1 position in the scrollbar.
The mouse point inside the scrollbar window is (12, 3). Ignore the 3, the 12 is the x.
So the scrollbar position is 12 / (300 / 100) = 4.
Last edited by Skizmo; April 12th, 2010 at 03:57 PM.
-
April 17th, 2010, 11:59 AM
#7
Re: progress bar mouse events
I think there are two possible solutions;
1- instead of dragging and dropping a progress bar to the dialog, a custom cprogressctrl class can be added. cprogressctrl class is derived from cwind and it has all the mouse events.
- add mfc class to the solution
- choose cprogressctrl as base class
- add mouse message handlers
- get point and get range x value (if progressbar is horizontal) and calculate the position in propotion to the width of the progress bar
-set position of the progress bar and do anything else
2-drag and drop a progress bar control to the dialog from resouce tool
-add mouse message handlers of the dialog
-determine if the point is inside the bounding rect of the progressbar
-if it is, get point and get range x value (if progressbar is horizontal) and calculate the position in propotion to the width of the progress bar
-set position of the progress bar and do anything else
with the mouse messages a progress bar can well be used both as a progress bar and a slider like progressing media tracker
-
April 17th, 2010, 01:23 PM
#8
Re: progress bar mouse events
In fact solution 1 will work fine even with dropping a progress bar. You just need to bind a variable to your custom class rather than CProgressCtrl.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|