473,511 Members | 16,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

does InvalidateRect() always invokes WM_PAINT

86 New Member
hi,
I am using InvalidataRect(hWnd, &rect, TRUE) to clear my client rect....does this mean that a WM_PAINT message will the invoked automatically by it....

neways fot the time being lets assume it does....

look at this code snippet...
Expand|Select|Wrap|Line Numbers
  1. switch(message)
  2. {
  3. case WM_CREATE:
  4.          srand(time(0));
  5.          break;
  6. case WM_SIZE:
  7.          GetClientRect(hWnd, &rect);
  8.          break;
  9. case WM_LBUTTONUP:
  10.          InvalidateRect(hWnd, &rect, TRUE); // TRUE so that it clears 
  11.                                                                      // the screen
  12.          break;
  13. case WM_PAINT:
  14.          BeginPaint(hWnd, &ps);
  15.          ShowText(hWnd, rect); 
  16.         EndPaint(hWnd, &ps);         
  17.         break;
  18. case WM_DESTROY:
  19.          PostQuitMessage(0);
  20.          break:
  21. ...
  22. ...
  23. ...
  24. ...
  25. }
  26.  
now ShowText() does nothin but prints a text at random position on screen

Now my question is if InvalidateRect() invokes WM_PAINT every time its called then it should print the desired text every time i click on a blank screen....but the fact is nothin happens after just for once the text is being displayed...
Jul 18 '07 #1
3 8348
weaknessforcats
9,208 Recognized Expert Moderator Expert
Yes, InvalidateRect() always dispatches a WM_PAINT to redraw the window.

This code:
Expand|Select|Wrap|Line Numbers
  1. case WM_PAINT:
  2.          BeginPaint(hWnd, &ps);
  3.          ShowText(hWnd, rect); 
  4.         EndPaint(hWnd, &ps);         
  5.         break;
  6.  
I'm not sure what ShowText() is. Do you mean RedrawWindow()? If ShowText is your function then it has to GetRect on hWnd so ti knows where to drop the text. Probably, you should use TextOut().
Jul 18 '07 #2
ayan4u
86 New Member
Yes, InvalidateRect() always dispatches a WM_PAINT to redraw the window.

This code:
Expand|Select|Wrap|Line Numbers
  1. case WM_PAINT:
  2. BeginPaint(hWnd, &ps);
  3. ShowText(hWnd, rect); 
  4. EndPaint(hWnd, &ps); 
  5. break;
  6.  
I'm not sure what ShowText() is. Do you mean RedrawWindow()? If ShowText is your function then it has to GetRect on hWnd so ti knows where to drop the text. Probably, you should use TextOut().
yes ShowText is my function and i have passed hWnd to GetClientRect...ok now that i have solved this problem i am facing another...

now,
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. case WM_LBUTTONDOWN:
  4.          InvalidateRect(hWnd, &rect, TRUE);             
  5.          break;
  6.  
must clear the client rect of window "hWnd" when i click left mouse button and invoke WM_PAINT and the text will be written again on the screen....but nothn happening on mouse click...(the story is different if i pass NULL as the first argument....which in case repaints all the active windows)
Jul 20 '07 #3
ayan4u
86 New Member
ok this problem solved too....just to add GetClientRect() before InvalidateRect() so that the structure "rect" is filled with enough informations....
Jul 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

31
3680
by: bilbothebagginsbab5 AT freenet DOT de | last post by:
Hello, hello. So. I've read what I could find on google(groups) for this, also the faq of comp.lang.c. But still I do not understand why there is not standard method to "(...) query the...
8
1590
by: ±èµ¿±Õ | last post by:
#include"stdio.h" main() { int a = 128 * 128 * 128 * 128 * 128 * 128 * 128 * 128 ; int a1 = 256 * 256 * 256 * 256; char b = 256 * 256 * 256 * 256; long c = 256 * 256 * 256 * 256; float d =...
4
6698
by: Kevin Dombroski | last post by:
Howdy - I would like my application to be able to read data from another application. Specifically, I would like my to get the text from the "client area" of another application's window whenever...
3
2096
by: Erik Greene | last post by:
I have written an application that contains a notifyicon that will not dispose or end when Windows shutsdown. I have seen other posts where people are experiencing the same issue (see post in...
19
352
by: centurian | last post by:
I have compiled following program with g++/gcc 3.3.1 and "MS Visual C++ 6" and it ran without any errors. Does this thing make any sense? Is it of some use or some problem with grammar/CFG of...
89
5948
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
2
2690
by: =?Utf-8?B?RXJpYw==?= | last post by:
Hello All, I am currently working on an issue that has a custom control that mimics a combobox that when it has focus it continues to generate endless WM_PAINT Messages. The control in itself...
2
2305
by: kiberg | last post by:
Hi When I listen WM_PAINT event, the cpu is max. LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { int x, y; HDC hdc; HPEN hOldPen, hPen; HBRUSH...
11
7592
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.