Questions about Windows Update window content (as an experiment, the effect is obvious)

Source: Internet
Author: User
Tags drawtext

Windows can be redrawn by the system under certain circumstances, such as when the invalid area is re-exposed, and the Vm_paint message is sent to the window's processing, but there may be Windows own Update window processing, as in the following code, the keystroke is explicitly converted to Vm_ The paint message lets the window process handle it, but the result is that the window is not redrawn immediately after the keystroke (the display font is not changed), but instead changes the font the next time it is redrawn, but if it changes to a updatewindow () function, the font is changed immediately. Guess UpdateWindow (), Invaliddaterect (), and Windows system calls all have Update window processing.

#include <windows.h>
LRESULT CALLBACK WndProc (HWND hwnd,uint message,wparam wparam,lparam LPARAM);
LRESULT CALLBACK WndProc (HWND hwnd,uint message,wparam wparam,lparam LPARAM)
{
HDC hdc;
Paintstruct PS;
Rect rect;
static int a=0;
Switch (message)
{
Case WM_CREATE:
return 0;
Case WM_PAINT:
Hdc=beginpaint (HWND,&AMP;PS);
GetClientRect (Hwnd,&rect);
int C;
if (a==0)
DrawText (Hdc,text ("Liu Wangsheng!"), -1,&rect,dt_singleline| dt_center| Dt_vcenter);
Else
C=drawtext (Hdc,text ("HELLO hello!"), -1,&rect,dt_singleline);
EndPaint (HWND,&AMP;PS);
return 0;
Case Wm_destroy:
PostQuitMessage (0);
return 0;
Case WM_KEYDOWN:
Switch (WParam)
{
Case VK_UP:
A=1;
SendMessage (hwnd,wm_paint,0,0);
InvalidateRect (hwnd,null,true);
return 0;
Case Vk_down:
PostQuitMessage (0);
return 0;
}
return 0;
}
return DefWindowProc (Hwnd,message,wparam,lparam);
return 0;
}
int Apientry WinMain (hinstance hinstance,hinstance hprevinstance, LPSTR lpcmdline,int ncmdshow)
{
Todo:place code here.
Static TCHAR Szappname[]=text ("LWS");
HWND hwnd;
MSG msg;
Wndclass Wndclass;

Wndclass.style=cs_hredraw | Cs_vredraw;
Wndclass.lpfnwndproc=wndproc;
wndclass.cbclsextra=0;
wndclass.cbwndextra=0;
Wndclass.hinstance=hinstance;
Wndclass.hicon=loadicon (null,idi_application);
Wndclass.hcursor=loadcursor (Null,idc_arrow);
Wndclass.hbrbackground= (Hbrush) getstockobject (White_brush);
Wndclass.lpszmenuname=null;
Wndclass.lpszclassname=szappname;
RegisterClass (&wndclass);
Hwnd=createwindow (Szappname,
TEXT ("hello!"),
Ws_overlappedwindow,
Cw_usedefault,
Cw_usedefault,
Cw_usedefault,
Cw_usedefault,
Null
Null
HINSTANCE,
NULL);
ShowWindow (hwnd,ncmdshow);
UpdateWindow (HWND);
while (GetMessage (&msg,null,0,0))
{
TranslateMessage (&AMP;MSG);
DispatchMessage (&AMP;MSG);
}
return msg.wparam;
}

http://blog.csdn.net/tobacco5648/article/details/7422803

Questions about Windows Update window content (as an experiment, the effect is obvious)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.