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

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
0
whluk
Asked:
whluk
  • 11
  • 5
  • 3
1 Solution
 
chensuCommented:
You need to create a font (CreateFont) and select it into the DC. See the example at

http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/gdi/fontext_8f6t.htm
0
 
whlukAuthor Commented:
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
0
 
whlukAuthor Commented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
whlukAuthor Commented:
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
0
 
nietodCommented:
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.
0
 
whlukAuthor Commented:
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
0
 
chensuCommented:
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);
}
0
 
whlukAuthor Commented:
How about changing the color of the text at the same time?
0
 
nietodCommented:
Use SetTextColor() and SetBkColor()
0
 
chensuCommented:
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);
}
0
 
whlukAuthor Commented:
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
0
 
whlukAuthor Commented:
need help urgently
0
 
nietodCommented:
>> 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.
0
 
whlukAuthor Commented:
need help urgently
0
 
whlukAuthor Commented:
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
0
 
chensuCommented:
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.
0
 
whlukAuthor Commented:
I want to display another dialog box too!! I'm using appwizard exe and is a dialog based program...


thanks
Jacky
0
 
whlukAuthor Commented:
all is fine. Budddy
0
 
chensuCommented:
Then, grade the answer please.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 11
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now