UINT uFormat // text-drawing options);5. Write the program: Design a line of text on the window, the text can scroll to the left in the window display, and each display round, change the color and font.The main code of the program is as follows:static int flag=0;int x=0;LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM){???? int Wmid, wmevent;???? Paintstruct PS;???? HDC hdc;???? RECT Clientrect;???? TCHAR szhello[max_l
. The address has been determined during compilation. Because it needs to be set in the registered window type, as follows:
#008 atom myregisterclass (hinstance)
#009 {
#010 wndclassex wcex;
#011
#012 wcex. cbsize = sizeof (wndclassex );
#013
#014 wcex. Style = cs_hredraw | cs_vredraw;
#015 wcex. lpfnwndproc = wndproc;
Row 15th is the message processing function of the window.
The defwindowproc function declaration is as follows:
Lresult defwindowproc (hwnd,
Uint MSG,
Wparam,
Lparam
);
This fun
downs (WM_XBUTTONDOWN or WM_XBUTTONUP) messages. For all messages, the lParam parameter passed in by the window procedure function contains the cursor position, where the base position is the x coordinate and the high position is the y coordinate, these coordinate values are relative to the values in the upper left corner of the window client area, and wParam contains the state of the mouse button.Instance
Key code
// The example program demonstrates how to wait for the left-click message to d
handle, the destination does not need to be explicitly specified. When a message is received in the target window, the window procedure function is executed and processed based on different messages. Because the window procedure function and the window class name have a corresponding relationship when registering the window. When creating a window, we use the window class name again. Therefore, we can infer that the window handle and Window Process letter obtained after the window is created ar
parameters for message { N Bsp , NB Sp , NB Sp //additional information int wmid, wmevent; Paintstruct PS; //saved the window drawing information hdc hdc; //the handle of the element in the window TCHAR szhello[max_loadstring]; //defines a double-byte string LOADSTRING (HInst, Ids_hello, Szhello, max_loadstring); //the character in the Resource table to the Szhello variable switch (message) //Select message {case WM_C
cursor is displayed.
The beginpaint and endpaint functions are declared as follows:WinuserapiHDCWinapiBeginpaint (_ In hwnd,_ Out lppaintstruct lppaint );
WinuserapiBoolWinapiEndpaint (_ In hwnd,_ In const paintstruct * lppaint );HwndIs the window handle.LppaintIs to obtain the display parameters. Its structure is defined as follows:Typedef struct tagpaintstruct {HDC;Bool ferase;Rect rcpaint;Bool frestore;Bool fincupdate;Byte rgbreserved [32];} Paintstruct, * ppaintstruct;HDCIs to obtain the d
is created here. Unlike the previously created window, there is only one difference, that is, the setwindowlongptr function is called in row 24th to save the object pointer to the custom data of the window, in this way, the following static member function wndproc can be used to compile class members. As follows:#001 //#002 // function: wndproc (hwnd, uint, wparam, lparam)#003 //#004 // purpose: to process messages in the main window.#005 //#006 // Cai junsheng 2007/07/27 QQ: 9073204#007 //#008
message and the wm_paint message in the customer zone.
// This section of code is taken from the code automatically generated by the vc6 Application Wizard, and some test code lresult callback wndproc (hwnd, uint message, wparam, lparam) {int wmid, wmevent; paintstruct pS; HDC; tchar szhello [max_loadstring]; loadstring (hinst, ids_hello, szhello, max_loadstring); Switch (Message) {Case wm_command: wmid =
form of awm_command message with cbn_selchange in the high-order wordOf the wparam parameter.
Syntax
CBN_SELCHANGE WPARAM wParam LPARAM lParam;
Parameters
Wparam
The low-order word specifies the control identifier of the combo box.
The high-order word specifies the notification message.
Lparam
Handle to the combo box.
Process message code:
Lresult callback wndproc (hwnd, uint message, wparam, lparam){Int
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.