PDA

Click to See Complete Forum and Search --> : Deleting text from DrawText


Phailak
Jan 8th, 2001, 01:48 PM
Hi,

Just want to know if there is a way to delete what one wrote with the API drawText without refreshing the screen or using the autoredraw. See, let's say I write Hello on a form and want it to write Bye in its place when user clicks a button, is there a way to delete Hello and then write again Bye.


Thanx

Phailak

Jan 8th, 2001, 02:41 PM
Using refersh is the easy way, but if you want to erase it using API, I'm guessing you'd have to send the WM_PAINT and WM_ERASEBKGND messages.

Phailak
Jan 9th, 2001, 06:03 AM
Ok, thanx,
Now let's say I have 10 areas define by the Api CreatePolygons and there is some text in each. What if I want to erase the text in one of the areas only, let's say Polygon number 5 (I do have its Rgn coordonates and those of the Rect i created to write my text into)
Can I still use those messages or will that erase the whole background?

Phailak

gwdash
Jan 10th, 2001, 08:44 PM
you can do this ( i have the same problem, but this is my
solution, it works with a Rgn or a Rect structure):
Declares:

Public Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, _
lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal _
fuRedraw As Long) As Long

Public Declare Function RedrawWindowM Lib "user32" Alias "RedrawWindow" (ByVal hwnd As Long, lprcUpdate As _
Long, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As _
Long

Public Declare Function DeleteObject Lib "gdi32" (ByVal _
hObject As Long) As Long


Public Const RDW_INVALIDATE = &H1

Public Const RDW_ERASE = &H4

Public Const RDW_ERASENOW = &H200

Public Const RDW_ALLCHILDREN = &H80


For Regions:

Private Sub ClearMessage(rgnBounding)
Dim retval As Long
RedrawWindowM 0, ByVal 0&, rgnBounding, RDW_INVALIDATE Or _
RDW_ERASE Or RDW_ERASENOW Or RDW_ALLCHILDREN
'refresh screen only on that point
DeleteObject rgnBounding 'delete region
End Sub


For Rects:

Private Sub ClearBox(r As RECT)
RedrawWindow 0, r, ByVal 0&, RDW_INVALIDATE Or RDW_ERASE Or _
RDW_ERASENOW Or RDW_ALLCHILDREN
'refresh screen only on that point
End Sub

Phailak
Jan 11th, 2001, 05:53 AM
Thanx gwdash

I can work with those, it will probably erase my background right? But it doesn't matter, it will be easy to redraw

Phailak

gwdash
Jan 11th, 2001, 06:57 AM
i probably will, but only right behind the text