PAINTSTRUCT ps

PAINTSTRUCT ps

Postby Jimmy » Wed Dec 18, 2019 4:26 am

hi,

now i have a big Problem with this HB_FUNC

Code: Select all  Expand view  RUN
HB_FUNC(BMP_PAINT)
{
   HWND hWnd;
   HBITMAP hBitmap;
   HDC memDC, hDC;
   RECT rect;
   RECT aSource;
   BITMAP bm;
   int nMode;

   hWnd     = (HWND)    hb_parnl (1);
   hBitmap  = (HBITMAP) hb_parnl  (2);
   nMode    = hb_parni (3);

   GetClientRect(hWnd, &rect);

458   // hDC = GetDC (hWnd);   // obtine un hDC para toda el area del cliente (se puede pintar en cualquier lugar del area del cliente)
459   PAINTSTRUCT ps;
460   hDC = BeginPaint (hWnd, &ps);  // obtiene un hDC solo para el area invalida (area que debe ser repintada) en un mensaje WM_PAINT

   if (nMode == BMP_ERASE)
       FillRect(hDC,&rect,(HBRUSH) GetSysColorBrush(COLOR_BTNFACE));
   else
   {
       FillRect(hDC,&rect,(HBRUSH) GetSysColorBrush(COLOR_BTNFACE)); // borra la imagen anterior antens de asignar otra

       memDC = CreateCompatibleDC(hDC);

       SelectObject(memDC, hBitmap);

       rect.top    = hb_parnl (4);
       rect.left   = hb_parnl (5);

       if (nMode == BMP_COPY_NORMAL)
      {
          rect.bottom = hb_parnl (6);
          rect.right  = hb_parnl (7);
          BitBlt(hDC, rect.left, rect.top, rect.right, rect.bottom, memDC, 0, 0, SRCCOPY);
      }


       GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);

       if (nMode == BMP_COPY_SCALE)
       {  if ((int) bm.bmWidth * rect.bottom / bm.bmHeight <= rect.right)
            rect.right= (int) bm.bmWidth * rect.bottom / bm.bmHeight;
         else
            rect.bottom = (int) bm.bmHeight * rect.right / bm.bmWidth;

          StretchBlt(hDC, rect.left, rect.top, rect.right, rect.bottom, memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
       }

       if (nMode == BMP_COPY_SPLIT)
       {
          rect.bottom = hb_parnl (6);
          rect.right  = hb_parnl (7);

          aSource.top    = hb_parnl (8);
          aSource.left   = hb_parnl (9);
          aSource.bottom = hb_parnl (10);
          aSource.right  = hb_parnl (11);

          StretchBlt(hDC, rect.left, rect.top, rect.right, rect.bottom, memDC, aSource.left, aSource.top, aSource.right, aSource.bottom, SRCCOPY);
       }

       if (nMode == BMP_COPY_STRETCH)
          StretchBlt(hDC, rect.left, rect.top, rect.right, rect.bottom, memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);

       DeleteDC(memDC);
   }

   //EndPaint (hWnd, hDC); //Elimina el hDC y Valida el area pintada
   ReleaseDC(hWnd, hDC);   //Elimina el hDC pero NO Valida el area pintada
                           //Al no validar el area pintada permite que los procesos de pintura siguientes encadenados puedan usar hDC = BeginPaint (hWnd, &ps);

}
 

i want to STRETCHBLT part of a Bitmap into DC of DIALOG but i got this Error while compile/link

Error E2140 hmg_uhr.prg 459: Declaration is not allowed here in function HB_FUN_BMP_PAINT
*** 1 errors in Compile ***

how to do it with FiveWin when i'm not allowed to use PAINTSTRUCT ps :idea:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: PAINTSTRUCT ps

Postby Antonio Linares » Wed Dec 18, 2019 5:29 am

In C code all variables declarations must go before the code, so please move that line here:

Code: Select all  Expand view  RUN
HB_FUNC(BMP_PAINT)
{
   HWND hWnd;
   HBITMAP hBitmap;
   HDC memDC, hDC;
   RECT rect;
   RECT aSource;
   BITMAP bm;
   int nMode;
   PAINTSTRUCT ps;

   ...
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: PAINTSTRUCT ps

Postby Jimmy » Wed Dec 18, 2019 10:28 pm

Antonio Linares wrote:In C code all variables declarations must go before the code, so please move that line here:

that happens when a Newbie like me copy/paste HB_FUNC code.
Thx for Advice

p.s. can i still use hb_* in HB_FUNC or do i need fw_* Syntax :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: PAINTSTRUCT ps

Postby Antonio Linares » Thu Dec 19, 2019 6:11 am

hb_*
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 83 guests