|
-
May 6th, 2003, 08:17 AM
#1
Retain text display
I am using pDC->DrawText(str, 20, myRect, DT_RIGHT); to display text in str.
After the window is minimized or another window is on top of it, the text disappears.
What should be done to retain the text display? Thanks in advance for your help.
-
May 6th, 2003, 08:24 AM
#2
Put the code in OnPaint()
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
-
May 6th, 2003, 08:25 AM
#3
You need to put the line
pDC->DrawText(str, 20, myRect, DT_RIGHT);
in the OnPaint function of your CView derived class. Only there will it be redrawn.
-
May 6th, 2003, 08:27 AM
#4
Originally posted by rsmemphis
You need to put the line
pDC->DrawText(str, 20, myRect, DT_RIGHT);
in the OnPaint function of your CView derived class. Only there will it be redrawn.
Might not be a CView, could be a CWnd ...
Just use class wizard to create a message handler for WM_PAINT, then stick the code in there
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
-
May 6th, 2003, 08:55 AM
#5
If I use CStatic instead of pDC->DrawText, there is no need to add codes in OnPaint(). Why??
-
May 6th, 2003, 09:00 AM
#6
CStatic is a static text control, based on a CWnd, so when it gets invalidated, it calls its own redraw function. A radio button, a push button -- all those controls -- are CWnd's that have their own draw/paint routines built into them. When you are drawing lines, though, your application doesn't know if you want them to stay or not when it gets invalidated, because those lines aren't typically there! Taht's why you have to add them yourself to the paint/draw proceedure.
-
May 6th, 2003, 09:01 AM
#7
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
-
May 6th, 2003, 09:28 AM
#8
Thanks guys. Appreciate your answers.
-
May 6th, 2003, 09:37 AM
#9
You can as well insert the line
pDC->DrawText(str, 20, myRect, DT_RIGHT);
in the OnDraw function of your CView derived class
regards
-
May 6th, 2003, 09:46 AM
#10
All these references to CView. He never once said he's using doc/view. It might just be a dlg guys ...
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
-
May 6th, 2003, 09:49 AM
#11
Yes, I am using doc/view. But it is also interesting to see how it can be handled in non-doc/view application.
-
May 6th, 2003, 09:50 AM
#12
The implementation is the same in either case.
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
-
May 6th, 2003, 09:53 AM
#13
I redraw in the OnPaint function. It works. Thanks.
-
May 7th, 2003, 07:03 AM
#14
Hi all,
Another interesting problem I have with DrawText in TRANSPARENT background mode is that when I use DrawText with pDC->SetBkMode(TRANSPRENT) to update a number value stored in CString str, the new number will display on top of the previous displayed numbers. What should I do to clear the area of myRect before display the new number?
Example to illustrate my question:
...
pDC->SetBkMode(TRANSPARENT);
for (int number=0; number<100; number++)
{
str.Format("%i", number);
pDC->DrawText(str, 20, myRect, DT_RIGHT);
}
-
May 7th, 2003, 07:11 AM
#15
I
Code:
HBRUSH hbr = CreateSolidBrush(RGB(0,0,0));
pDC->FillRect(myRect, &hbr);
The RGB value should bve your background color. If you have no control over the background color because it is a windows config specific color, then you can use GetSysColor() to retrieve the RGB you need. This will fill clear the area specified by rect with the background color.
Now redraw your text ...
If your background is not a solid color, such as a bitmap, you will need to redraw the bitmap, then the text.
Jase
www.slideshowdesktop.com
View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|