2005. március 1., kedd
Making Any-Shaped Form ( The Hard-Code )
Problem/Question/Abstract:
Wel, this is a hard-coded application, ONLY for people interested in knowing more, it describes another way of doing starnge shaped forms !!
Answer:
Well, Declare these 2 sentences to your PROTECTED declaration
procedure EvEraseBkgnd(var M: tMessage); message WM_ERASEBKGND;
procedure EvNcHitTest(var M: tMessage); message WM_NCHITTEST;
Then Of Course, add them in the body code !!
procedure tForm1.EvEraseBkgnd(var M: tMessage);
begin
{ No Erase Window Background.... }
M.Result := 1;
end;
procedure tForm1.EvNcHitTest(var M: tMessage);
begin
inherited;
{ If Hit in Client Area then simulate hit in Caption Area }
if M.Result = HTCLIENT then
M.Result := HTCAPTION;
end;
make the following OnFormPaint Procedure..
procedure TForm1.FormPaint(Sender: TObject);
var
Buffer: tBitmap;
begin
Buffer := tBitmap.create;
Buffer.LoadFromResourceName(hinstance, 'FORM');
Bitblt(Canvas.handle, 0, 0,
Buffer.width, Buffer.height,
Buffer.canvas.handle, 0, 0,
SrcCopy);
Buffer.free;
end;
And On Your Form, Put Any Buttons Or TEdits Or Anything You Want To Add, Try Your Form, I think it is working just as it used to work all the time, that is true, this is not the secret, the big part is here
OnFormCreate Procedure Needs To Be Added :-))
procedure TForm1.FormCreate(Sender: TObject);
var
Region1: array of tPoint;
Region1hrgn: hRgn;
begin
SetLength(Region1, 59);
Region1[0].X := 12;
Region1[0].Y := 6;
Region1[1].X := 484;
Region1[1].Y := 6;
Region1[2].X := 484;
Region1[2].Y := 7;
Region1[3].X := 486;
Region1[3].Y := 7;
Region1[4].X := 486;
Region1[4].Y := 8;
Region1[5].X := 487;
Region1[5].Y := 8;
Region1[6].X := 487;
Region1[6].Y := 9;
Region1[7].X := 488;
Region1[7].Y := 9;
Region1[8].X := 488;
Region1[8].Y := 10;
Region1[9].X := 489;
Region1[9].Y := 10;
Region1[10].X := 489;
Region1[10].Y := 12;
Region1[11].X := 490;
Region1[11].Y := 12;
Region1[12].X := 490;
Region1[12].Y := 285;
Region1[13].X := 489;
Region1[13].Y := 285;
Region1[14].X := 489;
Region1[14].Y := 287;
Region1[15].X := 488;
Region1[15].Y := 287;
Region1[16].X := 488;
Region1[16].Y := 288;
Region1[17].X := 487;
Region1[17].Y := 288;
Region1[18].X := 487;
Region1[18].Y := 289;
Region1[19].X := 486;
Region1[19].Y := 289;
Region1[20].X := 486;
Region1[20].Y := 290;
Region1[21].X := 484;
Region1[21].Y := 290;
Region1[22].X := 484;
Region1[22].Y := 291;
Region1[23].X := 101;
Region1[23].Y := 291;
Region1[24].X := 100;
Region1[24].Y := 290;
Region1[25].X := 99;
Region1[25].Y := 290;
Region1[26].X := 98;
Region1[26].Y := 289;
Region1[27].X := 97;
Region1[27].Y := 288;
Region1[28].X := 96;
Region1[28].Y := 287;
Region1[29].X := 95;
Region1[29].Y := 286;
Region1[30].X := 95;
Region1[30].Y := 284;
Region1[31].X := 94;
Region1[31].Y := 283;
Region1[32].X := 94;
Region1[32].Y := 200;
Region1[33].X := 93;
Region1[33].Y := 199;
Region1[34].X := 93;
Region1[34].Y := 198;
Region1[35].X := 92;
Region1[35].Y := 197;
Region1[36].X := 91;
Region1[36].Y := 196;
Region1[37].X := 90;
Region1[37].Y := 195;
Region1[38].X := 89;
Region1[38].Y := 194;
Region1[39].X := 88;
Region1[39].Y := 194;
Region1[40].X := 87;
Region1[40].Y := 193;
Region1[41].X := 14;
Region1[41].Y := 193;
Region1[42].X := 13;
Region1[42].Y := 192;
Region1[43].X := 12;
Region1[43].Y := 192;
Region1[44].X := 11;
Region1[44].Y := 191;
Region1[45].X := 10;
Region1[45].Y := 190;
Region1[46].X := 9;
Region1[46].Y := 189;
Region1[47].X := 8;
Region1[47].Y := 188;
Region1[48].X := 8;
Region1[48].Y := 187;
Region1[49].X := 7;
Region1[49].Y := 186;
Region1[50].X := 7;
Region1[50].Y := 184;
Region1[51].X := 6;
Region1[51].Y := 183;
Region1[52].X := 6;
Region1[52].Y := 12;
Region1[53].X := 7;
Region1[53].Y := 11;
Region1[54].X := 7;
Region1[54].Y := 10;
Region1[55].X := 8;
Region1[55].Y := 9;
Region1[56].X := 9;
Region1[56].Y := 8;
Region1[57].X := 10;
Region1[57].Y := 7;
Region1[58].X := 11;
Region1[58].Y := 7;
Region1hrgn := CreatePolygonRgn(Region1[0], 59, 2);
SetWindowRgn(Handle, Region1hrgn, True);
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése