Home > Archive > Smartphone Developer Forum > April 2006 > How to custom the font and background of control?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to custom the font and background of control?
|
|
| yaxixi 2006-04-19, 4:05 am |
| Hi everyone,
I need to custom the font and background of controls in the dialog,
e.g. the font and background of static text. The dialog I expect is the
same as the dial dialog.
I'm a rookie, please help me to start.
It'd be really appreciate if anyone have any ideal regarding to this subject.
| |
|
| yaxixi wrote:
> Hi everyone,
> I need to custom the font and background of controls in the dialog,
> e.g. the font and background of static text. The dialog I expect is the
> same as the dial dialog.
your trying to reimplment the dialing dialog?
if your referring to the header of the dialing dialog, that's a image,
gif I think.
So LoadImage()/BitBlt(), or you can use the static Image Control with
STM_SETIMAGE.
riki
--
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
Rats are rats, pigeons are rats with wings, and squirrels are rats with
good PR.
| |
| yaxixi 2006-04-19, 10:03 pm |
| I tried to implement the header of dialog througt drawing background and text
in Edit Control. But I came into a new problem that the text color overlap
with the background color.
I also used "SetBKMode( TRANSPARENT )" , but still useless.
What could I do to make the text color separate from the background color?
"riki" wrote:
> yaxixi wrote:
> your trying to reimplment the dialing dialog?
>
> if your referring to the header of the dialing dialog, that's a image,
> gif I think.
> So LoadImage()/BitBlt(), or you can use the static Image Control with
> STM_SETIMAGE.
>
> riki
>
>
> --
> ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
> AbstractStart for Smartphone :
> http://homepages.inspire.net.nz/~gambit/AbstractStart/
>
> Rats are rats, pigeons are rats with wings, and squirrels are rats with
> good PR.
>
| |
|
| yaxixi wrote:
> I tried to implement the header of dialog througt drawing background and text
> in Edit Control. But I came into a new problem that the text color overlap
> with the background color.
> I also used "SetBKMode( TRANSPARENT )" , but still useless.
> What could I do to make the text color separate from the background color?
which API are you using to draw the text? DrawText()? or are you
creating a edit control? SetBKMode() works with DrawText()
riki
--
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
A policeman's job is only easy in a police state.-- Orson Welles
| |
| yaxixi 2006-04-20, 8:06 am |
| I just find my problem was not what I observed. My problem is really that I
couldn't modify the text color of Edit Control with "pDC->SetTextColor()".
My code is:
BOOL CMFCtextDlg::OnInitDialog()
{ ......
((CEdit *)GetDlgItem(IDC_EDIT))->SetWindowTextW(_T(" Welcome"));
......
}
HBRUSH CMFCtextDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{ ......
if( pWnd->GetDlgCtrlID() == IDC_EDIT )
{
pDC->SetTextColor( GetSysColor( COLOR_WINDOWTEXT) );
pDC->SetBkMode( TRANSPARENT );
}
.....
}
"riki" wrote:
> yaxixi wrote:
>
> which API are you using to draw the text? DrawText()? or are you
> creating a edit control? SetBKMode() works with DrawText()
>
> riki
>
>
> --
> ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
> AbstractStart for Smartphone :
> http://homepages.inspire.net.nz/~gambit/AbstractStart/
>
> A policeman's job is only easy in a police state.-- Orson Welles
>
| |
|
| Hope this helps...
case WM_CTLCOLOREDIT:
{
hbr = (HBRUSH) DefWindowProc(hDlg, message, wParam, lParam);
if (!(GetDlgCtrlID((HWND)lParam) == IDC_TEXT))
return (LRESULT) hbr;
SetTextColor ((HDC)wParam,RGB(0,0,0));
SetBkColor((HDC)wParam, RGB(255,255,211));
SetBkMode((HDC)wParam, OPAQUE);
hbr = CreateSolidBrush(RGB(255,255,211));
SetWindowLong(hDlg, DWL_MSGRESULT, (INT) hbr);
return TRUE;
}
-Sai
| |
| yaxixi 2006-04-20, 10:04 pm |
| Thank you for your respond, but your code is the same as my code.
HBRUSH CMFCtextDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if( pWnd->GetDlgCtrlID() == IDC_EDIT1 )
{
pDC->SetTextColor( GetSysColor( COLOR_WINDOW ) );
pDC->SetBkColor(GetSysColor( COLOR_WINDOWFRAME ));
pDC->SetBkMode( OPAQUE );
return m_brushCaption;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
"Sai" wrote:
> Hope this helps...
>
> case WM_CTLCOLOREDIT:
> {
> hbr = (HBRUSH) DefWindowProc(hDlg, message, wParam, lParam);
>
> if (!(GetDlgCtrlID((HWND)lParam) == IDC_TEXT))
> return (LRESULT) hbr;
>
> SetTextColor ((HDC)wParam,RGB(0,0,0));
> SetBkColor((HDC)wParam, RGB(255,255,211));
> SetBkMode((HDC)wParam, OPAQUE);
>
> hbr = CreateSolidBrush(RGB(255,255,211));
>
> SetWindowLong(hDlg, DWL_MSGRESULT, (INT) hbr);
> return TRUE;
> }
>
>
>
> -Sai
>
>
| |
| yaxixi 2006-04-20, 10:04 pm |
| How to set the parameters of LoadImage function? I add a gif image into
project,
the resource ID is "IDR_BRICK_961", but the return value is NULL, the error
code figure that " can't find specified image file". My code is :
((CStatic
*)GetDlgItem(IDC_STATIC))-> SetBitmap(::LoadBitmapW(AfxGetInstanceHa
ndle,
MAKEINTRESOURCE(IDR_BRICK_961)));
The reson is whether the first parameter is error,or not?
hope your help!
"riki" wrote:
> yaxixi wrote:
> your trying to reimplment the dialing dialog?
>
> if your referring to the header of the dialing dialog, that's a image,
> gif I think.
> So LoadImage()/BitBlt(), or you can use the static Image Control with
> STM_SETIMAGE.
>
> riki
>
>
> --
> ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
> AbstractStart for Smartphone :
> http://homepages.inspire.net.nz/~gambit/AbstractStart/
>
> Rats are rats, pigeons are rats with wings, and squirrels are rats with
> good PR.
>
|
|
|
|
|