SRL Archive - SRL Archives

Canvas Funcitons


BazzBarrett

2008-09-10 15:14:55

ill start with a question is the SRL RuneScape based only? if not i would like to suggest this
var
TFN :TForm;
TFNHeight, TFNWidth :Integer;
TFNCaption : String;
TFNEOC : Boolean;

// EndScript(Sender: TObject; var Action: TCloseAction);
// Used in safecreatewindow for ending the scipt if the window is closed
procedure EndScript(Sender: TObject; var Action: TCloseAction);
begin
terminatescript;
end;

// DrawToWindow(BitMap, X, Y :integer);
// easy way of adding a bitmap to the windows canvas.
procedure DrawToWindow(BitMap, X, Y :integer);
begin
safedrawbitmap(BitMap, TFN.Canvas, x, y);
end;

// SafeCreateWindow;
// creates a form with a blank canvas from ur specification
// from the CreateWindow procedure
procedure SafeCreateWindow;
begin
TFN := CreateForm;
TFN.ClientWidth := TFNwidth;
TFN.ClientHeight := TFNheight;
TFN.Caption := TFNCaption;
TFN.Position := poDesktopCenter;
if TFNEOC then TFN.OnClose := @EndScript;
GetSelf.WindowState := wsMinimized;
TFN.Show;
end;

// CreateWindow(Width, Height: Integer; Caption :String; EndOnClose :Boolean);
//
// Width = The width of your window (if smaller than 114 then it will revert to 114)
// Height = The Height of your window (no min)
// Caption = The name of your Window
// EndOnClose = if true then it will end the script when you close the window
//
procedure CreateWindow(Width, Height: Integer; Caption :String; EndOnClose :Boolean);
var
V :TVariantArray;
begin
TFNWidth := Width;
TFNHeight := Height;
TFNCaption := Caption;
TFNEOC := EndOnClose;
ThreadSafeCall('SafeCreateWindow', v);
end;

by using create window you turn:
program New;
var
GW :TForm;
V :TVariantArray;

procedure EndScript(Sender: TObject; var Action: TCloseAction);
begin
terminatescript;
end;

procedure setup;
begin
GW := CreateForm;
GW.ClientHeight := 300;
GW.ClientWidth := 300;
GW.Caption := 'A Window!';
GW.Position := poDesktopCenter;
GW.OnClose := @EndScript;
GetSelf.WindowState := wsMinimized;
GW.Show;
end;

begin
ThreadSafeCall('Setup', v);
end.
into:
program New;
{.include SRL/misc/Window.scar}
begin
createwindow(300, 300, 'A Window!', True);
end.
thx for ya time ;)

Dan Cardin

2008-09-10 15:31:47

yes but then you have the problem, of needing to add an onclose procedure and that your position will always be poDesktopCenter, and whatnot. If i were to use something like that i would add more things to define to make it more useable. Its not that big of a deal, but im picky :).

and srl is all rs.

BazzBarrett

2008-09-10 15:40:51

the on close procedure is included just by the "EndOnClose :Boolean" then u could use scriptterminate if u whant 2 add anything extra i could add extra functions but i was more thinking of a base not every1 is gud with forms and canvases this makes it as simple if not simpler than the debug window.. but if SRL's all Rs then best not include this XD if u whant me 2 take it down i will but its hardaly "clogging" the topic and it's helpful for any1 who whants to create a quick canvas (altough not that meny people use canvas's)