Easy to make 24 true color toolbars

zhaozj2021-02-17  52

Easy to make 24 true color toolbars King Fan2002 / 11/29

Making 24 true color toolbars, online information can be really much. I wanted to give up this article before I wrote this article, although I made it, I have already made it.

During this time, because if you don't have anything, the boss looks at me is also idle, just make a software interface first, hugging the mindset and work, I started doing. Seeing Acrobat Reader 5.1, I think I can also make the toolbar as an exact same? The idea is of course feasible, and the practice is also possible. Online information quickly, I will get it easily (thanks to Google is not blocked). Into the roar painting scoop, the toolbar made. The effect is good, but, the tool is really ugly when the tool is invalid, and the ugly is better than Toyi, unlike Reader5.

How to do? The method is still there, and it is really easy to achieve. Hey, if you know that it is so easy, I don't say the above little pile. J

Making this thing, we still take a three steps.

First, the principle of making the principle, huh, huh. In fact, send a message to the Toolbar object, of course, this news is not your order, it is Microsoft. MFC provides a lot of messages related to toolbar, there are dozens of dozens, see MSDN, the news starting with TB_ is for toolbar. I want to use three messages here, respectively, respectively:

TB_SetImageList: Setting Tool Twilight During Graphics

WPARAM = 0;

LPARAM = (lparam) HIMLNEW;

TB_SETHOTIMAGELIST: Setting Tools to Trouble After the Hotspots

WPARAM = 0;

LPARAM = (lparam) (himagelist) HIMLNEWHOT

TB_SETDISABLEDIMAGELIST: Setting Tool Twisting Graphic

WPARAM = 0;

LPARAM = (lparam) (himagelist) HIMLNEWDISABLED;

Second, how to send a message

The issuance message is of course still used with a SendMessage function. The function is defined as follows:

LResult SendMessage (uint message, wparam wparam = 0, lparam lparam = 0);

The meaning of the parameter is not explained, and if you don't understand, you don't understand MSDN.

Third, about toolbar pictures

There are three types of toolbars, so we have three sets of pictures. The size of these three sets should be consistent (of course, pixels), the position of the tool is in line with. One thing to note is that there is no partition between the twisting in the picture, it is tightly together. Are you afraid of an error? Nothing, this stuff is a beautiful business, called the beauty. However, it is a good choice to paint in the res / Toolbar.bmp file.

These three sets have to be added to the resource file. I am named Idb_ToolBar_Cold (Default), IDB_TOOLBAR_HOT, IDB_TOOLBAR_DISABLE (invalid)

After three steps, the last step is to copy code.

/ / Add the following code to the least end of the CMAINFRAME :: oncreate function.

// SET UP HOT BAR Image LISTS.

Cimagelist imagelist;

CBitmap Bitmap;

// CREATE AND SET The Normal Toolbar Image List.

BitMap.LoadBitmap (idb_toolbar_cold);

Imagelist.create (21, 20, ILC_COLORDDB | ILC_MASK, 13, 1);

Imagelist.add (& Bitmap, RGB (192, 192, 1992)); // RGB (192, 192, 192) is Win98's twisting color

M_WndToolBar.sendMessage (tb_setimagelist, 0, (lparam) imagelist.m_himagelist);

Imagelist.detach ();

Bitmap.detach ();

// Create and set the Hot Toolbar Image List.

Bitmap.LoadBitmap (IDB_TOOLBAR_HOT);

Imagelist.create (21, 20, ILC_COLORDDB | ILC_MASK, 13, 1);

Imagelist.add (& Bitmap, RGB (192, 192, 192);

M_WndToolBar.sendMessage (tb_sethotimagelist, 0, (lparam) imagelist.m_himagelist);

Imagelist.detach ();

Bitmap.detach ();

// Create and set the disable Toolbar Image List

Bitmap.LoadBitmap (idb_toolbar_disable);

Imagelist.create (21, 20, ILC_COLORDDB | ILC_MASK, 13, 1);

Imagelist.add (& Bitmap, RGB (192, 192, 192);

M_WndToolBar.sendMessage (TB_SETDISABEDIMAGELIST, 0, (LPARAM) imagelist.m_himagelist);

Imagelist.detach ();

Bitmap.detach ();

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

New Post(0)