Set the background color or background image for the dialog box in vc++6.0

Source: Internet
Author: User
Tags set background

/************************************************************ Description: Set the background color or background image for the dialog box in vc++6.0 * Note: Test Code dialog box program name: BJ * Principle: Add code to OnPaint () ***********************************************************///Note: The code takes effect void after removing the comment symbol corresponding TO/* * * * Cbjdlg::onpaint () {if (Isiconic ()) {CPAINTDC DC (this),//device context for painting SendMessage (W M_iconerasebkgnd, (WPARAM) DC.         GETSAFEHDC (), 0);        Center icon in client rectangle int cxicon = GetSystemMetrics (Sm_cxicon);        int cyicon = GetSystemMetrics (Sm_cyicon);        CRect rect;        GetClientRect (&rect); int x = (rect.        Width ()-Cxicon + 1)/2; int y = (rect.         Height ()-Cyicon + 1)/2; Draw the icon DC.    DrawIcon (x, y, M_hicon);        } else {//cdialog::onpaint ();//This line is the original code/* Set Background color: CRect RC;        GetClientRect (&RC);//Get client Area CPaintDC DC (this); dc.   Fillsolidrect (&RC, RGB (0,160,0));        Fill customer Area color cdialog::onpaint (); */* Set background Image://cdialog::onpaint ();//To disallow this call CPaintDC DC (this);           CRect rect;           GetClientRect (&rect);           CDC Dcmem;           Dcmem.createcompatibledc (&DC);           CBitmap Bmpbackground;  Bmpbackground.loadbitmap (IDB_BITMAP3);           IDB_BITMAP3 is a bitmap resource BITMAP BITMAP;           Bmpbackground.getbitmap (&BITMAP);         CBitmap *pbmpold=dcmem.selectobject (&bmpbackground); dc. StretchBlt (0,0,rect. Width (), Rect.           Height (), &dcmem,0,0, bitmap.bmwidth,bitmap.bmheight,srccopy); */             }  }

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Set the background color or background image for the dialog box in vc++6.0

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.