Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to program the interface of Visual C++

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to carry out Visual C++ interface programming, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.

In order to have this function, I wrote the following function. First of all, you have to add a WM_CTLCOLOR message handle to your dialog box, or use CComboBox's inheritance class, and add the following code to it: it's not quite good after that, and you have to refresh the list box.

That way, you can change the width of the list box at any time according to the length of the text in the list box. You must scan the items in the list box and calculate the length of the text in the list (via pdc), so that if you refresh the list box, you can display the longer items in the list box. The above method is implemented through WM_CTLCOLOR messages, and later I learned that there is a function in MFC's CComboBox class that can do the same thing, that is:

BOOL CSampleDialog:: OnInitDialog () {CDialog:: OnInitDialog (); / / Get pointer to spin button. CSpinButtonCtrl * pSpin-(CSpinButtonCtrl *) GetDlgItem (IDC_SPIN); ASSERT _ VALID (pSpin); / / Set spin buttons default position. PSpin-> SetPos (10); return TRUE;}

Before realizing the high-color toolbar, we first study the implementation process of the ordinary 16-color toolbar, and sum up the improvement methods. In VC's assets view, the toolbar is a resource named Visual C++ interface resource, and the icon on the toolbar can be drawn by the icon on the edit button. Although the icons of the buttons on the toolbar are independent of each other in the resource view.

However, instead of saving as an ico file like an icon, it is saved on disk in bmp bitmap format. The bitmap is a long bitmap image made up of button icons on the toolbar without any gaps in the middle, which is first loaded into a list of images when the program is running and the toolbar is edited in the resource view.

The toolbar then displays the image from the image list to each button on the sidebar according to the index. Due to the Visual C++ interface restrictions on the toolbar icons can not exceed 16 colors, so whether in the resource view directly edit the bitmap or copy and paste and other means of access to more than 256color toolbars (Note: although the use of copy-and-paste method in the editing view can temporarily show the 256color icon, but in the program will still degenerate to 16 colors).

Because you can not edit Toolbar resources in the resource view to achieve more than 16 colors of the icon, coupled with the toolbar in the display is not directly from the Toolbar icon but read from the image list, so you can do a good job through some other image processing software similar to the toolbar bmp image (only the color is richer than the ordinary toolbar bmp image, the rest is exactly the same).

And add to the program resources in the form of a bitmap. When using it, read it into the image list first, so that the color of the icon used to display on the toolbar in the image list can be 256, 24-bit, or even 32-bit color. Because the toolbar loads the resource named Visual C++ interface as the source of the icon by default, the list of images with high-color bitmaps of the toolbar must also be specified as the source of the icon for the toolbar through the SetImageList () function.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report