Win32 study notes first chapter

zhaozj2021-02-16  44

Win32 learning notes

Author: Jiang Xuezhe (netsail0@163.net) materials: Windows programming (fifth edition), Peking University Press, [the United States] Charles Petzold with the Beijing Science and Technology Development Co., Ltd. Bo Yan translated ¥: 160 Environment: windows2000 server Internet Explorer 6.0 DirectX7 .0 Visual C 6.0

(Tunjiang computer program preparation group copyright, reproduced please explain the source) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------Chapter One begin

From the comment of "Windows Programming" from the Nth page, I started to have a big pile of praise, I will always meet main (), let me feel very kind!

#include

INT main () {Printf ("Hello World / N");

Return 0;}

Then the equivalent program of Windows version

1.3.2 Windows Equivalent Program

/ ************************************************** ***** Copyright (C) 2003, Tumen Programming Clan (Netsail0@163.net) All Rights Reserved.

Filename: Hellomsg Author: Hack-Chul Kang ********************************************************* ************* / # include

Int WinAPI Winmain (Hinstance Hinstance, Pstr Szcmdline, ICMDSHOW) {MessageBox (Null, Text ("Hello, Windows98!"), Text ("Hellomsg"), 0);

Return 0;}

After running the above program, a dialog box will appear as the "". You can see Hello Windows98! On the center of the dialog box, and a "big" 'deterministic' button. congratulations! Your first Windows program has been here!

In standard C we need stdio.h, and we need Windows.h in Windows C.

Page 2 of the program entry point is introduced. Please don't pay attention to the four long parameters. As mentioned earlier, it is okay. We have to pay attention to MessageBox ().

The first thing to explain is Text (). This is a macro definition, that is, defined by define. This is the change made in compatibility with the Unicode character set. Whenever you do, you'd better enclose the string with text (), and you can see Chapter 2 of Unicode.

Thirteenth page

#define mb_ok 0x00000000L # Define MB_OKCANCEL 0x00000000001L # define MB_AbortRetryIgnore 0x00000002L # define MB_YESNOCANCEL 0x00000003L # define MB_YESNO 0x00000004L # define MB_Retrycancel 0x00000005L

The above is the fourth parameter option for Messagebox (). It is very simple to understand their specific meaning. The fourth parameter of Messagebox () is zero in the Hellomsg program above, and you can change the zero to one of the six constants above, such as MessageBox (Null, Text ("Hello Windows98!"), Text ("Hellomsg "), MB_OKCANCEL;

After re-run, you will find more a 'cancel' button in the dialog. If you are using the English version, the two buttons are OK & Cancel, respectively. You can try one by one.

Fourteenth page

#define MB_ICONHAND 0x00000010L # Define MB_ICONQUESTION 0x0000000020L # Define MB_ICONEXCLAMATION 0x00000030L # Define MB_IConasterisk 0x00000040L

These are the icon options in the dialog. You can use the "|" operator in the C language to combine with one of the six options mentioned earlier, such as:

MessageBox (NULL, TEXT ("Hello Windows98!"), Text ("Hellomsg"), MB_OKCANCEL | MB_ICONHAND);

After running the above program, you will see more red icons in the original dialog. It is a "fork" that is used in an error. This icon I don't like it. I prefer exclamation points, so put the program. Change to:

MessageBox (Null, Text ("Hello Windows 98!"), Text ("Hellomsg"), MB_OKCANCEL | MB_ICONASTERISK);

After running, you can see the exclamation mark that appears in a white-backed blue word in the dialog.

Since this, is you aware of the last three parameters of MessageBox ()? As for the first parameter, wait until the third chapter. What ?? Are you still confused? -_- # I suggest you send a C4 to Bill Gates.

转载请注明原文地址:https://www.9cbs.com/read-26927.html

New Post(0)