"VC Programming Tips" form? 3.4 use bitmap to change the background of the dialog box.

Source: Internet
Author: User

Code:

1. Load bitmap in the dialog initialization function OnInitDialog, and then create a new paint brush.

Cbitmapdemodlgメッセージハンドラーbool Cbitmapdemodlg::oninitdialog () {cdialogex::oninitdialog ();//"バージョン ..." メニューをシステムメニューに Append します. Idm_aboutboxは, システムコマンドの range girth になければなりません. ASSERT ((Idm_aboutbox & 0xfff0) = = Idm_aboutbox); ASSERT (Idm_aboutbox < 0xf000); cmenu* Psysmenu = GetSystemMenu (FALSE); if (psysmenu! = NULL) {BOOL bnamevalid; CString straboutmenu;bnamevalid = straboutmenu.loadstring (Ids_aboutbox); ASSERT (Bnamevalid), if (!straboutmenu.isempty ()) {Psysmenu->appendmenu (mf_separator);p Sysmenu->appendmenu ( Mf_string, Idm_aboutbox, Straboutmenu);}} このダイアログのアイコンを set します. アプリケーションのメインウィンドウがダイアログでない,//Frameworkは, この set the self-occupies line います. SetIcon (M_hicon, TRUE);//Large きいアイコンの set SetIcon (M_hicon, FALSE);//small さいアイコンの set//TODO: initial をここに append します. cbitmap* pbitmap = new CBitmap;      ASSERT (Pbitmap);p bitmap->loadbitmap (Idb_bkground);  Load Bitmapm_bkbrush.createpatternbrush (PBITMAP);//Create Paint brush Delete Pbitmap;return TRUE; フォーカスをコントロールに Set Beauty field in addition to Earpick, Trueを return します. }


2. Add a response function for Windows message wm_ctlcolor.

Hbrush Cbitmapdemodlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nctlcolor) {hbrush HBR = Cdialogex::onctlcolor (PDC, PWnd, nCt Lcolor);//TODO:  ここでdcの Property Slew more してください. TODO:  use したくない は のブラシを return to します. if (nCtlColor = = Ctlcolor_dlg)//The current control is a dialog box, change the Brush return (Hbrush) M_bkbrush.getsafehandle (); return HBR;}



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.