Results 1 to 4 of 4

Thread: The "WM_PAINT" Message!

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    The "WM_PAINT" Message!

    I want to draw a round region when the move is down on my window. Please Look at the following code:

    Code:
       case WM_LBUTTONDOWN:
    	   InvalidateRgn(hwnd, hrgn, TRUE);
    	   hdc = GetDC(hwnd);
    	   hbrush = CreateSolidBrush(RGB(34,43, 255));
    	   FillRgn(hdc, hrgn, hbrush);
    	   ReleaseDC(hwnd, hdc);
    	   DeleteObject(hbrush); 
    	   ValidateRgn(hwnd, hrgn);
    	   return 0;
    That works fine but whenever, I move another window on top of my region or resize my window, it erases all that stuff and then the only way I can redraw the region is under the WM_PAINT message.

    -- So what is the other way to draw the roundrect only after the mouse is down. I have tried putting this code under WM_pAINT message but it draws the roundrect whenever it is loader because I have included the styles "CS_HREDRAW | CS_VREDRAW"

    Please help me with that!
    Baaaaaaaaah

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I think your only choice would be to make a function(s) that would draw your round region, keep track of its position, is it visable, etc. Then have it called each time by WM_LBUTTONDOWN and/or WM_PAINT.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    if even if I write the function and call it under the wm_paint message then i will draw the roundrect when the window is loaded or painted.
    Is there any other way to do that?
    Baaaaaaaaah

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Originally posted by abdul
    if even if I write the function and call it under the wm_paint message then i will draw the roundrect when the window is loaded or painted.
    No it doesnt, there are a bunch of ways to keep it from painting on load. The easiest way might be a public bool that when set it false does not run the paint. That should keep it from runing on load. But when the user clicks the left mouse button it changes to true. Thus it will run the function. The quickest way would be to add something like this in your paint function.

    PHP Code:
    bool ShouldIPaint;

    void PaintWhatEver()
    {
      if !(
    ShouldIPaint)
        return 
    0;
      
    RestOfCode....
    }

    case 
    WM_LBUTTONDOWN:
      
    ShouldIPaint true;
      
    PaintWhatEver();
      break;

    case 
    WM_PAINT
      PAINTSTRUCT ps
    ;
      
    BeginPaint(hwnd,&ps);
      
    EndPaint(hwnd,&ps);
      
    PaintWhatEver();
      
    DefWindowProc(hwndmsgwParamlParam);
      break; 
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width