• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Got a little problem with UpdateWindow(HWnd)

## Recommended Posts

Good day/morning/night/afternoon/whatever y'all, I have written a very basic application that allows the user two load to files and compare them byte for byte (and display the results of course). It is still at a very early stage but everything works fine so far - everything EXCEPT one thing. My program is supposed to display the path, file name and size of the first file as soon as it has been loaded . The problem is, it doesn't. Well, at least not until I either a) resize the window (and thus invalidate it so it has to be redrawn) or b) load the second file (which apparently also causes the window to be redrawn). I dunno what to do to force the window to be redrawn. I even threw in an UpdateWindow() directly in my ReadFile() method to make that happen, but it didn't do the trick either. Maybe you guys have an idea what I should do to remedy this? Oh BTW, here's my windows procedure.
  LRESULT CALLBACK MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: MWnd.InitApp(hWnd); return 0; case WM_CLOSE: PostQuitMessage(0); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: MWnd.DisplayContent(); // <-- this method is responsible for displaying all info about return 0; // file names, paths, sizes plus the results of the comparison case WM_SIZE: MWnd.GetWndSize(lParam); return 0; case WM_COMMAND: switch (wParam) { case ID_FILE_EXIT: PostQuitMessage(0); return 0; case ID_FILE_FOPEN: // <-- this loads a file into one of the 2 available slots MWnd.ReadFile(); return 0; case ID_FILE_FSAVE: return 0; case ID_FILE_FCLEAR: MWnd.ClearAll(); return 0; case ID_RUN_COMPAREFILES: // <-- this compares both files MWnd.CompareFiles(); return 0; } } return DefWindowProc(hWnd, msg, wParam, lParam); } 
Thanks in advance. Regards, Markus Edited by - Red Ant on October 18, 2001 10:07:23 PM

##### Share on other sites
I think you have to invalidate the rectangle after your readfile method has finished.

  case ID_FILE_FOPEN:MWnd.ReadFile();InvalidateRect (hwnd, NULL, TRUE);return 0;

this will cause a WM_PAINT message to be placed in the queue.

Also, I think your DisplayContent() method needs to validate the rectangle in some way so that you don''t get an endless string of WM_PAINT messages.

You can do this by calling ValidateRect() or,
calling BeginPaint() and EndPaint().