开发者

Win32 listbox not updating immideately after LB_ADDSTRING message

OS: Win7

list box is not updating its region after

SendMessage(hwndListData, LB_ADDSTRING, 0, (LPARAM) szListMainBuffer);

If mouse cursor is hovered over blank line that should contain text from szListMainBuffer, and clicked, 开发者_StackOverflowtext appears. I have tried using UpdateWindow(), InvalidateRect() functions targeted at hwndListData and parent window, for no effect.

Does someone knows how to solve refreshing of listbox after string insertion?

        hwndListData = CreateWindow(TEXT("listbox"), L"Data List", 
                                            WS_CHILDWINDOW | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | WS_HSCROLL | WS_BORDER, 
                                            cxChar * 50, cyChar, 
                                            cxChar * 38 + GetSystemMetrics(SM_CXVSCROLL), cyChar * 26 + GetSystemMetrics(SM_CYHSCROLL), 
                                            hwnd, (HMENU) ID_LISTDATA, 
                                            (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
                                            NULL);

Addition:

Global scope: WNDPROC oldListDataProcedure;

During WM_CREATE: oldListDataProcedure = (WNDPROC) SetWindowLong (hwndListData, GWL_WNDPROC, (LPARAM) ListDataProc); 

LRESULT CALLBACK ListDataProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
   return CallWindowProc(oldListDataProcedure, hwnd, message, wParam, lParam); 
}


It should update by itself. The fact the UpdateWindow and InvalidateRect didn't work either tells me the error might be lying elsewhere in your code. If it is small, feel free to post it. Is the listbox on top of any other control? What happens when your resize the window?


To fix it, go to the Listbox Control properties and change NoRedraw from true to false.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜