Link to home
Start Free TrialLog in
Avatar of whluk
whluk

asked on

set the size of the text

How do I change the size of the text
when I use textout?
There are correspounding functions
for setting text colors and changing text alignment and that's it. I would like to change the size of the text.
How?

Thanks
Jacky
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of whluk
whluk

ASKER

sorry for disturbance, chensu
    what i'm using is CPaintDC, so I must use this context to create the text and CPaintDC is not compatible with
HFONT objects... I guess...

Thanks
Jacky
Avatar of whluk

ASKER

I discovered that some of the windows standard class (for text display) don't support 'size' but no 'color' while on the other hand support 'color' but no 'size'.... is there a standard class that supports both?

Thanks
Jacky
Avatar of whluk

ASKER

I discovered that some of the windows standard class (for text display) don't support 'size' but no 'color' while on the other hand support 'color' but no 'size'.... is there a standard class that supports both?

Thanks
Jacky
wluck, why did you delete the previous question?  I did not answer it because I wasn't sure that I was sure I was answering what you were asking.  

>> what i'm using is CPaintDC
On the other questin you said you weren't MFC.  Now you are saying you are.  and my answer to the other question had nothing to do with MFC.

>> CPaintDC is not compatible with
>> HFONT objects
You just create the a CFont object using the static CFont::FromHandle() function.  This can be selected into the DC.

>> I discovered that some of the windows standard
>> class (for text display) don't support
>> 'size' but no 'color' while on the other hand
>> support 'color' but no 'size'.... is there a
>> standard class that supports both?
This sounds like the question you deleted, that's not the question you are asking here.
Avatar of whluk

ASKER

sorry, just don't want to confuse everybody... give me a few hours to think about it...and we will resolve the confusion then...

Thanks
Jacky
void CMyWnd::OnPaint()
{
    CPaintDC dc(this);
    CFont fnt;
    fnt.CreatePointFont(120, _T("Arial"));
    CFont *pOldFont = dc.SelectObject(&fnt);
    dc.TextOut(0, 0 CString(_T("ABC"));
    dc.SelectObject(pOldFont);
}
Avatar of whluk

ASKER

How about changing the color of the text at the same time?
Use SetTextColor() and SetBkColor()
Use CDC::SetTextColor, CDC::SetBkColor and CDC::SetBkMode. Try it out.

void CMyWnd::OnPaint()
{
    CPaintDC dc(this);
    CFont fnt;
    fnt.CreatePointFont(120, _T("Arial"));
    CFont *pOldFont = dc.SelectObject(&fnt);
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(RGB(0, 0, 255));
    dc.TextOut(0, 0 CString(_T("ABC"));
    dc.SelectObject(pOldFont);
}
Avatar of whluk

ASKER

How about locating the text in the middle of the client area. I've learned one function that does that, but i forgot its name...
Btw, How do I make a button react to a mouse left click actions... I'm a sucker
you know...


Thanks
Jacky
Avatar of whluk

ASKER

need help urgently
>> locating the text in the middle of the client
>> area. I've learned one function
>> that does that
There really isn't one that does that.  You can use TextOut() at the right coordinates to center the text or you can use DrawText() and specify the DT_CENTER and DT_VCENTER flags while using a rectangle whose dimensions are the window's client area.

>> How do I make a button react to a mouse
>> left click actions
This is really bejond the bounds of the original question.

you can look for the WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_LBUTTONDBLCLK and conver them to the cooresponding right button messages.  That is, pass the message on to the default window procedure specifying the cooresponding right button message instead of the actual message.
Avatar of whluk

ASKER

need help urgently
Avatar of whluk

ASKER

the ONLBUTTONDOWN message and a function is in place.The second problem being is how do i make it respond to a user's left click action on an 'ok' button...

Thanks
Jacky
void CMyWnd::OnPaint()
{
    CPaintDC dc(this);

    CFont fnt;
    fnt.CreatePointFont(120, _T("Arial"));
    CFont *pOldFont = dc.SelectObject(&fnt);
 
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(RGB(0, 0, 255));
 
    CRect rect;
    this->GetClientRect(&rect);
    CPoint pt = rect.CenterPoint();

    dc.TextOut(pt.x, pt.y, CString(_T("ABC"));

    dc.SelectObject(pOldFont);
}

Please post a new question on the button issue.
Avatar of whluk

ASKER

I want to display another dialog box too!! I'm using appwizard exe and is a dialog based program...


thanks
Jacky
Avatar of whluk

ASKER

all is fine. Budddy
Then, grade the answer please.