Cooker
January 18th, 2006, 01:45 AM
Hi,
I create two trackbars for different purposes and use two different notification functions.
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
// Create two trackbars
hwndTrack1 = CreateWindowEx( ... );
hwndTrack2 = CreateWindowEx( ... );
..
break;
case WM_HSCROLL:
TBNotification1(wParam,hwndTrack1,0,100);
TBNotification2(wParam,hwndTrack2,1,5);
break;
}
...
}
Notification function such as :
void WINAPI TBNotification1(
WPARAM wParam, // wParam of WM_HSCROLL message
HWND hwndTrack, // handle of trackbar window
UINT iSelMin, // minimum value of trackbar selection
UINT iSelMax) // maximum value of trackbar selection
{
DWORD dwPos; // current position of slider
dwPos = SendMessage(hwndTrack, TBM_GETPOS, 0, 0);
switch (LOWORD(wParam)) {
case TB_ENDTRACK:
if (dwPos > iSelMax) {
SendMessage(hwndTrack, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)iSelMax);
}
else if (dwPos < iSelMin) {
SendMessage(hwndTrack, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)iSelMin);
}
break;
default:
break;
}
}
Is right the method ?
Thank you.
I create two trackbars for different purposes and use two different notification functions.
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
// Create two trackbars
hwndTrack1 = CreateWindowEx( ... );
hwndTrack2 = CreateWindowEx( ... );
..
break;
case WM_HSCROLL:
TBNotification1(wParam,hwndTrack1,0,100);
TBNotification2(wParam,hwndTrack2,1,5);
break;
}
...
}
Notification function such as :
void WINAPI TBNotification1(
WPARAM wParam, // wParam of WM_HSCROLL message
HWND hwndTrack, // handle of trackbar window
UINT iSelMin, // minimum value of trackbar selection
UINT iSelMax) // maximum value of trackbar selection
{
DWORD dwPos; // current position of slider
dwPos = SendMessage(hwndTrack, TBM_GETPOS, 0, 0);
switch (LOWORD(wParam)) {
case TB_ENDTRACK:
if (dwPos > iSelMax) {
SendMessage(hwndTrack, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)iSelMax);
}
else if (dwPos < iSelMin) {
SendMessage(hwndTrack, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)iSelMin);
}
break;
default:
break;
}
}
Is right the method ?
Thank you.