Win32 study notes first chapter

zhaozj2021-02-16  46

Win32 learning notes

Author: Jiang Xuezhe (netsail0@163.net)

Textbook: Windows Program Design (Fifth Edition) Peking University Press [United States] Charles Petzold Translations from Beijing Boan Technology Development Co., Ltd.不 作者 不 编 工 出 社 社 社 社 工 社 社 出 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 社 译 译 译 张 张 张 张 张 译 译 译 译 译 译 译 译 译 译 译 译 ¥ ¥ ¥ ¥ ¥ ¥ 译 ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ ¥ Xu Kexi ¥: 42

Environment: Windows2000 Server Internet Explorer 6.0 DirectX7.0 Visual C 6.0

Copyright, Reprint, please explain the source ------------------------------------------------------------------------------------------------------------------------------- ------------------------------------- [Chapter 1 start]

After cooling "StarCraft", I can't help but sorry. If the star's map is bigger, the population is limited to a little more. The map size should be 81 times the map of 8 people, and the population should be 6000. It is impossible for it. No one can afford it. I want to command a real war. Just like Liu Deng Dafa and the Kuomintang army. In fact, the intersteration is very good, I can't ask anything.

Speaking here, I think of our most commonly used operating system Windows series. I have been to many forums, including Linux Forum, most netizens like to lysers Microsoft and all products of the company. I used to have passed, and later realized that my own mistakes were not yet. There are a lot of people with pirated Windows and IE to go to Microsoft. Is there a kind of linux? Do you want to buy a genuine and then you can.

My favorite company is Microsoft. Because the status of Microsoft programmers is very high, especially headquarters. Microsoft is created by two genius programmers. I don't like Microsoft for the programmer.

Take Microsoft so much hit, how can I not understand the Windows system? So I want to learn Win32. Thoroughly understand Microsoft's products.

Learning Win32, that is, reading Windows programming (fifth edition) must have three prerequisites.

First we should be familiar with the Windows system from the perspective of users. It means that you will use Windows. I think this a lot can do it.

Second, you should understand the C language. why? Windows is written with C, the book is explained in C language, which is the reason. Of course, if you are willing, you can also write in Pascal. But you have to find another book. The title should be the Windows programming (Pascal version).

Third, there should be a Visual C 6.0. I don't expect you to use genuine. More than 10,000 RMBs, more expensive than my computer.

In the book, we can have no programming experience in any graphical user interface. Very good!

Microsoft published books, of course, from greatly enlarged brilliant history.

Let's take a look at the Win32 version of "Hello World", oh, sorry! It should be "Hello Windows98!".

#include

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

The entrance in the C language should be main (), but it has changed to Win32, and WinMain () replaces main (). For beginners who have never been exposed to Win32, the above program may make you fog.

MessageBox () is the dialog function. It is provided by the Windows system. This is the legendary Windows API (Application Interface). The function function is to display a dialog. The content displayed by the dialog is the second parameter Text (Hello, Windows98!). The string in the third parameter appears in the title bar.

About text (), this is a macro definition, that is, defined by define. This is the change made in compatibility with the Unicode character set. In the future, you should make it better to enclote the string, about Unicode, which is the problem of the second chapter, so this problem is not a problem at all.

The header file contains other header files, and some of these headers contain additional headers.

◆ WINDEF.H ◆ Winnt.h ◆ WinBase.h ◆ Winuser.h ◆ Wingdi.h

These header files define all data types, function calls, data structures, and constant identifiers of Windows.

WinMain () WinAPI is defined in WINDEF.H as follows:

#define winapi __stdcall

I don't know the specific meaning. Maybe there will be a detailed explanation.

#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 () in the Hellomsg program above is zero, 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-compiling, 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.

#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 Windows98!"), 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.

In this way, the content of the first chapter is completed. Is it very strong, I want to write the impulse of the application software? Don't worry, come slowly. The next chapter briefly understands Unicode.

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

New Post(0)