I would do a simple dialog with two slider control and two edit control.
When I move the cursor in the edit control I would show the actual position.
When I write a value in the Edit control I would automactly set the cursor
position.
I think the biggest problem is hook the right WM_NOTIFY from the sliders.
Someone can hel me,
Thanks
Willy
Why not use an UpDown? It has the possibility to update another
control kind of built in.
> I can't find a simple example for use a trackbar slider.
First you got to initiate with "InitCommonControls();", link
"comctl32.lib" and include "commctrl.h"
Then you set the range with the "TBM_SETRANGE" message.
> I would do a simple dialog with two slider control and two edit control.
> When I move the cursor in the edit control I would show the actual position.
I guess you mean "When I move the cursor in the slide it displays the
value in the edit box".
Intercept the slider message "WM_HSCROLL" or "WM_VSCROLL" (according
your slider orientation). There get the position of your slide with the
"TBM_GETPOS", convert it with "_itow_s" (or "_itoa_s") and then
"SetDlgItemText" of your Edit Box.
> When I write a value in the Edit control I would automactly set the cursor
> position.
The opposite so: Intercept the message "EN_CHANGE" of your edit box,
there convert the value with "_wtoi" (or "atoi") and use the
"TBM_SETPOS" message to change your slider position with this value.
Hope this help
Cathy
> I can't find a simple example for use a trackbar slider.
http://msdn.microsoft.com/en-us/library/cc656639(VS.85).aspx
+ N. CLUTS samples (slider.c, ...)
and as Cathy said for Trackbar thumb position
Thanks to all. :)
Willy
case WM_INITDIALOG:
SetSliderRange(GetDlgItem(hDlg, IDC_GAINSLIDER), gainmin, gainmax,
gain);
...
case WM_HSCROLL:
{
HWND hwndScrollBar = (HWND) lParam;
int iPos = (short int)HIWORD(wParam);
if (GetDlgItem(hDlg, IDC_GAINSLIDER)==hwndScrollBar ) {
iPos = (int)SendMessage(hwndScrollBar, TBM_GETPOS, 0, 0);
gain = iPos;
sprintf_s(edtext, EDLEN, "Gain:%d", gain);
SetDlgItemText(hDlg, IDC_GAIN, (LPCSTR)edtext);
if (LOWORD(wParam)==SB_THUMBPOSITION) { // thumb has been released
// Set the gain value now
Beep(500,200);
}
}
}
...
A helper function:
int SetSliderRange(HWND hwndTrack, int iMin, int iMax, int iPos) {
SendMessage(hwndTrack, TBM_SETRANGE,
(WPARAM) TRUE, // redraw flag
(LPARAM) MAKELONG(iMin, iMax)); // min. & max. positions
SendMessage(hwndTrack, TBM_SETSEL,
(WPARAM) FALSE, // redraw flag
(LPARAM) MAKELONG(iMin, iMax));
SendMessage(hwndTrack, TBM_SETPAGESIZE,
0, (LPARAM) (iMax-iMin)/10); // new page
size
SendMessage(hwndTrack, TBM_SETPOS,
(WPARAM) TRUE, // redraw flag
(LPARAM) iPos);
SetFocus(hwndTrack);
return 1;
}
On Dec 19, 2:29 am, "Willy" <gru...@willygroup.org> wrote:
> "Willy" <gru...@willygroup.org> ha scritto nel messaggionews:494a12a5$1...@extreme.x-privat.org...