Ghost painting

This is a discussion on Ghost painting within the Windows Programming forums, part of the Platform Specific Boards category; I've intercepted the WM_PAINT message for my edit control, and I am drawing my own text in. After drawing, I ...

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Ghost painting

    I've intercepted the WM_PAINT message for my edit control, and I am drawing my own text in. After drawing, I validate and return 0. However, when I click on the control, it erases everything I've done. Using Spy++ I can see that there are no paint or erase background messages being sent. How is it possible then for drawing to occur that I do not know about?

    Code:
    	case WM_PAINT:
    		{
    			HDC hdc=GetDC(hwnd);
    			TextOut(hdc,0,0,"text",4);
    			ReleaseDC(hwnd,hdc);
    			ValidateRect(hwnd,NULL);
    		}
    		return 0;
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I gather you are subclassing the text control. One of the other messages must be causing an internal repaint.

    EM_SETRECT seems to be one such. Have a look here:
    http://msdn.microsoft.com/library/en...ormatting_rect

    Also EM_SETFOCUS seems to be a likely candidate.

    Which features are you hoping to use from the original edit control? If you want the text handling ability (EM_SETSEL, EM_PASTE, etc) you will need to query the edit control for the text to paint. If you don't want these features you may be better off creating a new control.

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Yeah, you're right. I would have thought that WM_PAINT would be the only drawing message, but plenty of others draw as well. If I really need to, I'll eventually create my own control. For now, I'll start a new thread to try find another solution to what I want to do.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 08:28 PM
  2. mouse messages, painting, tabs
    By ZeroG in forum Windows Programming
    Replies: 0
    Last Post: 06-20-2005, 03:51 AM
  3. smoother painting
    By underthesun in forum Windows Programming
    Replies: 2
    Last Post: 01-22-2005, 02:46 AM
  4. Question about painting
    By Ariod in forum Windows Programming
    Replies: 10
    Last Post: 08-24-2003, 01:36 PM
  5. Pacman ghost AI and pills
    By lambs4 in forum Game Programming
    Replies: 3
    Last Post: 11-21-2002, 07:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21