OWNERDRAW Listbox help
-
I have an application that subclasses an LBS_OWNERDRAWFIXED listbox window. When I subclass the window it seems to break the listbox so that horizontal scrolling and painting do not work correctly (perhaps other things as well that I have not gotten to yet. Assuming that it was a problem with my subclass procedure I reduced it to the following code: //* The listbox definition in the dialog resource LISTBOX ID_USERS_LISTBOX, 3, 22, 324, 185, LBS_OWNERDRAWFIXED | LBS_MULTICOLUMN | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP //* Subclass the listbox earlier in the code.... fpOldListProc = (FARPROC) SetWindowLong(hWndList, GWL_WNDPROC, (DWORD)ListProc); //* Listbox subclass procedure LRESULT APIENTRY ListProc( HWND hWnd, UINT Message, WORD wParam, LONG lParam) { return CallWindowProc((WNDPROC)fpOldListProc, hWnd, Message, wParam, lParam); } with the same result. It is worse in Win2000 than in Win/98 but basically the same kinds of problems are there. In Win2000 the items the space below the bottom row in the listbox and below and to the right of the last row of items is not repainted as well as horizontal scrolling not working correctly. I've tinkered with this for a week and I'm at a loss. Any suggestions or pointers would be greatly appreciated. Thanks Neil Neil Lamka neil@meetingworks.com
-
I have an application that subclasses an LBS_OWNERDRAWFIXED listbox window. When I subclass the window it seems to break the listbox so that horizontal scrolling and painting do not work correctly (perhaps other things as well that I have not gotten to yet. Assuming that it was a problem with my subclass procedure I reduced it to the following code: //* The listbox definition in the dialog resource LISTBOX ID_USERS_LISTBOX, 3, 22, 324, 185, LBS_OWNERDRAWFIXED | LBS_MULTICOLUMN | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP //* Subclass the listbox earlier in the code.... fpOldListProc = (FARPROC) SetWindowLong(hWndList, GWL_WNDPROC, (DWORD)ListProc); //* Listbox subclass procedure LRESULT APIENTRY ListProc( HWND hWnd, UINT Message, WORD wParam, LONG lParam) { return CallWindowProc((WNDPROC)fpOldListProc, hWnd, Message, wParam, lParam); } with the same result. It is worse in Win2000 than in Win/98 but basically the same kinds of problems are there. In Win2000 the items the space below the bottom row in the listbox and below and to the right of the last row of items is not repainted as well as horizontal scrolling not working correctly. I've tinkered with this for a week and I'm at a loss. Any suggestions or pointers would be greatly appreciated. Thanks Neil Neil Lamka neil@meetingworks.com
http://support.microsoft.com/support/kb/articles/Q197/6/90.ASP http://msdn.microsoft.com/library/techart/msdn\_mfcclip.htm Also try to do the following: 1. send WM_SETREDRAW and turn off the drawing of the listbox before subclassing 2. Do subcalssing 3. send WM_SETREDRAW to turn drawing back on 4. in your ListProc add the following: if (Message == WM_NCDESTROY) { //return old window proc... SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)fpOldListProc); } Mh2
-
http://support.microsoft.com/support/kb/articles/Q197/6/90.ASP http://msdn.microsoft.com/library/techart/msdn\_mfcclip.htm Also try to do the following: 1. send WM_SETREDRAW and turn off the drawing of the listbox before subclassing 2. Do subcalssing 3. send WM_SETREDRAW to turn drawing back on 4. in your ListProc add the following: if (Message == WM_NCDESTROY) { //return old window proc... SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)fpOldListProc); } Mh2
I finally had a chance to try your suggestion and it did not seem to help. Any other places you would suggest I look or things I should try? The strange thing (to me at least) is that reducing the subclass procedure to simply return the default procedure reply (as my example shows) results in the same problem. Thanks Neil Neil Lamka neil@meetingworks.com