NO

Author Topic: The WM_PAINT Message (modified)  (Read 3531 times)

grom-it

  • Guest
The WM_PAINT Message (modified)
« on: May 06, 2008, 12:09:46 AM »
In my Main_OnPaint

static void Main_OnPaint(HWND hwnd)
   {

PAINTSTRUCT ps;
RECT rc;
HDC hdc;
      // HANDLE TO DEVICE CONTEXT FOR GRAPHICS
HPEN hpen_ThinBlack,hpenOld; // pen handles
int xcount=0; // keeping count of drawing operations
int startpointx,startpointy; // point at which to start drwaing
int curx,cury,curwidth,curhite; // current point in drawing
int scaledw,scaledh; // scaled width and hite

GetClientRect(hwnd, &rc);
BeginPaint(hwnd,  &ps);
EndPaint(hwnd, &ps);  // if i dont d this i cant get about dialog to dissapear


   if (g_bmydrawmode==TRUE)
   {
   PAINTSTRUCT ps;
   hdc=BeginPaint(hwnd,  &ps);

   hpen_ThinBlack=CreatePen(PS_SOLID,2, RGB(139, 35, 35));  // thin black pen
   hpenOld=SelectObject(hdc, hpen_ThinBlack); // remember the  old pen
   SelectObject(hdc,hpen_ThinBlack);
Rectangle(hdc,startpointx,startpointy, startpointx+scaledw,startpointy+scaledh);


   
   do{
   xcount++;
   
     switch (g_iframepartid[xcount]) // going through the already entered input
          {
      case  TOP:   
      Rectangle(hdc,startpointx+10,startpointy+10, startpointx+scaledw,startpointy+scaledh);
      break;   
      case  LEFT:   
      Rectangle(hdc,startpointx,startpointy, startpointx+scaledw,startpointy+scaledh);
      break;
      
      case  RIGHT:
      Rectangle(hdc,startpointx,startpointy, startpointx+scaledw,startpointy+scaledh);
      break;
            }// end of switch


}
   while (xcount<g_ipartidcount );
   //put back original pen and destroy one i have finished with
   SelectObject(hdc, hpenOld);
     DeleteObject(hpen_ThinBlack);
      
EndPaint(hwnd,  &ps);

   }// end of if


   } //end of func


In my Main_OnCommand(......

I have this
case IDC_NEXTDRAWBUT :
   g_bmydrawmode=TRUE;
    RedrawWindow(hwnd,NULL,NULL, RDW_INTERNALPAINT |     
              RDW_ALLCHILDREN | RDW_INVALIDATE);
   UpdateWindow(hwnd);
   g_bmydrawmode=FALSE;

Having tried every variation i can think of
from UpdateWindow to Redraw and others  i cannot get my NEXTDRAWBUTTON to
fire a WM_PAINT

However if i call up an about dialog. After this clears the rectangle is shown.

in fact any other window like messagebox that appears over the drawing that has been executed but not shown will make drawing appear when said box is closed.
but i cant for the life of me work out where i am going wrong
so any help would be appreciated.
« Last Edit: May 06, 2008, 11:29:01 PM by grom-it »

Synfire

  • Guest
Re: The WM_PAINT Message (modified)
« Reply #1 on: May 08, 2008, 10:52:12 PM »
Try this:

Code: [Select]
case IDC_NEXTDRAWBUT :
   RECT rct;
   g_bmydrawmode=TRUE;
   GetClientRect ( hwnd, &rct );
   InvalidateRect ( hwnd, &rct, TRUE );
   g_bmydrawmode=FALSE;

grom-it

  • Guest
Re: The WM_PAINT Message (modified)
« Reply #2 on: May 26, 2008, 10:01:47 AM »
ThankYou Bryant                                             :)
Sorry havent replied sooner
That did make me think a lot harder

It works a treat in my new version
However The main problem was
g_bmydrawmode==FALSE
It
Simply stopped my process from redrawing any painted over items when a dialog was called.
i am now using a different method.
But with your code to force a repaint .
Once again Many Thanks                                  :)