Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Horizontal slider control: Can't get message working.

Author
Message
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 10th Dec 2010 00:49 Edited at: 10th Dec 2010 02:37
I have this piece of code here:

The checkbox works and I can get buttons working but I have looked everywhere for how to get the position of the slider. I'm using VC++ 2008 Express and ResEdit. If there is anything out there on how to program this stuff I've not found it yet.

Can anyone help?

EDIT: I've found putting under WM_NOTIFY I actually get the message but I still cannot retrieve the position of the slider...

Warning! May contain Nuts!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 10th Dec 2010 18:17 Edited at: 10th Dec 2010 18:45
That's a Windows API question, not Dark GDK issue, so you may have more chance of a good answer in the "programming talk" part of the forum.

I could help you with programming scrollbar position but, judging from the message constant, you are using a trackbar, not a scrollbar. I don't know the difference but I can tell you this: with a scrollbar, first I had to set the scrollbar limits (min, max, value for dragging and for page movement) in the WM_INITDIALOG part. Then I had to handle either the WM_HSCROLL or the WM_VSCROLL message (depending whether it's horizontal or vertical scrollbar). Within that message, there are several sub-messages to indicate how the scrollbar moves and I actually have to SET the new position of the slider (instead of only reading it), otherwise it jumps back to the beginning of the range after dragging, it does not move by itself. Does your slider stay in the new position when you drag it? (Mine didn't until I set up all that code.)

If you want I can post you my scrollbar code, but as I said, I don't know the difference between the two controls. I'm not a Windows API expert, maybe someone else with more knowledge about track bars can chime in.
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 10th Dec 2010 20:03
Hi and thanks Mireben, still after searching and searching through tons of forums on google I'm still having difficulty.

As you know I am using Resedit and just using a slider from there. I'm setting up the dialog as a modeless dialog so the GDK window can still run.

The slider will stay in the position its dragged to. I've seen and printed out tons of stuff on sliders and how to setup and read values but I can't at the moment get the sliders handle from the dialog.

I'm still going to go through forums and msdn to see if anything helps out. Once I have this up and running I'm hoping to add somewhere in these forums the complete code so as to help other users of GDK.

Warning! May contain Nuts!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Dec 2010 11:47 Edited at: 11th Dec 2010 12:02
Solved! Attached is a working project for you which creates a modeless dialog and displays the current position of the slider on a text label. I configured the slider to move between 0-10 but if you don't use the initial configuration part, it works also with the default 0-100 range.

It seems the two controls (scrollbar and track bar) are not so different after all. You need to process the WM_HSCROLL message, not WM_NOTIFY.

To get the handle, you can use GetDlgItem, store the handle and use it in SendMessage, but there is also SendDlgItemMessage for which is shorter if you don't need the handle several times. You can see examples for both methods in the attached project.

There is not so much info out there on trackbars but the "using trackbars" page on MSDN is useful.

http://msdn.microsoft.com/en-us/library/bb760151%28v=VS.85%29.aspx

EDIT: I noticed that I ended the scroll handler branch with "break" instead of "return TRUE" which would probably be the proper ending, but I won't edit the zip file only for that.

Attachments

Login to view attachments
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Dec 2010 14:41
Mireben you are a lifesaver. I've now got it working perfect. The entire code I've uploaded as a project (also for any others to have a look at). Not quite complete yet but will get there...

I was wondering how to setup the slider controls before the dialog was initialised but its all there. Thanks again...

Warning! May contain Nuts!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-19 16:33:39
Your offset time is: 2024-11-19 16:33:39