SRL Archive - Help

painting a backround to a form in simba


Awkwardsaw

2010-06-17 23:22:36

hola, i'm having trouble getting a backround onto the form in simba, D:

i'm guessing its in


procedure paint(Sender: TObject);
begin
c := LoadBitmap(ScriptPath + 'background.bmp')
DrawBitmap(c, form.CANVAS, 0, 0);
freebitmap(c);
end;

but if it helps,

  Form := CreateForm;
with Form do
begin
Caption := 'Awkward Epic Flaxer';
SetBounds(100, 100, 360, 200);
BorderStyle := BSToolWindow;
ONpaint:= @paint;
end;

first to help is sexy, :)

Coh3n

2010-06-17 23:29:48

Try:

Form := CreateForm;
with Form do
begin
Caption := 'Awkward Epic Flaxer';
SetBounds(100, 100, 360, 200);
BorderStyle := BSToolWindow;
paint;
end;

If not, then take out the freeBitmap() and just free it on form close.

Awkwardsaw

2010-06-17 23:38:00

From: Coh3n
Try:

Form := CreateForm;
with Form do
begin
Caption := 'Awkward Epic Flaxer';
SetBounds(100, 100, 360, 200);
BorderStyle := BSToolWindow;
paint;
end;

If not, then take out the freeBitmap() and just free it on form close.


nope, :\ thanks though :p

Coh3n

2010-06-17 23:41:02

Hmm, that's weird. I do exactly the same thing in my Draynor form and it works fine. Try loading the image before initializing the form (just load the image before the CreateForm line.

Awkwardsaw

2010-06-17 23:47:36

From: Coh3n
Hmm, that's weird. I do exactly the same thing in my Draynor form and it works fine. Try loading the image before initializing the form (just load the image before the CreateForm line.


that's really weird, it still does nothing D:

program new;
{$i srl\srl.scar}
var
Form : TFORM;
labels : array [0..1] of array of TLabel;
edits : array [0..1] of array of TEdit;
combos : Array of TCOMBOBOX;
buttons : Array [0..3] of TButton;
v : Tvariantarray;
c : integer;

const
column_one = 0;
column_two = 1;

procedure ButtonClick(Sender: TObject);
begin
end;

procedure paint(Sender: TObject);
begin
DrawBitmap(c, form.CANVAS, 0, 0);
//freebitmap(c);
end;

procedure closeform(Sender: TObject);
begin
freebitmap(c);
end;

procedure init;
var
i, ii, iii : integer;
labelcaptions : array [0..1] of array of String;
combotexts : array[0..1] of array of String;
buttontexts : array of String;
begin
labelcaptions[column_one] :=
['Username:', 'Password:', 'Nick:', 'Pin:'];
labelcaptions[column_two] :=
['Loads:', 'Server:', 'Signed:', 'Action:'];
combotexts[0] := ['True', 'False'];
combotexts[1] := ['[Lumby] Spin Flax', '[LLetya] Pick Flax', '[Cammy] Pick Flax', '[Cammy] Spin Flax', '[Cammy] Both'];
buttontexts := ['Save', 'Load', 'Start', 'Stop'];
Form := CreateForm;
with Form do
begin
Caption := 'Awkward Epic Flaxer';
SetBounds(100, 100, 360, 200);
BorderStyle := BSToolWindow;
ONpaint:= @paint;
// ondestroy := @closeform;
end;
setarraylength(labels[column_one], 5);
for i := 1 to 4 do
begin
labels[column_one][i] := TLabel.Create(Form);
with labels[column_one][i] do
begin
Parent := Form;
caption := labelcaptions[column_one][i - 1];
left := 10;
top := i * 28;
end;
end;

setarraylength(labels[column_two], 5);
for i := 1 to 4 do
begin
labels[column_two][i] := TLabel.Create(Form);
with labels[column_two][i] do
begin
Parent := Form;
caption := labelcaptions[column_two][i - 1];
left := 200;
top := i * 28;
end;
end;

setarraylength(edits[column_one], 5);
for i := 1 to 4 do
begin
edits[column_one][i] := Tedit.Create(Form);
with edits[column_one][i] do
begin
Parent := Form;
Height := 30;
Width := 110;
left := 75;
top := i * 28;
end;
end;

setarraylength(edits[column_two], 3);
for i := 1 to 2 do
begin
edits[column_two][i] := Tedit.Create(Form);
with edits[column_two][i] do
begin
Parent := Form;
Height := 30;
Width := 110;
left := 250;
top := i * 28;
end;
end;

setarraylength(combos, 3);
for i := 1 to 2 do
begin
combos[i] := Tcombobox.Create(Form);
with combos[i] do
begin
Parent := Form;
Height := 30;
Width := 110;
left := 250;
top := 56 + i * 28;
if i = 1 then iii := 1 else iii := 4;
for II := 0 to iii do
Items.Add(ComboTexts[i - 1][ii]);
end;
end;

for I := 0 to 3 do
begin
Buttons[I] := TButton.Create(Form);
with Buttons[I] do
begin
Parent := Form;
height := 40;
width := 90;
left := i * 90;
top := 142;
Caption := buttontexts[i];
OnClick := @ButtonClick;
end;
end;
form.ShowModal;
form.Free;
end;
begin
c := LoadBitmap(ScriptPath + 'background.bmp');
ThreadSafeCall('init',v);
end.

if it helps :\

e : updated to the actual script :p

nielsie95

2010-06-18 04:24:16

Are you sure it loads the bitmap correctly? What if you try it with a (smaller) bitmap using BitmapFromString?

Coh3n

2010-06-18 07:39:07

From: Awkwardsaw
that's really weird, it still does nothing D:

program new;
{$i srl\srl.scar}
var
Form : TFORM;
labels : array [0..1] of array of TLabel;
edits : array [0..1] of array of TEdit;
combos : Array of TCOMBOBOX;
buttons : Array [0..3] of TButton;
v : Tvariantarray;
c : integer;

const
column_one = 0;
column_two = 1;

procedure ButtonClick(Sender: TObject);
begin
end;

procedure paint(Sender: TObject);
begin
DrawBitmap(c, form.CANVAS, 0, 0);
//freebitmap(c);
end;

procedure closeform(Sender: TObject);
begin
freebitmap(c);
end;

procedure init;
var
i, ii, iii : integer;
labelcaptions : array [0..1] of array of String;
combotexts : array[0..1] of array of String;
buttontexts : array of String;
begin
labelcaptions[column_one] :=
['Username:', 'Password:', 'Nick:', 'Pin:'];
labelcaptions[column_two] :=
['Loads:', 'Server:', 'Signed:', 'Action:'];
combotexts[0] := ['True', 'False'];
combotexts[1] := ['[Lumby] Spin Flax', '[LLetya] Pick Flax', '[Cammy] Pick Flax', '[Cammy] Spin Flax', '[Cammy] Both'];
buttontexts := ['Save', 'Load', 'Start', 'Stop'];
Form := CreateForm;
with Form do
begin
Caption := 'Awkward Epic Flaxer';
SetBounds(100, 100, 360, 200);
BorderStyle := BSToolWindow;
ONpaint:= @paint;
// ondestroy := @closeform;
end;
setarraylength(labels[column_one], 5);
for i := 1 to 4 do
begin
labels[column_one][i] := TLabel.Create(Form);
with labels[column_one][i] do
begin
Parent := Form;
caption := labelcaptions[column_one][i - 1];
left := 10;
top := i * 28;
end;
end;

setarraylength(labels[column_two], 5);
for i := 1 to 4 do
begin
labels[column_two][i] := TLabel.Create(Form);
with labels[column_two][i] do
begin
Parent := Form;
caption := labelcaptions[column_two][i - 1];
left := 200;
top := i * 28;
end;
end;

setarraylength(edits[column_one], 5);
for i := 1 to 4 do
begin
edits[column_one][i] := Tedit.Create(Form);
with edits[column_one][i] do
begin
Parent := Form;
Height := 30;
Width := 110;
left := 75;
top := i * 28;
end;
end;

setarraylength(edits[column_two], 3);
for i := 1 to 2 do
begin
edits[column_two][i] := Tedit.Create(Form);
with edits[column_two][i] do
begin
Parent := Form;
Height := 30;
Width := 110;
left := 250;
top := i * 28;
end;
end;

setarraylength(combos, 3);
for i := 1 to 2 do
begin
combos[i] := Tcombobox.Create(Form);
with combos[i] do
begin
Parent := Form;
Height := 30;
Width := 110;
left := 250;
top := 56 + i * 28;
if i = 1 then iii := 1 else iii := 4;
for II := 0 to iii do
Items.Add(ComboTexts[i - 1][ii]);
end;
end;

for I := 0 to 3 do
begin
Buttons[I] := TButton.Create(Form);
with Buttons[I] do
begin
Parent := Form;
height := 40;
width := 90;
left := i * 90;
top := 142;
Caption := buttontexts[i];
OnClick := @ButtonClick;
end;
end;
form.ShowModal;
form.Free;
end;
begin
c := LoadBitmap(ScriptPath + 'background.bmp');
ThreadSafeCall('init',v);
end.

if it helps :\

e : updated to the actual script :p


All I did was replace background.bmp with golf1.jpg (because I don't have your image), and it worked fine. Here's a pic -> http://i50.tinypic.com/34o1rif.png

Awkwardsaw

2010-06-18 10:03:20

From: Coh3n
All I did was replace background.bmp with golf1.jpg (because I don't have your image), and it worked fine. Here's a pic -> http://i50.tinypic.com/34o1rif.png


:\. maby its just my image

thanks :D

e: yeah, D:. it was a .png not a .bmp

:duh:

Coh3n

2010-06-18 15:29:51

From: Awkwardsaw
:\. maby its just my image

thanks :D

e: yeah, D:. it was a .png not a .bmp

:duh:

That shouldn't matter. The golf1 image I used was a .jpg, and every image I use in my Draynor script's form is a .png. Weird, but I'm glad it's working now. :)