#1
  1. Cast down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    321
    Rep Power
    12

    TextOut GDI32, Text over text, how do I remove old text?


    On mousemove, I want the x/y on top left of the screen, my code sort of works.. the text goes over the text so I can't really see the numbers right. how would I remove the old text that was there then put the new x/y locations?
    Code:
    		case WM_MOUSEMOVE: 
    		{
    			HDC hdc; 
    			POINT pt; 
    			PAINTSTRUCT ps; 
    			char txt[200]; 
    			pt.x = LOWORD(lParam); 
    			pt.y = HIWORD(lParam); 
    
    			wsprintf(txt,"x: %d y: %d",pt.x,pt.y); 
    
    			hdc=GetDC(hwnd); 
    
    			SetBkMode(hdc,TRANSPARENT); 
    			SetTextColor(hdc,RGB(200,100,50)); 
    			TextOut(hdc,0,0,txt,strlen(txt)); 
     
    			ReleaseDC(hwnd,hdc); 
    		}
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Try SetBkMode(hdc, OPAQUE); instead of TRANSPARENT.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Cast down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    321
    Rep Power
    12
    That's the default, it will put an ugly background color behind the text, I fixed it just now by doing this.

    But it's a bit messy, I don't like how C doesn't let you declare varaibles `on the fly`:

    Code:
    		case WM_MOUSEMOVE: 
    		{
    			POINT pt; 
    			pt.x = LOWORD(lParam); 
    			pt.y = HIWORD(lParam); 
    			wsprintf(txt,"x: %d y: %d",pt.x,pt.y); 
    			InvalidateRect(hwnd,NULL,1); 
    		}
    
    		case WM_PAINT: 
    		{ 
    			HDC			hdc; 
    			PAINTSTRUCT ps; 
    			if(txt[0])
    			{
    				hdc = BeginPaint(hwnd,&ps); 
    
    				SetBkMode(hdc,TRANSPARENT); 
    				SetTextColor(hdc,RGB(200,100,50)); 
    				TextOut(hdc,0,0,txt,strlen(txt)); 
     
    				EndPaint(hwnd,&ps); 
    			}
    			break; 
    		}

IMN logo majestic logo threadwatch logo seochat tools logo