How to receive SB_THUMBPOSITION
-
Hey all, I have a dialog that has a richedit control on it. I receive EN_VSCROLL messages through the WM_COMMAND message in the parent window. I can not figuer out how to catch the SB_THUMBPOSITION message. To catch the EN_VSCROLL messages I had to set the event mask SendMessage(hrichEdit, EM_SETEVENTMASK, 0, LPARAM(SendMessage(hwndDlg, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL )); Any ideas? Cheers, Luke
-
Hey all, I have a dialog that has a richedit control on it. I receive EN_VSCROLL messages through the WM_COMMAND message in the parent window. I can not figuer out how to catch the SB_THUMBPOSITION message. To catch the EN_VSCROLL messages I had to set the event mask SendMessage(hrichEdit, EM_SETEVENTMASK, 0, LPARAM(SendMessage(hwndDlg, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL )); Any ideas? Cheers, Luke
Luke Murray wrote:
SendMessage(hrichEdit, EM_SETEVENTMASK, 0, LPARAM(SendMessage(hwndDlg, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL ));
is hwndDlg intentional instead of hrichEdit?
-prakash
-
Luke Murray wrote:
SendMessage(hrichEdit, EM_SETEVENTMASK, 0, LPARAM(SendMessage(hwndDlg, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL ));
is hwndDlg intentional instead of hrichEdit?
-prakash
Sorry that is meant to be hrichEdit, like SendMessage(hrichEdit, EM_SETEVENTMASK, NULL, LPARAM(SendMessage(hrichEdit, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL )); From what I have read. if you have a winproc for a window you can catch WM_VSCROLL and LOWORD(lParam) will be SB_THUMBPOSITION. the issue I have it when its a scroll message from a child window (like in this case) first you catch WM_COMMAND then EN_VSCROLL through HIWORD(wParam) and lParam in this case is the handle to the richedit control. So i'm not sure how to get the message for SB_THUMBPOSITION from the child window. I guess I have to have a winproc for the richedit control and handle it through the WM_VSCROLL etc? Then i'm not too sure on how to do that. The dialog is loaded from a resource file as well. Cheers, Luke
-
Sorry that is meant to be hrichEdit, like SendMessage(hrichEdit, EM_SETEVENTMASK, NULL, LPARAM(SendMessage(hrichEdit, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL )); From what I have read. if you have a winproc for a window you can catch WM_VSCROLL and LOWORD(lParam) will be SB_THUMBPOSITION. the issue I have it when its a scroll message from a child window (like in this case) first you catch WM_COMMAND then EN_VSCROLL through HIWORD(wParam) and lParam in this case is the handle to the richedit control. So i'm not sure how to get the message for SB_THUMBPOSITION from the child window. I guess I have to have a winproc for the richedit control and handle it through the WM_VSCROLL etc? Then i'm not too sure on how to do that. The dialog is loaded from a resource file as well. Cheers, Luke
humm, you might want to do subclassing.
-prakash
-
humm, you might want to do subclassing.
-prakash
Yeah, that was something I hoped to avoid. I really would have thought there would be a way.
-
Hey all, I have a dialog that has a richedit control on it. I receive EN_VSCROLL messages through the WM_COMMAND message in the parent window. I can not figuer out how to catch the SB_THUMBPOSITION message. To catch the EN_VSCROLL messages I had to set the event mask SendMessage(hrichEdit, EM_SETEVENTMASK, 0, LPARAM(SendMessage(hwndDlg, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL )); Any ideas? Cheers, Luke
-
You have to catch WM_HSCROLL or WM_VSCROLL messages and in the WPARAM argument you can find SB_THUMBPOSITION or some other code depending on what the user is doing with the scroll bar.
The problem is WM_VSCROLL etc get sent to the richedit control, not my dialog. the winproc in my dialog I have to catch WM_COMMAND and in that wparam is EN_VSCROLL, and the lparam is the richedit handle, so I lose the SB_THUMBPOSITION and SB_BOTTOM etc. If i subclassed the richedit and had a winproc for that i could get the WM_VSCROLL messages. but I did not want to sub class the richedit. Thanks anyway Luke
-
Hey all, I have a dialog that has a richedit control on it. I receive EN_VSCROLL messages through the WM_COMMAND message in the parent window. I can not figuer out how to catch the SB_THUMBPOSITION message. To catch the EN_VSCROLL messages I had to set the event mask SendMessage(hrichEdit, EM_SETEVENTMASK, 0, LPARAM(SendMessage(hwndDlg, EM_GETEVENTMASK, 0, 0) | ENM_SCROLL )); Any ideas? Cheers, Luke
Well, I got it. If you add ENM_SCROLLEVENTS to the event mask, you will get the messages through WM_NOTIFY. Then the lParam is a pointer to a MSGFILTER stucture, which gives us the message code of original message, in this case WM_VSCROLL, and LOWORD(msgFilter->wparam) is the SB_* N ow this is great. Only problem now is the mouse wheel does not fire this event, but it did fire the EN_VSCROLL through WM_COMMAND. annoying. Thanks all
-
Well, I got it. If you add ENM_SCROLLEVENTS to the event mask, you will get the messages through WM_NOTIFY. Then the lParam is a pointer to a MSGFILTER stucture, which gives us the message code of original message, in this case WM_VSCROLL, and LOWORD(msgFilter->wparam) is the SB_* N ow this is great. Only problem now is the mouse wheel does not fire this event, but it did fire the EN_VSCROLL through WM_COMMAND. annoying. Thanks all
My bad, the wheel does fire the WM_VSCROLL through WM_NOTIFY. it did ever trigger the SB_ENDSCROLL which I was also testing for.