dwb11
June 12th, 2009, 10:01 AM
Hello,
I am having a problem getting my program to execute any code under my WM_VSCROLL case statement. I posted some code that sends a message that I think WM_VSCROLL should pickup, but is not. When I run my code I can see the third listbox scrolling down every time I change the selection in the first listbox, but I don't get a messagebox. What I am trying to do is have when a user scrolls through one of the listboxes I want the other two to scroll with it accordingly so it appears as one to the user. WM_VSCROLL is the message I want to listen to when a user interacts with a scrollbar, correct? Thank you for your time.
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static HWND hwndTrack1,hwndTrack2,hwndTrack3;
switch(msg)
{
case WM_CREATE:
{
hwndTrack1=CreateWindow(TEXT("listbox"),NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY ,
180, 10, 110, 200, hwnd, (HMENU) IDM_TRACK1, g_hinst, NULL);
hwndTrack2=CreateWindow(TEXT("listbox"),NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY ,
290, 10, 110, 200, hwnd, (HMENU) IDM_TRACK2, g_hinst, NULL);
hwndTrack3=CreateWindow(TEXT("listbox"),NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY|WS_VSCROLL ,
400, 10, 110, 200, hwnd, (HMENU) IDM_TRACK3, g_hinst, NULL);
for(int i=0;i<20;i++)
{
SendMessage(hwndTrack1,LB_ADDSTRING,0,(LPARAM) TEXT("JUNK"));
SendMessage(hwndTrack2,LB_ADDSTRING,0,(LPARAM) TEXT("JUNK"));
SendMessage(hwndTrack3,LB_ADDSTRING,0,(LPARAM) TEXT("JUNK"));
}
break;
}
case WM_COMMAND:
{
if(HIWORD(wParam)==CBN_SELCHANGE)
{
if(LOWORD(wParam)==IDM_TRACK1)
{
SendMessage(hwndTrack3,WM_VSCROLL,SB_LINEDOWN,0);
}
}
break;
}
case WM_VSCROLL:
{
MessageBox(NULL,TEXT("CLICKED"),TEXT("CLICKED"),MB_OK);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
I am having a problem getting my program to execute any code under my WM_VSCROLL case statement. I posted some code that sends a message that I think WM_VSCROLL should pickup, but is not. When I run my code I can see the third listbox scrolling down every time I change the selection in the first listbox, but I don't get a messagebox. What I am trying to do is have when a user scrolls through one of the listboxes I want the other two to scroll with it accordingly so it appears as one to the user. WM_VSCROLL is the message I want to listen to when a user interacts with a scrollbar, correct? Thank you for your time.
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static HWND hwndTrack1,hwndTrack2,hwndTrack3;
switch(msg)
{
case WM_CREATE:
{
hwndTrack1=CreateWindow(TEXT("listbox"),NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY ,
180, 10, 110, 200, hwnd, (HMENU) IDM_TRACK1, g_hinst, NULL);
hwndTrack2=CreateWindow(TEXT("listbox"),NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY ,
290, 10, 110, 200, hwnd, (HMENU) IDM_TRACK2, g_hinst, NULL);
hwndTrack3=CreateWindow(TEXT("listbox"),NULL,
WS_CHILD | WS_VISIBLE | LBS_NOTIFY|WS_VSCROLL ,
400, 10, 110, 200, hwnd, (HMENU) IDM_TRACK3, g_hinst, NULL);
for(int i=0;i<20;i++)
{
SendMessage(hwndTrack1,LB_ADDSTRING,0,(LPARAM) TEXT("JUNK"));
SendMessage(hwndTrack2,LB_ADDSTRING,0,(LPARAM) TEXT("JUNK"));
SendMessage(hwndTrack3,LB_ADDSTRING,0,(LPARAM) TEXT("JUNK"));
}
break;
}
case WM_COMMAND:
{
if(HIWORD(wParam)==CBN_SELCHANGE)
{
if(LOWORD(wParam)==IDM_TRACK1)
{
SendMessage(hwndTrack3,WM_VSCROLL,SB_LINEDOWN,0);
}
}
break;
}
case WM_VSCROLL:
{
MessageBox(NULL,TEXT("CLICKED"),TEXT("CLICKED"),MB_OK);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}