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/
Floating Text
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!
--== Rapier ==--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Save the whales, feed the hungry, free the mallocs!
--== Rapier ==--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Save the whales, feed the hungry, free the mallocs!
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
============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Well, I would use something like
RECT rect;
GetClientRect(hWnd, ▭);
FillRect(hDC,▭,CreateSolidBrush(0x00FFFFFF)); //Clear screen
DrawText(hDC, text, strlen(text), ▭, 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;
}
RECT rect;
GetClientRect(hWnd, ▭);
FillRect(hDC,▭,CreateSolidBrush(0x00FFFFFF)); //Clear screen
DrawText(hDC, text, strlen(text), ▭, 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;
}
Chris
Hey bravezeus i don''t get this line
text=(text==text1)?text2:text1;
could you explain that to me?
- king171@hotmail.com
- http://www.cfxweb.net/mxf/
text=(text==text1)?text2:text1;
could you explain that to me?
- king171@hotmail.com
- http://www.cfxweb.net/mxf/
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
(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
Chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement