Log in

View Full Version : painting a backround to a form in simba



Awkwardsaw
06-18-2010, 03:22 AM
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
06-18-2010, 03:29 AM
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
06-18-2010, 03:38 AM
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
06-18-2010, 03:41 AM
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
06-18-2010, 03:47 AM
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
06-18-2010, 08:24 AM
Are you sure it loads the bitmap correctly? What if you try it with a (smaller) bitmap using BitmapFromString?

Coh3n
06-18-2010, 11:39 AM
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
06-18-2010, 02:03 PM
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
06-18-2010, 07:29 PM
:\. 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. :)