Window doesn't always update

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
		case WM_CREATE:
		{
			TCHAR Path_BG     [MAX_PATH];	// Background image buffer
			TCHAR Path_Siel   [MAX_PATH];	// Siel   banner
			TCHAR Path_Lumiel [MAX_PATH];	// Lumiel banner

			GetModuleFileName(NULL, Path_BG,     MAX_PATH);
			GetModuleFileName(NULL, Path_Siel,   MAX_PATH);
			GetModuleFileName(NULL, Path_Lumiel, MAX_PATH);

			PathRemoveFileSpec(Path_BG);
			PathRemoveFileSpec(Path_Siel);
			PathRemoveFileSpec(Path_Lumiel);

			_tcscat(Path_BG,     TEXT("\\bg.jpg"));
			_tcscat(Path_Siel,   TEXT("\\Siel.jpg"));
			_tcscat(Path_Lumiel, TEXT("\\Lumiel.jpg"));

			HWND hwnd_bg     = CreateWindowEx(0, WC_IMAGEBOX, TEXT(""), WS_CHILD | WS_VISIBLE, 0, 0,  500, 263, hwnd, NULL, (HMODULE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL);
			HWND hwnd_Siel   = CreateWindowEx(0, WC_IMAGEBOX, TEXT(""), WS_CHILD | WS_VISIBLE, 5, 50,  40,  40, hwnd, NULL, (HMODULE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL);
			HWND hwnd_Lumiel = CreateWindowEx(0, WC_IMAGEBOX, TEXT(""), WS_CHILD | WS_VISIBLE, 5, 95,  40,  40, hwnd, NULL, (HMODULE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL);

			ImageBox_SetImage(hwnd_Siel  ,Path_Siel);
			ImageBox_SetImage(hwnd_Lumiel, Path_Lumiel);
			ImageBox_SetImage(hwnd_bg    , Path_BG);

			SendMessage(NULL,WM_PAINT,0,0);
		
			return 0;
		}

The window doesn't show the two images unless i hide it and restore it, i tried sending it a WM_PAINT msg, but it doesn't seem to fix it, any ideas?:)
In place of this line:

SendMessage(NULL,WM_PAINT,0,0);

Try:

InvalidateRect (hwnd, NULL, TRUE);

I haven't tried it, but it might work.

Also don't use return 0;, use break; Because we don't want to return from that function, we want to get out of the switch statement, so we can use return DefWindowProc (hwnd, msg, wParam, lParam);
Thank you, you're right about the break; instead of the return 0;
It still doesn't function properly tho
Hmm, sorry but I don't know how to solve this one. Maybe someone else does...
I could suggest a workaround you could try ... Are you interested?
Of course :) that's what i'm here for
Well I found that if you click on the listview it would paint - so I tried this (on the hwnd_bg listview)
1
2
3
4
5
6
7
8
9
10
11
12
......
ImageBox_SetImage(hwnd_Siel  ,Path_Siel);
ImageBox_SetImage(hwnd_Lumiel, Path_Lumiel);
ImageBox_SetImage(hwnd_bg, Path_BG);

PostMessageA(hwnd_bg,WM_LBUTTONDOWN  , 0, 0); //fake a mouse left button messge
Sleep(20);//Sleep a very short while 
PostMessageA(hwnd_bg,WM_LBUTTONUP  , 0, 0);   //fake the mouse button back up     

//SendMessage(NULL,WM_PAINT,0,0);
.....


It seemed to work for me.
The Sleep can be as low as 5 but it is necessary.

I could only guess what the ImageBox_SetImage function looked like - but as you said
list view would show but you couldn't see the background picture immediately.

Last edited on
I gotta tell ya, i was more then a lil skeptical about your idea, didn't seem much different then trying to send a WM_PAINT or InvalidateRect

Care to explain why sending it a mouse click worked, but if i do it with the mouse it doesn't...why would a click even force a PAINT


Thank you, and to the others :)


Solved


*edit*
Seems like the Sleep is enough, gives it that split sec it needs i guess
Last edited on
Sleep on it's own or Sleep and paint didn't work for me - I had tried them before settleing on the mousedown and Sleep and mouseup.

Maybe it's because I'm on Windows 7 - who knows - windows does have it's little weird ways.
I'm on 7 (x64) too, i guess this is one of those things that well, it works, don't touch it :D
Topic archived. No new replies allowed.