Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program MSIForm;
- const
- PANEL_COUNT = 5;
- PANEL_1 = 0;
- PANEL_2 = 1;
- PANEL_3 = 2;
- PANEL_4 = 3;
- PANEL_5 = 4;
- IMG_COUNT = 23;
- // Used in frmMain
- IMG_BGND = 0;
- IMG_X_NORM = 1;
- IMG_Q_NORM = 2;
- IMG_LOAD_TAB_NORM = 3;
- IMG_SAVE_TAB_NORM = 4;
- IMG_TAB_NORM_1 = 5;
- IMG_TAB_NORM_2 = 6;
- IMG_TAB_NORM_3 = 7;
- IMG_TAB_NORM_4 = 8;
- IMG_LOC_MAP = 9;
- IMG_LOC_NAV = 10;
- IMG_LOC_EXIT_NORM = 11;
- IMG_LOC_BORD_TOP = 12;
- IMG_LOC_BORD_BOTTOM = 13;
- IMG_LOC_BORD_LEFT = 14;
- IMG_LOC_BORD_RIGHT = 15;
- IMG_LOC_BOX_TOP = 16;
- IMG_LOC_BOX_LEFT = 17;
- IMG_LOC_BOX_RIGHT = 18;
- IMG_LOC_BOX_BOTTOM = 19;
- // Used in Panel 0 (Is also used for frmMain)
- IMG_LOC_ICON_NORM = 20;
- IMG_LOC_LABEL = 21;
- IMG_TAB_HINT = 22;
- // Used in Panel 1
- // Used in Panel 2
- // Used in Panel 3
- // Used in Panel 4
- BITMAP_COUNT = 31;
- BGND = 0;
- X_NORM = 1;
- X_HOVER = 2;
- Q_NORM = 3;
- Q_HOVER = 4;
- LOAD_TAB_NORM = 5;
- LOAD_TAB_HOVER = 6;
- SAVE_TAB_NORM = 7;
- SAVE_TAB_HOVER = 8;
- TAB_NORM_1 = 9;
- TAB_HOVER_1 = 10;
- TAB_NORM_2 = 11;
- TAB_HOVER_2 = 12;
- TAB_NORM_3 = 13;
- TAB_HOVER_3 = 14;
- TAB_NORM_4 = 15;
- TAB_HOVER_4 = 16;
- LOC_ICON_NORM = 17;
- LOC_ICON_HOVER = 18;
- LOC_EXIT_NORM = 19;
- LOC_EXIT_HOVER = 20;
- LOC_MAP = 21;
- LOC_NAV = 22;
- LOC_BORD_TOP = 23;
- LOC_BORD_BOTTOM = 24;
- LOC_BORD_LEFT = 25;
- LOC_BORD_RIGHT = 26;
- LOC_BOX_TOP = 27;
- LOC_BOX_LEFT = 28;
- LOC_LABEL = 29;
- TAB_HINT = 30;
- var
- frmMain: TForm;
- time: TTimer;
- tImages: Array[0..IMG_COUNT - 1] of TImage;
- frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;
- isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
- isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
- isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;
- MapDragStartX, MapDragStartY: Integer;
- procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- BoundL, BoundT: Extended;
- begin
- case sender of
- tImages[IMG_LOC_MAP]:
- begin
- MapDragStartX := x;
- MapDragStartY := y;
- end;
- tImages[IMG_LOC_NAV]:
- begin
- GetMousePos(x, y);
- with tImages[IMG_LOC_BOX_TOP] do
- SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);
- if tImages[IMG_LOC_BOX_TOP].Left < 376 then
- tImages[IMG_LOC_BOX_TOP].Left := 376;
- if tImages[IMG_LOC_BOX_TOP].Top < 216 then
- tImages[IMG_LOC_BOX_TOP].Top := 216;
- if tImages[IMG_LOC_BOX_TOP].Left > 494 then
- tImages[IMG_LOC_BOX_TOP].Left := 494;
- if tImages[IMG_LOC_BOX_TOP].Top > 322 then
- tImages[IMG_LOC_BOX_TOP].Top := 322;
- with tImages[IMG_LOC_BOX_LEFT] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
- with tImages[IMG_LOC_BOX_RIGHT] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
- with tImages[IMG_LOC_BOX_BOTTOM] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
- BoundL := -(x - 155 - 376) * 7.234;
- BoundT := -(y - 140 - 216) * 7.234;
- tImages[IMG_LOC_MAP].Left := Round(BoundL);
- tImages[IMG_LOC_MAP].Top := Round(BoundT);
- if tImages[IMG_LOC_MAP].Left > 0 then
- tImages[IMG_LOC_MAP].Left := 0;
- if tImages[IMG_LOC_MAP].Top > 0 then
- tImages[IMG_LOC_MAP].Top := 0;
- if tImages[IMG_LOC_MAP].Left < -345 then
- tImages[IMG_LOC_MAP].Left := -345;
- if tImages[IMG_LOC_MAP].Top < -354 then
- tImages[IMG_LOC_MAP].Top := -354;
- end;
- end;
- end;
- var sended: Tobject;
- move, accel, cons: integer;
- procedure TimerTabClick(Sender: TObject);
- var
- senderTab, i, CurrentPanel: Integer;
- begin
- for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
- if (Sended = tImages[i]) then
- senderTab := i;
- if not(isLeftTab[senderTab]) then
- begin
- for i := IMG_TAB_NORM_1 to senderTab do
- begin
- if not(isLeftTab[i]) then
- begin
- tImages[i].Left := tImages[i].Left - accel;
- if move = 0 then
- cons := tImages[i].Left;
- accel := accel + 2;
- move:= move + accel;
- end;
- if move >= 380 then
- begin
- tImages[i].Left := cons - 380;
- isLeftTab[i] := True;
- move := 0;
- time.ENABLED := false;
- end;
- end;
- CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
- end else
- begin
- for i := IMG_TAB_NORM_4 downto senderTab do
- begin
- if (isLeftTab[i]) then
- begin
- tImages[i].Left := tImages[i].Left + accel;
- if move = 0 then
- cons := tImages[i].Left;
- accel := accel + 2;
- move := move + accel;
- end;
- if move >= 380 then
- begin
- tImages[i].Left := cons + 380;
- isLeftTab[i] := False;
- move := 0;
- time.ENABLED := false;
- end;
- end;
- CurrentPanel := sendertab - IMG_TAB_NORM_1;
- end;
- for i := PANEL_1 to PANEL_5 do
- begin
- if i = CurrentPanel then
- isActivePanel[i] := True
- else
- isActivePanel[i] := False;
- end;
- WriteLn(CurrentPanel);
- for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
- tImages[i].Visible := isActivePanel[PANEL_1];
- end;
- procedure TabClick(Sender: TObject);
- begin
- if not time.ENABLED then
- begin
- accel := 0;
- time.enabled := not time.enabled;
- sended := Sender;
- end;
- end;
- procedure LocViewer(Sender: TObject);
- var i: Integer;
- begin
- case Sender of
- tImages[IMG_LOC_ICON_NORM]:
- begin
- for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
- tImages[i].Visible := True;
- for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
- tImages[i].Visible := False;
- end;
- tImages[IMG_LOC_EXIT_NORM]:
- begin
- for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
- tImages[i].Visible := False;
- for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
- tImages[i].Visible := isActivePanel[PANEL_1];
- end;
- end;
- end;
- procedure Clicked(Sender: TObject);
- var
- i: Integer;
- begin
- for i := 0 to BITMAP_COUNT - 1 do
- FreeBitmap(frmBitmaps[i]);
- frmMain.ModalResult := mrOk;
- end;
- procedure OutsideBox(l,t,r,b, obj: integer);
- begin
- if tImages[obj].Left > l then
- tImages[obj].Left := l;
- if tImages[obj].Top > t then
- tImages[obj].Top := t;
- if tImages[obj].Left < r then
- tImages[obj].Left := r;
- if tImages[obj].Top < b then
- tImages[obj].Top := b;
- end;
- procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
- var
- hi, i, bmp, xdif, ydif, h: Integer;
- BoundL, BoundT: Extended;
- imgSwap, bmpArr, imgArr: Array of Integer;
- begin
- bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
- SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
- TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]
- imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
- IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
- IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
- case Sender of
- tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
- begin
- {bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
- SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
- TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]
- imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
- IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
- IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ] }
- hi := High(bmpArr);
- for i := 0 to hi do
- begin
- if (not isActiveImage[imgArr[i]]) then
- Continue;
- bmp := frmBitmaps[bmpArr[i]];
- DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
- isActiveImage[imgArr[i]] := False;
- end;
- end;
- end;
- for h := 1 to 10 do
- begin
- i := 2 * h;
- case Sender of
- tImages[h]:
- begin
- imgSwap := [h, frmBitmaps[i]];
- if not (isActiveImage[imgSwap[0]]) then
- begin
- DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
- {imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
- IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
- IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM];}
- writeln(inttostr(imgSwap[0]) + ' ' + inttostr(imgSwap[1]));
- bmp := frmBitmaps[h];
- DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
- end;
- end;
- end;
- end;
- case sender of
- tImages[IMG_LOC_MAP]:
- begin
- if not IsMouseButtonDown(1) then exit;
- xdif := x - MapDragStartX;
- ydif := y - MapDragStartY;
- tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
- tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;
- OutsideBox(0,0,-854, -765, IMG_LOC_MAP);
- BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
- BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;
- with tImages[IMG_LOC_BOX_TOP] do
- SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);
- OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);
- with tImages[IMG_LOC_BOX_LEFT] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
- with tImages[IMG_LOC_BOX_RIGHT] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
- with tImages[IMG_LOC_BOX_BOTTOM] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
- end;
- tImages[IMG_LOC_NAV]:
- begin
- if not IsMouseButtonDown(1) then exit;
- GetMousePos(x, y);
- with tImages[IMG_LOC_BOX_TOP] do
- SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);
- OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);
- with tImages[IMG_LOC_BOX_LEFT] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
- with tImages[IMG_LOC_BOX_RIGHT] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
- with tImages[IMG_LOC_BOX_BOTTOM] do
- SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
- BoundL := -(x - 155 - 376) * 7.234;
- BoundT := -(y - 140 - 216) * 7.234;
- tImages[IMG_LOC_MAP].Left := Round(BoundL);
- tImages[IMG_LOC_MAP].Top := Round(BoundT);
- OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
- end;
- end;
- end;
- procedure OnClickEvents(Sender: TObject);
- begin
- case Sender of
- tImages[IMG_X_NORM]: Clicked(Sender);
- tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
- tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
- end;
- end;
- procedure InitForm;
- var
- Image, bmp, hi, i: Integer;
- consts: TintegerArray;
- bmpArr: TStringArray;
- xy, wh: TPointArray;
- visibl: TBoolArray;
- begin
- bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
- hi := High(frmBitmaps);
- for i := 0 to hi do
- frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');
- {
- MAIN FORM
- }
- frmMain := TForm.Create(nil);
- with frmMain do
- begin
- SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
- //Position := poScreenCenter;
- //Width := 600;
- //Height := 400;
- BorderStyle := bsNone;
- end;
- time := TTimer.Create(frmMain);
- time.ONTIMER := @TimerTabClick;
- time.INTERVAL := 10;
- time.ENABLED := false;
- xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(390,100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(-300,0), Point(369,209), Point(475,7), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
- wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(1454,1165), Point(215,175), Point(119,22), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
- visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
- consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_MAP, LOC_NAV, LOC_EXIT_NORM, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
- for Image := 0 to IMG_COUNT - 1 do
- begin
- tImages[Image] := TImage.Create(frmMain);
- with tImages[Image] do
- begin
- Parent := frmMain;
- SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
- bmp := frmBitmaps[consts[image]];
- OnMouseMove := @MouseMoved;
- ONMOUSEDOWN := @OnMouseDown;
- OnClick := @OnClickEvents;
- isActiveImage[Image] := False;
- if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
- isLeftTab[Image] := false;
- visible := Visibl[Image];
- end;
- DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
- end;
- isActivePanel[Panel_1] := True;
- isActivePanel[Panel_2] := False;
- isActivePanel[Panel_3] := False;
- isActivePanel[Panel_4] := False;
- isActivePanel[Panel_5] := False;
- end;
- procedure SafeInitForm;
- var
- v: TVariantArray;
- begin
- setarraylength(V, 0);
- ThreadSafeCall('InitForm', v);
- end;
- procedure ShowFormModal;
- begin
- frmMain.ShowModal;
- end;
- procedure SafeShowFormModal;
- var
- v: TVariantArray;
- begin
- setarraylength(V, 0);
- ThreadSafeCall('ShowFormModal', v);
- end;
- begin
- try
- SafeInitForm;
- SafeShowFormModal;
- except
- Writeln(ExceptionToString(ExceptionType, ExceptionParam));
- end;
- end.
Add Comment
Please, Sign In to add comment