changing the dialog background color

Hi,

I would like to change the dialog background color. Using the help, I called 
the 
function----SetDialogBkColor(RGB(0,0,255),RGB(255,0,0))-----in the function 
InitInstance(), but it didn't work. The function already existed in the 
project:

BOOL CFindDate::InitIstance()
{
     InitCommonControls();

     CWinApp::InitInstance();

    if (!AfxOleInit())
    {
         AfxMessage(IDP_OLE_INIT_FAILED);
         return FALSE;
    }

    // Here I added the call to the function
    SetDialogBkColor(RGB(0,174, 174), RGB(255, 0, 0));


   AfxEnableControlContainer();


// and more things that were written


    return TRUE;
}

What is wrong with it?

Thanks a lot,
Liat
0
liat_oren (16)
1/4/2005 10:37:04 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
1190 Views

Similar Articles

[PageSpeed] 3

IIRC, SetDialogBkColor is obsolete. You can do it in OnCtlColor or you
can use CWinApp::SetDialogBkColor(this changes color of all dialogs).

--------
Ajay Kalra
ajaykalra@yahoo.com


Liat wrote:
> Hi,
>
> I would like to change the dialog background color. Using the help, I
called
> the
> function----SetDialogBkColor(RGB(0,0,255),RGB(255,0,0))-----in the
function
> InitInstance(), but it didn't work. The function already existed in
the
> project:
>
> BOOL CFindDate::InitIstance()
> {
>      InitCommonControls();
>
>      CWinApp::InitInstance();
>
>     if (!AfxOleInit())
>     {
>          AfxMessage(IDP_OLE_INIT_FAILED);
>          return FALSE;
>     }
>
>     // Here I added the call to the function
>     SetDialogBkColor(RGB(0,174, 174), RGB(255, 0, 0));
>
>
>    AfxEnableControlContainer();
>
>
> // and more things that were written
>
>
>     return TRUE;
> }
> 
> What is wrong with it?
> 
> Thanks a lot,
> Liat

0
ajaykalra (6842)
1/4/2005 1:51:15 PM
On Tue, 4 Jan 2005 02:37:04 -0800, "Liat" <liat_oren@yahoo.co.uk> wrote:

>Hi,
>
>I would like to change the dialog background color. Using the help, I called 
>the 
>function----SetDialogBkColor(RGB(0,0,255),RGB(255,0,0))-----in the function 
>InitInstance(), but it didn't work. The function already existed in the 
>project:
>
>BOOL CFindDate::InitIstance()
>{
>     InitCommonControls();
>
>     CWinApp::InitInstance();
>
>    if (!AfxOleInit())
>    {
>         AfxMessage(IDP_OLE_INIT_FAILED);
>         return FALSE;
>    }
>
>    // Here I added the call to the function
>    SetDialogBkColor(RGB(0,174, 174), RGB(255, 0, 0));
>
>
>   AfxEnableControlContainer();
>
>
>// and more things that were written
>
>
>    return TRUE;
>}
>
>What is wrong with it?
>
>Thanks a lot,
>Liat

Override CWnd::OnEraseBkgnd in your dialog class and paint the background
yourself. Here's a snippet from my project that you can use as a guide if you
need it.

BOOL CMultiView2::OnEraseBkgnd(CDC* pDC)
{
	CRect	rect;
	CBrush	patBrush;
	App * app = ((App*)AfxGetApp());

	//patBrush.CreatePatternBrush(&app->m_PatBM);
	patBrush.CreateSolidBrush(RGB(0,0,0));
	GetClientRect(&rect);
	pDC->SaveDC();
	pDC->SelectObject(&patBrush);
	pDC->Rectangle(&rect);
	pDC->RestoreDC(-1);
	return TRUE;
}

0
dju1 (13)
1/5/2005 4:06:14 AM
On Tue, 4 Jan 2005 02:37:04 -0800, "Liat" <liat_oren@yahoo.co.uk> wrote:

>Hi,
>
>I would like to change the dialog background color. Using the help, I called 
>the 
>function----SetDialogBkColor(RGB(0,0,255),RGB(255,0,0))-----in the function 
>InitInstance(), but it didn't work. The function already existed in the 
>project:
>
>BOOL CFindDate::InitIstance()
>{
>     InitCommonControls();
>
>     CWinApp::InitInstance();
>
>    if (!AfxOleInit())
>    {
>         AfxMessage(IDP_OLE_INIT_FAILED);
>         return FALSE;
>    }
>
>    // Here I added the call to the function
>    SetDialogBkColor(RGB(0,174, 174), RGB(255, 0, 0));
>
>
>   AfxEnableControlContainer();
>
>
>// and more things that were written
>
>
>    return TRUE;
>}
>
>What is wrong with it?
>
>Thanks a lot,
>Liat

(Dup: had problem posting. Hope this works now)

Override CWnd::OnEraseBkgnd in your dialog class and paint the background
yourself. Here's a snippet from my project that you can use as a guide if you
need it.

BOOL CMultiView2::OnEraseBkgnd(CDC* pDC)
{
	CRect	rect;
	CBrush	patBrush;
	App * app = ((App*)AfxGetApp());

	//patBrush.CreatePatternBrush(&app->m_PatBM);
	patBrush.CreateSolidBrush(RGB(0,0,0));
	GetClientRect(&rect);
	pDC->SaveDC();
	pDC->SelectObject(&patBrush);
	pDC->Rectangle(&rect);
	pDC->RestoreDC(-1);
	return TRUE;
}

0
dju1 (13)
1/5/2005 4:09:34 AM
Thank you very much for your answer.

I just have a problem finding the OnEraseBkgnd function in the override 
functions list that appears in the properties of the view class.

Could you please tell me how come it doesn't appear there?

Thanks a lot,
Liat

"dju@nospam.comm" wrote:

> On Tue, 4 Jan 2005 02:37:04 -0800, "Liat" <liat_oren@yahoo.co.uk> wrote:
> 
> >Hi,
> >
> >I would like to change the dialog background color. Using the help, I called 
> >the 
> >function----SetDialogBkColor(RGB(0,0,255),RGB(255,0,0))-----in the function 
> >InitInstance(), but it didn't work. The function already existed in the 
> >project:
> >
> >BOOL CFindDate::InitIstance()
> >{
> >     InitCommonControls();
> >
> >     CWinApp::InitInstance();
> >
> >    if (!AfxOleInit())
> >    {
> >         AfxMessage(IDP_OLE_INIT_FAILED);
> >         return FALSE;
> >    }
> >
> >    // Here I added the call to the function
> >    SetDialogBkColor(RGB(0,174, 174), RGB(255, 0, 0));
> >
> >
> >   AfxEnableControlContainer();
> >
> >
> >// and more things that were written
> >
> >
> >    return TRUE;
> >}
> >
> >What is wrong with it?
> >
> >Thanks a lot,
> >Liat
> 
> Override CWnd::OnEraseBkgnd in your dialog class and paint the background
> yourself. Here's a snippet from my project that you can use as a guide if you
> need it.
> 
> BOOL CMultiView2::OnEraseBkgnd(CDC* pDC)
> {
> 	CRect	rect;
> 	CBrush	patBrush;
> 	App * app = ((App*)AfxGetApp());
> 
> 	//patBrush.CreatePatternBrush(&app->m_PatBM);
> 	patBrush.CreateSolidBrush(RGB(0,0,0));
> 	GetClientRect(&rect);
> 	pDC->SaveDC();
> 	pDC->SelectObject(&patBrush);
> 	pDC->Rectangle(&rect);
> 	pDC->RestoreDC(-1);
> 	return TRUE;
> }
> 
> 
0
liat_oren (16)
1/11/2005 4:53:05 PM
Dear Kalra,

Thank you very much for your answer. Should I write 
CWinApp::SetDialogBkColor(RGB(0,0,255),RGB(255,0,0)); in the OnCtlColor 
function?

I did it and got an error message saying "'CWinApp::SetDialogBkColor' : 
cannot access protected member declared in class 'CWinApp'"

What should I do?

Thanks a lot,
Liat

"Ajay Kalra" wrote:

> IIRC, SetDialogBkColor is obsolete. You can do it in OnCtlColor or you
> can use CWinApp::SetDialogBkColor(this changes color of all dialogs).
> 
> --------
> Ajay Kalra
> ajaykalra@yahoo.com
> 
> 
> Liat wrote:
> > Hi,
> >
> > I would like to change the dialog background color. Using the help, I
> called
> > the
> > function----SetDialogBkColor(RGB(0,0,255),RGB(255,0,0))-----in the
> function
> > InitInstance(), but it didn't work. The function already existed in
> the
> > project:
> >
> > BOOL CFindDate::InitIstance()
> > {
> >      InitCommonControls();
> >
> >      CWinApp::InitInstance();
> >
> >     if (!AfxOleInit())
> >     {
> >          AfxMessage(IDP_OLE_INIT_FAILED);
> >          return FALSE;
> >     }
> >
> >     // Here I added the call to the function
> >     SetDialogBkColor(RGB(0,174, 174), RGB(255, 0, 0));
> >
> >
> >    AfxEnableControlContainer();
> >
> >
> > // and more things that were written
> >
> >
> >     return TRUE;
> > }
> > 
> > What is wrong with it?
> > 
> > Thanks a lot,
> > Liat
> 
> 
0
liat_oren (16)
1/11/2005 4:53:06 PM
Reply:

Similar Artilces:

Auto change formula in cells when source is changed
Good day experts; If specific cells have the same formula for example: C1 = Product( A1;B1) C16 = Product(A16;B16) C17= Product(A17;B17) And so on ... What formula should i write in C16, C17, ... so that: when the formula in the source cell, C1, is changed the formulas in C16, C17, ... would automatically change accordingly. I tried "=C1" it does not work Thanks in advance Carlo carlo wrote: > Good day experts; > > If specific cells have the same formula for example: > C1 = Product( A1;B1) > C16 = Product(A16;B16) > C17= Product(A17;B17) > And so on ... ...

Font Color codes
Hi, It someboby know the colors code for required (red) and recomended (blue) field? Thanks, Sylvie Required (Red):#990000; Desired (Blue):#000099; More info: http://msdn.microsoft.com/library/en-us/CrmSdk1_2/htm/v1d2stylesheet.asp?frame=true Hope this helps. []'s Vin�cius Pitta Lima de Ara�jo "Si" <anonymous@discussions.microsoft.com> escreveu na mensagem news:283eb01c46430$aa869110$a401280a@phx.gbl... > Hi, > > It someboby know the colors code for required (red) and > recomended (blue) field? > > Thanks, > > Sylvie WOW, exactly what I ne...

Unable to create a dialog box in MFC Extension DLL.
Hi all, I am trying to create MFC Extension DLL using VS 2005. 1. First I have created a project of type MFC Extension DLL. 2. Then I added a dialog box with a text box, static text control and buttons. 3. Then added a class for that dialog. 4. In dialog's header file I inserted AFX_EXT_CLASS, manually. class AFX_EXT_CLASS CLogonParamDlg : public CDialog 5. Then built and got .lib and .dll files. 1. In my client application, just commented ENUM line of dialog's header file of MFC Extension DLL , as below. (In client its not necessary and to avoid compiler errro...

how to produce toolbar icons with a common background? #2
I would like to create a common background for all icons in the toolbar. In particular, I would like a common background that starts with a light grey at the top and that then becomes progressively darker at lower levels of the icon. I've used an icon editor to extract a icon from programs that have a common icon background. The extracted icons contain only the icon image but not the common background. This indicates the common icon background is implemented separatedly from the icon drawing. Can anyone describe how a common icon background is implemented? Thanks in advance. Ia...

Changing a text field to a date field
Hi I know this is a problem for lots of people but I still cant find an answer. I have imported a text file into excel with a number field that displays credit card expiry dates as a 4 digit number. example 0408 so month + year. I have converted the number field to a text field so it doesnt drop off the first zero and now I need to convert it to a date field. Any nice easy simple ideas. Any help would be much appreaciated. Or direction to a question the same. Perhaps =DATE(100+RIGHT(A1,2),LEFT(A1,2),1) format as date -- daddylonglegs --------------------------------------------...

Please Help: Toolbars in DLL Dialog
Hello, Creating toolbars in an EXE app is a relative piece of cake. However, I am trying to insert a toolbar into a DLL dialog. This is how my DLL dialog works: 1) Contents of a function exporting a dialog AFX_MANAGE_STATE(AfxGetStaticModuleState()); CSvg* dlg; try { dlg = new CSvg(); dlg->Create(IDD_MAIN_FRAME); dlg->ShowWindow(SW_SHOW); } catch (CSvg *dlg) { dlg->PostNcDestroy(); delete dlg; } 2) Use a function in my Dialog class to insert a toolbar: int CSvg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -...

Problem changing wallpaper on Vista
I am trying to change the wallpaper on Vista. I have a sub that works on XP with .jpg and .bmp images... Private Sub SetActiveDesktopWallpaper(ByVal sFileName As String, ByVal lStyle As Long, ByVal fForce As Boolean) Dim ad As ActiveDesktop Dim co As COMPONENTSOPT Dim wpo As WALLPAPEROPT Set ad = New ActiveDesktop 'check if AD is enabled co.dwSize = Len(co) ad.GetDesktopItemOptions co, 0& With wpo .dwSize = Len(wpo) .dwStyle = lStyle End With With ad ' set wallpaper style... .SetWallpaperOpt...

coloring in rows
Hi Could somebody please help me with the following problem? How do I set a conditional format that if L5,M5, or N5 = �BAD� the highlight the row yellow, otherwise leave it the standard non fil color (clear) Thanks Andre -- kob ----------------------------------------------------------------------- koba's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2863 View this thread: http://www.excelforum.com/showthread.php?threadid=48371 Select Row 5. Format> Conditional Formatting. Formula is: =OR($L5="Bad",$N5="Bad",$M5="Bad") Set ...

Statment of changes in financial position
i will be a demo of GP 10 on Weds for a customer who has a requirement for a statement of changes in financial position. Is there any reason that this would be a problem in FRx as long as i know what GL accounts make up each row? Their sales and receivables are going to be maintained in another systmer - with that system providing a journal entry either weekly or monthly. THanks! Andrea: How did this come out for you, also have you done a Schedule of Changes Report?? Pretty standard non-profit reports. "Andrea Smiley" wrote: > i will be a demo of GP 10 on Weds for a cus...

Corporate Name Change
How does one change the name of a stock (and symbol) when a company (such as AOL) decides to do so Wade: Select AOL from your portfolio, right click and choose "see details" You can rename it and change the symbol there. Kevin "Wade" <anonymous@discussions.microsoft.com> wrote in message news:023701c395d4$c6129da0$a401280a@phx.gbl... > How does one change the name of a stock (and symbol) when > a company (such as AOL) decides to do so Thanks ... I get an error stating the ticker is already in use. How can I get around this (is there a global ticker li...

changing sort order
I have followed the TK "How to BCP Data Out and Back into a New Database (875179)" a few times and it seems to work great. However, when bcp'ng the data back in, I do notice some errors as it flashes by in the dos screen, however, NONE of the .err files show any size other than 0k. After logging into Great Plains, I do notice that some information is completely missing. I check the tables and they are empty. I checked the in and out bat files and those tables are exported, then imported, the table is empty and its .err file is also blank. If the .err files do not show...

dialog based app & command line
Hello, I'm trying to launch my application with command line arguments, but I received an error, without any identification number of it. The MessageBox tolds me: "Runtime error" "the path to my exe file" "This application has requested the Runtime to terminate it in an unusual way. Please contact...". Have somebody a ideea where is the problem? Thank you a lot in advance, Alex PS: When I debbutg the appllication with command line args. from project properties the app. starts very well Try setting the start command line options fro...

Changing Exch5.5 GAL columns in Outlook client view
Sorry if the subject line is a bit cryptic; anyway, in the Outlook client, if you display the 'Address Book' you get the following columns - name, business phone, office, title, company, alias, e-mail type, & e-mail address. How do you change it so you show the display name, business, extension, cell phone, & internet email address? Basically, how/where do you change the columnar data the client sees? Thanks, Mike Lawson Mike Goto View | Columns and there u can manage views... KJ "Mike Lawson" wrote: > Sorry if the subject line is a bit cryptic; anyway, i...

how do you make pictures your slide background
iam am trying to make a map of the hundred years war my actual background not tryng to make a picture slideshow in ppt. 2003, in the same way you can change the back ground fill or make a whole new slide design also how do you make i template in ppt. i kinda forgot This should get you started: Design efficiently with masters: http://office.microsoft.com/training/training.aspx?AssetID=RC011536491033 Lucy -- Lucy Thomson PowerPoint MVP MOS Master Instructor www.aneasiertomorrow.com.au "ppthelp" <ppthelp@discussions.microsoft.com> wrote in message ...

Dropdown Size: How do I change?
I have a workbook and after opening it on another computer, all the dropdowns are way too wide. And how can I have them show 20 items rather than the default of 8? Thanks, Craig Right-click the dropdown and you can change the 8 to any other number. To make it less wide, right-click it and drag the right/left border to the size you want. It MAY have something to do with the screen resolution on the other computers...? Bob Umlas "Craig Roberts" <Somewhere @ Lindstrom Minnesota USA> wrote in message news:e4jiOnVPFHA.1268@TK2MSFTNGP14.phx.gbl... >I have a workbook a...

How can I change primary display for presentation on multiple mon.
I want to hit F5 and have my presentation go to a different monitor. I have multiple monitors so my laptop display on a classroom screen. Can I change the default monitor that F5 points to? In article <5A95BBFC-B291-4A05-9E71-3F094B937ABB@microsoft.com>, Shorebilly wrote: > I want to hit F5 and have my presentation go to a different monitor. I have > multiple monitors so my laptop display on a classroom screen. Can I change > the default monitor that F5 points to? In the Slide Show | Set up show dialog, you can choose the monitor you want to display slide s...

pointer changes from arrow to plussign
Somehow the pointer arrow in excel has changed from an arrow to a plus sign. How can I change it back to an a n arrow? That would depend upon where you are pointing the cursor. If anywhere on the cells portion of a worksheet, the cursor is a fat white plus sign. If pointing to menus, toolbars, sheet tabs or scrollbars the cursor should be an arrow. Are you saying your cursor "never" changes to an arrow? Gord Dibben Excel MVP On Wed, 14 Apr 2004 19:15:34 -0700, "gmohanco" <anonymous@discussions.microsoft.com> wrote: >Somehow the pointer arrow in excel has c...

Disabling a CButton in a dialog
Hallo, I want to disable a button directly after clicking on it with this code: void CElternDialog::OnBnClickedEdit() { CButton* pbEdit = (CButton*)GetDlgItem( IDC_EDIT ); pbEdit->EnableWindow( FALSE ); ... GetDlgItem( IDC_NAME1 )->SetFocus(); } At runtime the button text looks 'grayed' and the button is disabled. The focus is in the desired control, but the clicked button has a bold black frame like it is if it were the BS_DEFPUSHBUTTON style. Before clicking the button hadn't the black frame. Is it necessary to 'repaint' the disabled button to prevent...

changing the message list in outlook 2003
i just upgraded from office 2000 to 2003. in the message look in outlook, it separates the messages by date. is there any way to turn this off, so i just have a long list of messages? Right click on the header in the message list, uncheck "show in groups." --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the SWEN virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Lee Benningfield asked: | i just upgraded from office 2000 to 2003. in the mess...

Cell colour change automatically
Is it possible to create a formula to automatically turn a cell a given colour? Example: - If I type the word "Yes" in a cell I would like the cell to turn red automatically, If I type the word "No" in a cell I would like the cell to turn green automatically. Is this possible? If yes please recreate a formula to assist me. Many thanks -=- dustyv Take a look at "Conditional Formatting" in XL Help. In article <45794F52-0D61-4B8F-8562-A3E9E6F957BE@microsoft.com>, dustyv <dustyv@discussions.microsoft.com> wrote: > Is it possible to create a formul...

worksheet background color
I would like to format the individual worksheets with a color for the sheet itself. Is this possible in 2002? thanks for you help and advice Candice Hi! Do you mean you want to color the sheet tabs? Right click the sheet tab, select Tab Color. Biff >-----Original Message----- >I would like to format the individual worksheets with a color for the sheet >itself. Is this possible in 2002? thanks for you help and advice >Candice >. > No, I wanted to color the sheet itself... is that possible? (Thank you for your thoughts) "Biff" wrote: > Hi! > > ...

Changing cell format
I have a worksheet that is populated with data exported from Access. The data in the Access table was serial numbers with an occasional (rare) alpha character. The column was formatted "Text" in Access. When I exported it to Excel, every value in this field (around 3000 entries), has an apostrophe (') inserted at the frontof the cell. Find and Replace does not see the ' How can I remove this so that I can use Fill>Series to populate the gaps in my data (there are many gaps)? Try copying the ' Access character and pasting it into the Replace menu. It could be...

how to change the background color of menu bar
I want to change the background color on the menu bar in excel 2003. Can anyone help me. the color is controlled by Windows. On your desktop, Right click and choose Properties Click the Appearance tab and then choose "Advanced" In the "Item" dropdown choose Menu pick your desired color and click OK, OK NOTE: THIS CHANGE WILL AFFECT ALL WINDOWS APPLICATIONS -- swatsp0p ------------------------------------------------------------------------ swatsp0p's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15101 View this thread: http://www....

range color from date and database
newbie done some homework on excel i would like to have a range change color based on date and time and a name from a database--or any suggestion for example if it is thursday and the time is betweeen 1 and 3 pm i want the range to be say light red if out of tinme range i want it to be light green also the cell above the range as long as time constraints are met to have a name from a datasource any suggestions or ideas apprciated i need to have data from either a database or from say another sheet where user can enter a form the data from the datasource would fill range values a...

verify that a dialog box exists
I want to verify that a dialog box exists before I send it some message. I have a pointer to its object. Can someone remind me please? Thanks George > I want to verify that a dialog box exists before I send it some message. I > have a pointer to its object. > Can someone remind me please? > if(pDlg && pDlg->m_hWnd) { .... } --- Ajay > I want to verify that a dialog box exists before I send it some message. I > have a pointer to its object. > Can someone remind me please? > You can use ASSERT_VALID as well. It works in Debug only but its of great...