Miguel Angel Torres Master


Registrado: 23 Abr 2006Mensajes: 282Ubicación: Siegen, Alemania
|
Publicado: Vie 02 Jun, 2006 1:14 pm Asunto: Código del Skin.... |
|
|
Este código lo encuentras aquí en el foro.Primero agrega esto:
Luego en el .h agrega esto
| Código: |
__published: // IDE-managed Components
TImage *Image1;
TBitBtn *BitBtn1;
void __fastcall Cargarskin1Click(TObject *Sender);
void __fastcall Image1MouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
void __fastcall BitBtn1Click(TObject *Sender);
void __fastcall FormShow(TObject *Sender);
void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
private: // User declarations
void __fastcall BitmapToRgn(void);
|
Ya en el cpp metes esto:
| Código: |
void __fastcall TForm1::BitmapToRgn(void)
{
//Graphics::TBitmap *bmp = dynamic_cast<Graphics::TBitmap*>(Image1->Picture->Bitmap);
Graphics::TBitmap *bmp = Image1->Picture->Bitmap;
bmp->HandleType = bmDIB;
bmp->PixelFormat = pf32bit;
SetBounds(Left, Top, bmp->Width, bmp->Height);
Image1->Width = bmp->Width;
Image1->Height = bmp->Height;
Brush->Bitmap = bmp;
DWORD colorTransparente = static_cast<DWORD*>(bmp->ScanLine[bmp->Height-1])[0];
//DWORD colorTransparente = static_cast<DWORD>(RGB(255,255,255));
HRGN rgn, rgnTemp;
int ancho = 0;
rgn = CreateRectRgn(0, 0, Width, Height);
rgnTemp = CreateRectRgn(0, 0, Width, Height);
CombineRgn(rgn, rgn, rgnTemp, RGN_DIFF);
DeleteObject(rgnTemp);
for (int y=0; y<Height; ++y)
{
DWORD *pixel = static_cast<DWORD*>(bmp->ScanLine[y]);
for (int x=0; x<=Width; ++x)
{
if (x != Width && pixel[x] != colorTransparente)
ancho++;
else
if (ancho > 0)
{
rgnTemp = CreateRectRgn(x-ancho, y, x, y+1);
CombineRgn(rgn, rgn, rgnTemp, RGN_OR);
DeleteObject(rgnTemp);
ancho = 0;
}
}
}
SetWindowRgn(Handle, rgn, true);
DeleteObject(rgn);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::Cargarskin1Click(TObject *Sender)
{
std::auto_ptr<TOpenPictureDialog> dlgOpen(new TOpenPictureDialog(0));
if (dlgOpen->Execute())
{
/******
if (!CompareText(ExtractFileExt(OpenPictureDialog1->FileName), ".jpg"))
{
TJPEGImage *jpg = new TJPEGImage;
Graphics::TBitmap *bmp = new Graphics::TBitmap;
jpg->LoadFromFile(OpenPictureDialog1->FileName);
bmp->Width = jpg->Width;
bmp->Height = jpg->Height;
bmp->Canvas->Draw(0, 0, jpg);
Image1->Picture->Graphic = bmp;
delete bmp;
delete jpg;
}
else
******/
Image1->Picture->LoadFromFile(dlgOpen->FileName);
BitmapToRgn();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if (Button == mbLeft)
{
ReleaseCapture();
Perform(WM_SYSCOMMAND, 0xF012, 0);
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
Left = (Screen->Width - Width) / 2;
Top = (Screen->Height - Height) / 2;
AnimateWindow(Handle, 1500, AW_BLEND | AW_ACTIVATE);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
//para que cierre por los bordes
// AnimateWindow(Handle, 500, AW_HOR_POSITIVE | AW_VER_NEGATIVE | AW_HIDE);
//Para que cierre lentamente
Form1->Show();
AnimateWindow (Form1->Handle,2000,AW_BLEND | AW_HIDE );
}
//---------------------------------------------------------------------------
|
y listo, suerte..... _________________ Entre más sé, sé que nada sé
----------------------------------
Miguel Angel Torres Arredondo
Siegen - Deutschland |
|