views:

31

answers:

1

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, text 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); 
}
+1  A: 

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?

Alexander Rafferty
It 280 lines.. so no posting :) Nothing below it, just parent client area. Text do appear when i resize it.
Martin Berger
Hmm... Have done anything special with the control (like subclassing)?
Alexander Rafferty
Yes. WNDPROC oldListDataProcedure; Bust as you see, there is still nothing there.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);}
Martin Berger
Solved it. I made a mistake. I was using UpdateWindow with wrong window handle. Instead hwndListData i used something else. It works even with parent window handle. Well, Alexander, thanks for trying to help, see you another time.
Martin Berger