Static Text Settings category: CLabel class author: NormSoft example Author: Gong Jianwei Gong Jianwei Technology Home ◆ ◆
Clabel class can change Static static text color, background, or set static text to hyperlinks, and ask me how to change the dialog text color (not all changes), find this class, have made an example program (The Original Autor's Expamle Program Is Not Suit for Beginner, I recommend it to you, have a good work, don't forget to send me a copy. First download the source program: Download (including the sample program I do) (269 provides links) Ok, if it is a friend of the beginner VC, first follow the sample program, the old bird is going to see the program. 1. New project: Newly built a dialog-based TestStaticLabel project in VC6, and add the control in the dialog box as shown in the figure, set different IDs for each static text. (In the Properties of the Static Control. See how I set it, do whatever you want, it is best to make memories, it is a good program habit, this is nonsense); 2. Insert a document in the project: All label.cpp and label.h files Copy to the project folder, Project-> add to project-> files selected Label.cpp and label.h files, ok; how, see the CLabel class in ClassView. Open ClassWizard If you do not see the CLABEL class, you can close the classwizard (without turning off the VC), delete the testsaticLabel.clw file in the project folder, open ClassWizard, you will see the prompt: "The classwizard database doesn't exist, .. ..., Would You Like To Build IT from Your Source Files? ", select Yes, a dialog box, click Add All, click OK, ok, you can see the Clabel class in ClassWizard. 3. Add the DDX control variable for each Static Static Text to change the settings in the dialog header file testsaticLabeldlg.h "Label.h"; open the ClassWizard, select the Member Variables page, select the corresponding static text ID, Click Add Viriable, select Control in Category in the dialog, Variable Type selection Clabel, Variable Name is set by yourself. (Plus the IDX control variable to be changed) 4. Static text setting method In the OnInitDialog () function in the dialog box, add code: // where: DDX Clabel control variable starting with m_ctrl
// Todo: add extra initialization herem_ctrlstaticxfs.setFontName ("arial") // FOR 啸峰 studio.SettextTextColor (RGB (255, 255, 0)). SetFontunderline (True) .setbkcolor (RGB (RGB (0,0,0 , 0)) .SetFontbold (true) .SetBorder (TRUE) .SetSunken (TRUE); m_ctrlstaticwww.setLink (True) .SetTextColor (RGB (0, 0, 255)). SetFontunderline (TRUE) .SetFontsize (15 ) .SetLinkCursor (AfxGetApp () -> LoadCursor (IDC_CURSOR1));.. m_ctrlStaticTellme.SetFontName (. "System") SetBkColor (RGB (153,204,153)) SetTextColor (RGB (255,0,102)) SetFontSize (20) .FlashBackground (TRUE ) .SetFontBold (TRUE); m_ctrlStaticMail.SetLink (TRUE) .SetTextColor (RGB (0,0,255)) SetFontUnderline (TRUE) .SetFontSize (15) .SetLinkCursor (AfxGetApp () -> LoadCursor (IDC_CURSOR1));. m_ctrlStaticBorder.SetBkColor .. (RGB (051,102,255)) SetTextColor (RGB (255,255,255)) SetFontSize (25) .SetFontBold (TRUE) .SetBorder (TRUE); //borderm_ctrlStaticSuken.SetBkColor(RGB(102,051,255)).SetTextColor(RGB(255,255,255)). SetFontSize (25) .SetFontbold (True) .SetBorder (TRUE) .SETSUNKEN (TRUE); // Suken is big successfully, buil D -> Run, have you been? Please click on the image to enter ◆ Gong Jianwei technology home page ◆ serial port Tongxun (program source), serial debugging assistant, port network communication technology, VC / C programming, mobile robot control related technology, MATLAB simulation and data processing