I know that friends wait for a long time, many friends send email asking. Press now said that in mid-October, you can go to the city. The fastest listing should be sales on the Internet, then, in terms of regular channels, Beijing should be fast than other areas.
Here, a section of the election is posted.
Book support website: http://www.sunistudio.com/nicrosoft/book/DID/ CD content download temporarily not available.
Thank you!
----------------------------------------------- 4.4.1 Windows programs that are separated from VCL I want to read by understanding a standard Windows program running process, if you don't know, please see one of the following sample programs. Here, I give a very simple Windows application written by pure Pascal to demonstrate how the standard Windows program is established and run. The code and executable of the program can be found in the WindowDemo directory of this book, and the program can be compiled by Delphi. The following is a list of code, please pay attention to the comments: Program windowDemo;
Uses Windows, Messages;
// Window function, when the window is connected, Function WindowProc (hwnd: hwnd; UMSG: cardinal; wparam: wparam; lparam: lparam): LRESULT; stdcall; begin result: = 0; case umsg of // off Window message, when the user closes the window, notify the main message loop end program wm_close: postmessage (hwnd, wm_quit, 0, 0); // Mouse left mouse button Press the message wm_lbuttondown: MessageBox (hwnd, 'hello!', 'And you Tell ', MB_ICONITIONFORMATION;
ELSE / / Other messages do default processing Result: = DefWindowProc (HWND, UMSG, WPARAM, LPARAM); END;
VAR WNDCLS: WNDCLASS; // Window Class record (Structure) Type HWnd: Thandle; Msg: tagmsg; // Message Type Begin Wndcls.Style: = CS_DBLCLKS; // Allow Window Accept Mouse Double-click WNDcls.lpfnWndProc: = @windowProc; / / For the window class specified window function wndcls.cbclsextra: = 0; wndcls.cbwndextra: = 0; wndcls.hinstance: = Hinstance; wndcls.hicon: = 0; wndcls.hcursor: = loadingcursor (Hinstance, 'IDC_ARROW'); Wndcls.hbrbackground: = color_windowframe; wndcls.lpszMenuname: = nil; wndcls.lpszclassname: = 'windowclassdemo'; // window class name
// Register Window IF RegisterClass (WNDCLS) = 0 THEN EXIT; // Create Window HWnd: = CREATEWINDOW ('WindowClassDemo', // Window Name 'WindowDemo', // Window Name WS_Border or WS_CAPTION or WS_SYSMENU, // Window type Integer (CW_USEDEFAULT), Integer (CW_USEDEFAULT), Integer (CW_USEDEFAULT), Integer (CW_USEDEFAULT), 0, 0, hInstance, nil); if hWnd = 0 then Exit; // display window ShowWindow (hWnd, SW_SHOWNORMAL); UpdateWindow ( HWND);
// Create a master message loop, process the message in the message queue and distribute // until you receive the WM_QUIT message, exit the main message loop, and end the program // WM_QUIT message by the PostMessage () function (MSG, hwnd, 0, 0) DO Begin TranslateMessage (MSG); DISPATCHMESSAGE (MSG); END; END. This program does not use VCL, what it does now shows a window, pop up a friendly dialog box when you right-click on the window Question to you. If you have never learned these, then I suggest that you actually run this program on the CD and have more sensual understandings. It is such a simple program that demonstrates the process of standard Windows programs: 1. Create and display window 4 from the entrance function WinMain start 2, the registration window, and window function (Window Procedure) 3, create and display window 4, enter the main message loop, from the message queue Get and distribute the message 5, after the message is distributed, the window function is called by the Windows operating system, and the message is processed by the window function. In Object Pascal, we can't see the so-called "winmain" function, but, in fact, the entire Program Begin is the entrance of the Windows program. The registration window class is done by the system API function registerclass (), which registers a window to the Windows system. After the registration window type is complete, you can create this type of window instance, create a real window to achieve it through the API function createWindow (). The created window instance allows it to display on the screen via an API function showWindow (). When all of this is completed, the window starts entering a While loop to process various messages until the API function getMessage () returns 0 exit program. In the loop, the program needs to take a variety of messages from the message queue of the main thread and distribute it to the system, then the window function (WndProc) of the Windows System calls the window to complete the response process of the window. Maybe you will think that writing a Windows application is so cumbersome, you need to call a lot of API functions to complete the usual look very simple, and we usually use the VCL to write a window application, it seems that these did not encounter these thing. Yes, VCL as a Framework made a lot of things, in which another important mission is to package the hateful, cumbersome steps that package the above.