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 45
|
#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);
//typedef long (__declspec(dllimport) *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, 9, 9, LR_LOADFROMFILE | LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS); //
GetObject(hBitmap, sizeof(bitmap), &bitmap);
hDC = GetDC(Form1->Handle);
hdcMem = CreateCompatibleDC(hDC);
SelectObject(hdcMem, hBitmap);
//SetLayeredWindowAttributes(hdcMem, crTransColor, 255, LWA_COLORKEY);
transparentblt ImpFuncDLL;
HINSTANCE msimg = LoadLibrary("C:\\Windows\\System32\\msimg32.dll");
ImpFuncDLL= (transparentblt)GetProcAddress(msimg, "TransparentBlt");
if (ImpFuncDLL)
{
transparentblt(hDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, crTransColor);
Label1->Caption = "ok";
}
//for(int i = 1; i <= 200; i = i+20)
//{
BeginPaint(hDC, &ps);
BitBlt(hDC, 120, 120, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY); // SRCAND NOTSRCCOPY SRCPAINT SRCCOPY
EndPaint(hDC, &ps);
//}
}
//--------------------------------------------------------------------------- |
Partager