FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour paste one DC on second DC
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
paste one DC on second DC
Posted: Wed Jun 05, 2024 01:40 PM

Hi,

I need to paste one device context onto another at the specified coordinates. How can I do this?

Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: paste one DC on second DC
Posted: Wed Jun 05, 2024 02:30 PM
you can use StretchBlt API function https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchblt

BOS Taurus of HMG have this :
Code (fw): Select all Collapse
//*****************************************************************************************************************************
//* BT_DRAW_HDC_TO_HDC (hDC1, x1, y1, Width1, Height1, hDC2, x2, y2, Width2, Height2, Mode_Stretch, Action, Color_Transp)
//*****************************************************************************************************************************

// Action
#define BT_HDC_OPAQUE        0
#define BT_HDC_TRANSPARENT   1

HB_FUNC (BT_DRAW_HDC_TO_HDC)
{
   HDC hDC1, hDC2;
   INT x1, y1, Width1, Height1, x2, y2, Width2, Height2;
   INT Mode_Stretch, Action;
   COLORREF color_transp;
   POINT Point;

   hDC1          = (HDC)      HMG_parnl (1);
   x1            = (INT)      hb_parni (2);
   y1            = (INT)      hb_parni (3);
   Width1        = (INT)      hb_parni (4);
   Height1       = (INT)      hb_parni (5);

   hDC2          = (HDC)      HMG_parnl (6);
   x2            = (INT)      hb_parni (7);
   y2            = (INT)      hb_parni (8);
   Width2        = (INT)      hb_parni (9);
   Height2       = (INT)      hb_parni (10);

   Mode_Stretch  = (INT)      hb_parni (11);
   Action        = (INT)      hb_parni (12);
   color_transp  = (COLORREF) hb_parnl (13);


   bt_bmp_adjust_rect (&Width1, &Height1, &Width2, &Height2, Mode_Stretch);   

   //SetStretchBltMode (hDC1, COLORONCOLOR);
   GetBrushOrgEx (hDC1, &Point);
   SetStretchBltMode (hDC1, HALFTONE); 
   SetBrushOrgEx (hDC1, Point.x, Point.y, NULL);

   
   switch (Action)
   {    case BT_HDC_OPAQUE:
             StretchBlt(hDC1, x1, y1, Width1, Height1, hDC2, x2, y2, Width2, Height2, SRCCOPY); 
             break;
        case BT_HDC_TRANSPARENT:
             TransparentBlt(hDC1, x1, y1, Width1, Height1, hDC2, x2, y2, Width2, Height2, color_transp);                                                         
             break;     
        default:
             hb_retl (FALSE);        
             return;
   }

   hb_retl (TRUE);
}
greeting,

Jimmy
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: paste one DC on second DC
Posted: Wed Jun 05, 2024 03:44 PM

Thanks, Jimmy, I'll try.

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: paste one DC on second DC
Posted: Thu Jun 06, 2024 10:24 AM
Jimmy, I compiled your example. References to bt_bmp_adjust_rect and HMG_parnl are not recognized
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: paste one DC on second DC
Posted: Thu Jun 06, 2024 10:38 AM
hi,
Natter wrote:Jimmy, I compiled your example. References to bt_bmp_adjust_rect and HMG_parnl are not recognized
replace HMG_parnl() with hb_parnll()

you will find HB_FUNC( STRETCHBLT ) in Fivewin \source\winapi\bmpdraw.c
greeting,

Jimmy
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: paste one DC on second DC
Posted: Thu Jun 06, 2024 10:45 AM

Thanks !

Continue the discussion