1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "windows.h"
#include "wingdi.h"
#include <conio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
PAINTSTRUCT ps;
static HDC hDC, hdcMem;
static HBITMAP hBitmap;
static BITMAP bitmap;
COLORREF crTransColor = RGB(0, 0, 0);
typedef long (__cdecl *transparentblt)(HDC,int,int,int,int,HDC,int,int,int,int,UINT);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
hBitmap = LoadImage(NULL, "C:\\Users\\home\\Documents\\Prog_Fraisage\\Bitmap18.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hBitmap, sizeof(bitmap), &bitmap);
hDC = GetDC(Form1->Handle);
hdcMem = CreateCompatibleDC(hDC);
SelectObject(hdcMem, hBitmap);
transparentblt ImpFuncDLL;
HINSTANCE msimg = LoadLibrary("msimg32.dll");
ImpFuncDLL= (transparentblt)GetProcAddress(msimg, "TransparentBlt");
if (ImpFuncDLL)
{
transparentblt(hDC, 120, 120, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, crTransColor);
}
BeginPaint(hDC, &ps);
BitBlt(hDC, 120, 120, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY); // SRCAND NOTSRCCOPY SRCPAINT SRCCOPY
EndPaint(hDC, &ps);
}
//--------------------------------------------------------------------------- |
Partager