Тут две ошибки:
1) в функции CreateRgnFromBitmap - первый параметр указатель на битмап, а ты передаешь строку - надо вот так:
Код:
![Выделить весь код](images/misc/selectcode.png)
void __fastcall TForm1::FormCreate(TObject *Sender)
{
POINT pt;
pt.x = 0; pt.y = 0;
Graphics::TBitmap *bmp = new Graphics::TBitmap;
bmp->LoadFromFile("c:\\1.bmp");
HRGN R1=CreateRgnFromBitmap(bmp,pt,true);
SetWindowRgn(Handle, R1, TRUE);
bmp->Free();
}
2) функция CreateRgnFromBitmap реализована ниже чем первый раз используется. Поэтому функция void __fastcall TForm1::FormCreate(TObject *Sender) должна находить ниже ее.
Код:
![Выделить весь код](images/misc/selectcode.png)
HRGN CreateRgnFromBitmap(Graphics::TBitmap *bmp, TPoint pPoint, bool bEqaul = true)
{
int f, x, y;
bool b = false;
HRGN Rgn, ResRgn = CreateRectRgn(0, 0, 0, 0);
for (y = 0; y < bmp->Height; y++)
for (x = 0; x < bmp->Width; x++)
{
if (!bEqaul^(bmp->Canvas->Pixels[x][y] != bmp->Canvas->Pixels[pPoint.x][pPoint.y]))
{
if (!b)
{ f = x; b = true; }
else
if (x == (bmp->Width - 1))
{
Rgn = CreateRectRgn(f, y, x, y + 1);
CombineRgn(ResRgn, ResRgn, Rgn, RGN_OR);
b = false;
}
}
else
if (b)
{
Rgn = CreateRectRgn(f, y, x, y + 1);
CombineRgn(ResRgn, ResRgn, Rgn, RGN_OR);
b = false;
}
}
return ResRgn;
}
//--------------------------------------------------------------------------- */
void __fastcall TForm1::FormCreate(TObject *Sender)
{
POINT pt;
pt.x = 0; pt.y = 0;
Graphics::TBitmap *bmp = new Graphics::TBitmap;
bmp->LoadFromFile("c:\\1.bmp");
HRGN R1=CreateRgnFromBitmap(bmp,pt,true);
SetWindowRgn(Handle, R1, TRUE);
bmp->Free();
}