I got some incoming questions asking about how I created the heart-shaped application in VTL v2.5.
So, here’s the source code to make it happen.
First, put this code in your OnCreate event of your main form :
procedure TForm1.FormCreate(Sender: TObject); var rgnHeart: HRGN; begin rgnHeart:=init_region_utama; SetWindowRgn(Utama.Handle,rgnHeart,TRUE); end;
And this is the exact function to create the shape of heart :
function init_region(jenis: byte): HRGN; type Dotz= record x,y: longint; end; var a: array[1..100] of Dotz; i: integer; begin case jenis of 1 : begin { Heart Utama } i:=1; a[i].x:=254; a[i].y:=459; i:=i+1; a[i].x:=132; a[i].y:=372; i:=i+1; a[i].x:=83; a[i].y:=334; i:=i+1; a[i].x:=55; a[i].y:=306; i:=i+1; a[i].x:=25; a[i].y:=261; i:=i+1; a[i].x:=17; a[i].y:=244; i:=i+1; a[i].x:=9; a[i].y:=221; i:=i+1; a[i].x:=3; a[i].y:=188; i:=i+1; a[i].x:=0; a[i].y:=157; i:=i+1; a[i].x:=1; a[i].y:=122; i:=i+1; a[i].x:=5; a[i].y:=102; i:=i+1; a[i].x:=10; a[i].y:=90; i:=i+1; a[i].x:=29; a[i].y:=60; i:=i+1; a[i].x:=53; a[i].y:=35; i:=i+1; a[i].x:=74; a[i].y:=20; i:=i+1; a[i].x:=104; a[i].y:=6; i:=i+1; a[i].x:=142; a[i].y:=0; i:=i+1; a[i].x:=167; a[i].y:=0; i:=i+1; a[i].x:=190; a[i].y:=4; i:=i+1; a[i].x:=212; a[i].y:=12; i:=i+1; a[i].x:=228; a[i].y:=19; i:=i+1; a[i].x:=242; a[i].y:=28; i:=i+1; a[i].x:=254; a[i].y:=41; for i:=24 to 46 do begin a[i].x:=511-(a[47-i].x); a[i].y:=a[47-i].y; end; init_region:=CreatePolygonRgn(a[1],46,ALTERNATE); end; else init_region:=CreateRectRgn(0,0,0,0); end; end; function init_region_utama: HRGN; var rgnTemp1,rgnTemp2: HRGN; begin { Init Heart Region } rgnTemp1:=init_region(1); rgnTemp2:=CreateEllipticRgn(458,10,483,35); CombineRgn(rgnTemp1,rgnTemp1,rgnTemp2,RGN_OR); rgnTemp2:=CreateEllipticRgn(485,10,510,35); CombineRgn(rgnTemp1,rgnTemp1,rgnTemp2,RGN_OR); init_region_utama:=rgnTemp1; end;
The numbers are actually X,Y coordinates. I mapped a heart shaped using a graph mapping software and got these numbers. Of course, you can change them into any shape you want.
Leave A Comment