How to program the Visual C ++ Interface

Source: Internet
Author: User

The following describes the difficulties and problems encountered in learning the Visual C ++ interface and the skills used to learn the Visual C ++ interface, for more information about how to learn the Visual C ++ interface.

In order to have this function, I wrote the following function. First, you must add a message handle of WM_CTLCOLOR in your dialog box, or use the inheritance class of CComboBox, and add the following code in it: this is not completely good, you have to refresh the list box.

In this way, you can change the width of the list box according to the text length in the list box at any time. To do this, you have. You must scan the entries in the list box and calculate the length of the text through pdc). In this way, if you refresh the list box, you can display a large segment. The above method is implemented through the WM_CTLCOLOR message. Later I learned that there is a function in the CComboBox class of MFC that can implement the same function, that is:

 
 
  1. BOOL CSampleDialog : : OnInitDialog ( )   
  2.  
  3. {   
  4.  
  5. CDialog : : OnInitDialog ( ) ;   
  6.  
  7. //Get pointer to spin button .   
  8.  
  9. CSpinButtonCtrl * pSpin - ( CSpinButtonCtrl *) GetDlgItem (IDC_SPIN) ;   
  10.  
  11. ASSERT _ VALID (pSpin) ;   
  12.  
  13. //Set spin buttons default position .   
  14.  
  15. pSpin —> SetPos (10) ;   
  16.  
  17. return TRUE ;   
  18.  
  19. }  

Before achieving the High-color tool bar, first study the implementation process of the normal 16-color tool bar and summarize the improvement methods. In the resource view of VC, a toolbar is a resource named Visual C ++ interface resource. You can draw a toolbar by clicking the icon on the edit button. In the resource view, the icons of buttons on the toolbar are independent of each other.

However, the storage is not saved as an ico file like an icon, but saved as a bmp bitmap on the disk. This bitmap is a long bitmap image composed of Button icons on the toolbar, with no gaps in the middle, when the program runs and the resource view edits the toolbar, the image is first loaded into an image list.

Then, the toolbar displays the image to the buttons of the toolbar from the image list according to the index. Because the Visual C ++ interface limits the number of icons on the toolbar to 16 colors, you cannot obtain a toolbar that exceeds 256 colors by either directly editing the bitmap in the resource view or copying or pasting the toolbar. Note: although the 256-color icon can be temporarily displayed in the editing view, it will be degraded to 16 colors when running the program ).

Because you cannot edit a Toolbar resource in the resource view to implement icons of more than 16 colors, In addition, when the Toolbar is displayed, the icons are not obtained directly from the Toolbar but read from the image list, therefore, we can use other image processing software to make bmp images similar to tool strips richer in color than bmp images of common tool strips, and the rest are exactly the same ).

And add it to program resources in the form of Bitmap. When using the tool, read it to the image list first. In this way, the color of the icon displayed on the toolbar in the image list can be 256, 24, or even 32 bits. Because the tool bar is missing, the Resource Name Visual C ++ interface is directly loaded as the icon source, so you must also use SetImageList) the function specifies the image list containing the High-Color toolbar bitmap as the toolbar icon source.

  1. Introduction to C ++
  2. Summary Notes on learning and exploring C ++ library functions
  3. Basic Conception and method of C ++ Class Library Design
  4. Does C ++ really have market value?
  5. Basic Conception and method of C ++ Class Library Design

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.