• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

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


0
eugene007
Asked:
eugene007
  • 4
  • 2
1 Solution
 
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
 
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now