Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

King

Floating Text

This topic is 6787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i go about changing text on the screen. and example would be you have a simple window with text from the DrawText() fuction saying "hi this is text #1". I want to be able to press a button and have "hi this is text #1" go away and "blalblablalbla" in its place. I program in C++ windows API, and i''m very new at it. - king171@hotmail.com
- http://www.cfxweb.net/mxf/

Share this post


Link to post
Share on other sites
Advertisement
You need to clear the screen (or window, or whatever) and just draw the new text.

--== Rapier ==--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Save the whales, feed the hungry, free the mallocs!

Share this post


Link to post
Share on other sites
You should use DrawText or TextOut to print text on DC''s. (They''re WinAPI functions)

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

Share this post


Link to post
Share on other sites
Well, I would use something like

RECT rect;
GetClientRect(hWnd, &rect);
FillRect(hDC,&rect,CreateSolidBrush(0x00FFFFFF)); //Clear screen
DrawText(hDC, text, strlen(text), &rect, DT_CENTER);

and then in WndProc put

case WM_ERASEBKGND:
return TRUE;

and

case WM_KEYDOWN:
switch(wParam){
case VK_TAB:text=(text==text1)?text2:text1;
break;
}

Share this post


Link to post
Share on other sites
It's a condensed form of if-else,

(boolean expression)?(statement1) : (statement2);
practically (but not exactly) same as
if(boolean expression)
statement1;
else
statement2;

if the boolean expression is true the whole thing evaluates as statement1 and if the boolean expression is false (else) it evaluates as statement2, here are some examples :

return (x>1)?x:1;
(x>1)?func():func2();

but if you use this remember that statement1 and statement2 must be of the same type (function, int...etc.)

I think it is really useful in some situations like switching something between two values like :

bool x;
x=(x?false:true);

Hope that helps =)

Edited by - BraveZeus on 3/18/00 3:42:42 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!