ODBC - CRecordset - CRecordview

Question :

How do i set the color of the edit control? And how to i change the size of the text found in the static control...as well as the background color of the static control.


Regards

Eugene


eugene007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Hi,

U have the those controls on the dialog say CMyDlg.
Then map the WM_CTLCOLOR to that dialog.
And in the function OnCtlColor(...)

....
if(nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetBkColor(editbkcolor);
}
if(nCtlColor == CTLCOLOR_STATIC)
{
return StaticColorbrush;
}

return hbr;
...

Here StaticColorbrush is the CBrush object declared in .h file and created as
StaticColorbrush.CreateSolidBrush(RGB(255,0,0));

Then to set the text size of the static control. U have to do
CFont myfont
//set the desired font to myfont.
((CStatic *)GetDlgItem(ID_STATIC))->SetFont(&myfont);

Thats it.

Hope this helps.
Inpras

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eugene007Author Commented:
hI inpras..i am having a problem to set the size of the text. I have tried this way...but my application keeps displaying an error...that is i have perform an illegal operation.


    CFont myfont;

    VERIFY(myfont.CreateFont(
    12,                        
    0,                        
    0,                        
    0,                        
    FW_NORMAL,                
    FALSE,                    
    FALSE,                    
    0,                        
    ANSI_CHARSET,              
    OUT_DEFAULT_PRECIS,      
    CLIP_DEFAULT_PRECIS,      
    DEFAULT_QUALITY,          
    DEFAULT_PITCH | FF_SWISS,  
    "Arial"));                
   
   //set the desired font to myfont.
   ((CStatic *)GetDlgItem(IDC_STATIC))-
   >SetFont(&myfont);
   


Regards

Eugene
0
eugene007Author Commented:
Another comment:

Its regarding about my static control. I have set my Recordview as white color, but the background color of my static control still remains gray even after i placed this code.


StaticColorbrush.CreateSolidBrush(RGB(255,255,255));

if(nCtlColor == CTLCOLOR_STATIC)
{
   return StaticColorbrush;
}



0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

eugene007Author Commented:
Hi inpras...i manage to solve the problem regarding about the size of the text found in the static control. But i am still unable to change the background color of the static control. It still remains as gray in color.

Regards

Eugene
0
inprasCommented:
Hi,

Check this once
1. U have declared that variable in dialog.h file as CBrush variable.
CBrush StaticColorbrush;

2. Then In OnInitDialog
StaticColorbrush.CreateSolidBrush(RGB(255,255,255));

3. Then OnCtlColor(...)
if(nCtlColor == CTLCOLOR_STATIC)
{
return StaticColorbrush;
}

4. Make sure that for Ur static control, the notify property is set.

Try it out, and let me know the result.
Inpras
0
eugene007Author Commented:
Hi inpras...i tried placing the
CBrush StaticColorbrush variable as a public member in my header file..but my compiler keeps giving me an error. I have also set the notify property for my static control and still it does not work. My static control is in my Record view. Anyway inpras how is my airport reservation application.

Regards

Eugene
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.