Win32 Windows Programming IX

Source: Internet
Author: User

Use of resources

1 Resource Files

Icon cursor String menu Accelerator Key dialog Resource bitmap and so on

Resource script file-the extension RC file defines information such as resources and related files

Resource Compiler-RC.exe

2 Icons Resource icon

2.1 Frequently used sizes: 16x16, 32x32, 48x48

2.2 Use

hicon LoadIcon (  hinstance  hinstance//Handle to application instance   LPCTSTR  lpiconname   //name string or resource identifier);

2.3 System-Provided icons

HInstance is empty, wife Iconname for the defined system icon

2.4 Draw your own icon

HINSTANCE the application instance handle where the icon is located

2.5 An icon file can include a variety of different size colors of the icon, the system when using icons. to match by size

3 Cursor Resources

3.1 Cursor Resources

Hotspot hotspot-16x16 can produce a mouse click position

3.2 Use

Hcursor LoadCursor (

HINSTANCE HInstance,

LPCTSTR lpcursorname)

3.3 System cursor

HINSTANCE is a null lpcursorname specified as the system cursor ID can be

3.4 Self-drawn cursors

HINSTANCE is not empty

3.5 wm_setcursor

When the mouse is inside the window, it will create a style that changes the mouse while the program is running.

WParam-Form Handle

Identification of the location of the LoWord (LParam)

HiWord (LParam) the message ID of the mouse

4 string Resource

4.1 Resources that include strings

4.2 Use

int LoadString (  hinstance  hinstance,  //program handle to hold string resource   UINT  UID  ,             //resource ID  LPTSTR  lpbuffer,      //buffer that holds the string  int Nbuffermax        The size of the buffer );

5 Menu Resources

5.1 Adding a menu resource

5.2 Loading Menu Resources

  hinstance   hinstance ,   Handle to Module   lpctstr  lpmenuname    //Menu name or resource identifier c33>);
5.3 Command Handling

Use the added menu ID of the macro, in the WM_COMMAND message, to process the menu command

6 Accelerator Key Resources

6.1 Role of accelerator keys

Ability to run commands using accelerator keys. Like Ctrl+s disk.

6.2 Adding accelerator key resources

6.3 Use of accelerator keys

6.3.1 Loading

haccel loadaccelerators (  hinstance  hinstance,  //handle to Module   LPCTSTR lptablename   Accelerator table name);

6.3.2 adding message Processing

int TranslateAccelerator (  hwnd  hwnd,         //form handle   haccel  hacctable  ,  //  accelerator key table handle   lpmsg  lpmsg        //MSG structure address );

6.4 Message about accelerator keys

Traslateaccelerator translate wm_keydown or wm_syskeydown into WM_COMMAND or wm_syscommand messages.

When a KeyDown or Syskeydown message is received, the corresponding command ID is found based on the corresponding relationship between the key and the command ID in the accelerator key table, and then called

The form's handler function, which runs the WM_COMMAND message or the Syscommand message.

When the corresponding command ID is found and run, Traslateaccelerator returns nonzero. Then it is not running a possibly processing, the message loop waits for the next message.

Otherwise continue to allow Traslatemessage and dispatchmessage in the message loop to process




Win32 Windows Programming IX

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.