Use of resources

1 Resource file

Icon cursor character string menu   Accelerator key Dialog resource bitmap and so on

Resource script file - extension RC file Defines information such as resources and related documents

Resource compiler - RC.exe

2 Icon resources ICON

2.1  Several sizes that are often used : 16x16 ,32x32, 48x48

2.2 Use

HICON LoadIcon(
HINSTANCE
hInstance, // handle to application instance
LPCTSTR lpIconName // name string or resource identifier
);

2.3 Icons provided by the system

hInstance It's empty , The wife IconName System icon defined for

2.4 Draw your own icons

hInstance Handle to the application instance where the icon is located

2.5 An icon file can contain multiple sizes Icons in different colors , When the system uses icons . Match by size

3 cursor resource

3.1 cursor resource

hotspot Hotspot - 16x16 Can generate mouse click position

3.2 Use

HCURSOR LoadCursor(

HINSTANCE hInstance,

LPCTSTR lpCursorName )

3.3 System cursor

hInstance It's empty lpCursorName Designated as the system cursor ID Can

3.4 Self drawn cursor

hInstance Not empty

3.5 WM_SETCURSOR

When the mouse is in the form, it will produce Can change the mouse style in the process of running the program

WParam - Form handle

LOWORD(lParam)     Identification of the location

HIWORD(lParam)   Mouse message ID

4 String resource

4.1 Resources that include strings

4.2 Use

int LoadString(
HINSTANCE
hInstance, // A handle to a program that holds string resources
UINT uID, // resources ID
LPTSTR lpBuffer, // To store strings BUFFER
int nBufferMax // Buffer Size
);

5 Menu resources

5.1 Add menu resources

5.2 Load menu resources

 HMENU LoadMenu(
HINSTANCE
hInstance, // handle to module
LPCTSTR lpMenuName // menu name or resource identifier
);

5.3 Command processing

Use the added menu ID The macro , stay WM_COMMAND In the news , Handle menu commands

6   Accelerator resources

6.1 The accelerator function

Be able to use the accelerator to run commands . such as Ctrl+S Save

6.2 Accelerator resources are added

6.3 Use of accelerator keys

6.3.1 load

HACCEL LoadAccelerators(
HINSTANCE
hInstance, // handle to module
LPCTSTR lpTableName // accelerator table name
);

6.3.2 Add message processing

int TranslateAccelerator(
HWND
hWnd, // Form handle
HACCEL hAccTable, // Handle to accelerator table
LPMSG lpMsg // MSG Address of structure
);

6.4 Message about Accelerator

TraslateAccelerator take WM_KEYDOWN perhaps WM_SYSKEYDOWN Translate into WM_COMMAND perhaps WM_SYSCOMMAND news .

When I received KEYDOWN perhaps SYSKEYDOWN According to the buttons and commands in the accelerator table ID The corresponding relationship between Find the appropriate command ID, And then call

Window processing function , function WM_COMMAND News or SYSCOMMAND news .

When the corresponding command is found ID And after running ,TraslateAccelerator Return nonzero . Then you don't run the possible processing , The message loop waits for the next message .

Otherwise, continue to let... In the message loop TraslateMessage and DispatchMessage Handle

Win32 Windows Programming More related articles on nine

  1. Win32 Windows Programming Ten

    One Windows drawing 1 Graph drawing 1.1 The way graphics are drawn Get the handle to the drawing , Device description descriptors (DC). Use the corresponding drawing API. Drawing on the device 1.2 Color RGB, Each color 8 position , common 24 Bit color 32 position ...

  2. Win32 Windows Programming Twelve

    One . Dialog box 1. Categories of dialog boxes 2. The basic use of dialog boxes 3. Dialog resources 4. There is the use of modal dialog boxes 5. The use of modeless dialog boxes 5.1 Add dialog resources 5.2 Define form handling functions BOOL CALLBACK ...

  3. Win32 Windows Programming 7、 ... and

    Timer message 1. WM_TIMER According to the time period set by the timer , I take the initiative to send a timer message to the form WM_TIMER. Low priority The precision of timer is low . Millisecond level . The accuracy of message generation time is also relatively low 2 . Messages and functions WM ...

  4. 【Windows Programming 】 Series 6 : establish Toolbar And Statusbar

    Last time we learned how to use Windows GDI drawing , The applications are all static windows of light , We use Windows Applications , Any slightly more complex program will have a toolbar and a status bar , The toolbar is mainly used for some shortcut buttons . For example, canon ...

  5. 【Windows Programming 】 Series 10 : Text inserters

    As we all know , When you create a project using Microsoft's programming environment, you will be given the choice of console mode or Windows Applications . If you choose the console console Pattern , A black character mode window will appear at run time , There's a flashy insert waiting for input ...

  6. 【Windows Programming 】 Chapter 8 of the series : Common dialog box

    Last time we learned the basic programming of menu , This article is about the use of General dialog box .Windows System is the most popular desktop system at present , It is also because Windows There's a set of standards , Unified friendly interface , Like the menu . The toolbar . The status bar and each ...

  7. 【Windows Programming 】 The fifth part of the series :GDI Graph drawing

    In the last two articles, we learned about text character output and Unicode Programming , Know how to use common Win32 Output text string , Let's learn this one Windows Another very important part of programming GDI Graphic drawing .Windows Of GDI Function contains number ...

  8. 【Windows Programming 】 Part three of the series : Text character output

    Last time we showed how to use Windows SDK Create basic controls , This article discusses how to output text characters . In the use of Win32 When programming , We often have to output text to the window ,Windows All text characters or graphics output are connected through graphics devices ...

  9. MFC-01-Chapter01:Hello,MFC---1.1 Windows Programming model

    1.1 Windows Programming model Programs written for traditional operating systems use a procedural model , That is, the program is executed in sequence from beginning to end . for example C Program , from main The function entry starts executing , Call different functions until the end of the program , The process is the program itself ...

Random recommendation

  1. Team work - In the second week of -SRS file

    Use case diagram of mobile classroom roll call :

  2. [ turn ]Asp.NET MVC Widget Development - ViewEngine

    In this paper, from :http://www.cnblogs.com/hsinlu/archive/2011/03/02/1968796.html stay Asp.NET Develop blog system , We use it all the time Widget, Like in ...

  3. Javascript Refresh the page

    Non modal refresh parent page :window.opener.location.reload(); Mode refresh parent page :window.dialogArguments.location.reload(); Let's start with a simple one ...

  4. timer Use

    ; private void timer1_Tick(object sender, EventArgs e) // Scheduled execution events { button1.Text = i.ToString();// Display button ...

  5. How to configure git ssh Connect , How to be in GitHub Join collaborative developers on the web , How to configure gitignore And how to be in GitHub Delete repository on .

    **********1. Running git push origin master For example, the following error : iluckysi@ILUCKYSI-PC /d/ilucky/message/code (master ...

  6. 6. How to use jedis Thread pool of

    Basic usage example using Jedis in a multithreaded environment You shouldn't use the same instance f ...

  7. TensorFlow And DNN( 3、 ... and ): Regularization method of neural network (Dropout、L2 Regularization 、 Early stop and data enhancement )

    This blog is organized with TensorFlow The content of neural network regularization . Deep neural networks often have hundreds of thousands or even millions of parameters , It can transform very complex features , Have strong learning ability , So it's easy to over fit on the training set . To alleviate the over fitting of neural network ...

  8. Webpack Study 2

    webpack + react Optimize : narrow js Package volume webpack Introduce & install & Common commands 30 I'll teach you by hand webpack actual combat Webpack Chinese guide

  9. 20155222 Lu Zijie Experiment 8 Web Basics

    Experiment 8 Web Basics 1. install apache sudo apt-get install apache2 2. start-up apache service apache2 start 3. Use netstat -tupl ...

  10. Python Introduction os.walk() Method

    os.walk Method , It is mainly used to traverse subdirectories and sub files in a directory . os.walk(top, topdown=True, onerror=None, followlinks=False) You can get a ternary ...