How to change the background color of the dialog in VC6.0

xiaoxiao2021-03-06  22

In front of the yellow base (Guangxi Guilin) ​​- I discussed how to change the color of the control in the "Soft News" 2000, but there is a considerable part of the reader letter: A dialog-based MFC AppWizard application How to change the background color of the dialog box? For this problem, it can actually be implemented by several different methods. The specifically (bolded): ---- Method 1: Call the member function setDialogbkcolor of the CWINAPP class. ---- The first parameter of the function specifies the background color, and the second parameter specifies the text color. The following example is to set the application dialog as a blue background and red text, steps below: ---- 1 New Dialog-based MFC AppWizard application ExampleDLG. ---- 2 Add the following code in Cexampledlgapp :: InitInstance (): Bool CexampledlGapp:: InitInstance () {... CexampledLGDLG DLG; M_PMAINWND = & DLG; // Prevent Domodal () call, set the dialog box to blue background , Red text setDialogbkcolor (RGB (0, 0, 255), RGB (255, 0)); int NRESPONSE = DLG.Domodal (); ...} ---- Compile and run, this time the background color and text of the dialog Color has changed. It is worth noting that SETDIALOGBKCOLOR is called before calling Domodal (), and this method is to change all the dialog colors in the application, and cannot target a specified dialog box. ---- Method 2: Overload OnPaint (), the WM_PAINT message. The relevant code is as follows: Void Cexampledlgdlg :: onpaint () {if (isiconic ()) ... else {create; cpaintdc dc (this); getClientRect (RECT); DC.FillSolidRect (RECT, RGB) 0,255,0)); // Set to green background cdialog :: onpaint ();} - - method 3: Overload OnctLcolor (CDC * PDC, CWND * PWND, UINT NCTLCOLOR), the WM_CTLCOLOR message.

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

New Post(0)