SRL Archive - SRL Archives

SRL Message Box


Waddo

2008-07-12 18:07:39

There we go updated it now you cant say the other is better.
Yes there's more stuff to fill out but its not hard questions=]

updated again now it has multi line.

program New;
var
frmDesign : TForm;
BitBtn1 : TBitBtn;
labelwidth, txtsize, msgboxheight : Integer;
txtup : string;
txtbold, txtit,txtuline:boolean;
Memo1 : TMemo;
Msg:array of String;
MsgPos:integer;

procedure LoadMsgBoxForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 50;
frmDesign.Width := labelwidth+16;
frmDesign.Height := msgboxheight+78;
frmDesign.Caption := txtup;
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Memo1 := TMemo.Create(frmDesign);
Memo1.Color := clBtnFace;
memo1.Parent := frmDesign;
memo1.Font.size:= txtsize;
memo1.ReadOnly:=true;
For MsgPos:=0 to high(Msg) do
memo1.Lines.add (msg[MsgPos]);
If txtbold then
memo1.Font.Style := [fsBold];
If txtit then
memo1.Font.Style := [fsItalic];
If txtuline then
memo1.Font.Style := [fsUnderline];
memo1.Left := 0;
memo1.Top := 0;
memo1.Width := labelWidth;
memo1.Height := msgboxheight;
BitBtn1 := TBitBtn.Create(frmDesign);
BitBtn1.Parent := frmDesign;
BitBtn1.Left := (memo1.Width-137);
BitBtn1.Top := memo1.Height;
BitBtn1.Width := 137;
BitBtn1.Height := 41;
BitBtn1.Caption := 'Ok';
BitBtn1.ModalResult := 1;
BitBtn1.TabOrder := 8;
end;

procedure ShowMsgBoxFormModal;
begin
frmDesign.ShowModal;
end;

Procedure MsgBox(Message:array of string;Uptext:String;Size:integer;Bold,Underlined,Italic:boolean;width,height:integer;sound:Boolean);
Var
V: TVariantArray;
begin
setarraylength(Msg,High(message)+1)
setarraylength(Message,High(message)+1)
labelwidth:=width;
msgboxheight:=height;
for MsgPos:= 0 to high(message) do
msg[MsgPos]:=message[MsgPos];
txtup:=uptext;
txtbold:=bold;
txtuline:=underlined;
txtit:=italic;
txtsize:=size;
V := [];
ThreadSafeCall('LoadMsgBoxForm', V);
V := [];
If sound then
PlaySound('C:\WINDOWS\Media\tada.wav');
ThreadSafeCall('ShowMsgBoxFormModal', V);
end;

begin
MsgBox(['hello','hi','bob','yay'],'MsgBox',15,True,True,True,200,100,True);
end.

mastaraymond

2008-07-12 19:19:46

From: Waddo
I wonder if this or some variation of this could be added into the next SRL.

program New;
var
frmDesign : TForm;
Label1 : TLabel;
BitBtn1 : TBitBtn;
labelwidth, txtsize : Integer;
Msg : string;

procedure LoadMsgBoxForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := labelwidth;
frmDesign.Height := 154;
frmDesign.Caption := 'MsgBox';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
label1.Caption:=Msg;
Label1.Parent := frmDesign;
label1.Font.size:= 12;
Label1.Left := 32;
Label1.Top := 24;
Label1.Width := labelWidth-48;
Label1.Height := 81;
BitBtn1 := TBitBtn.Create(frmDesign);
BitBtn1.Parent := frmDesign;
BitBtn1.Left := labelWidth-137-20;
BitBtn1.Top := 68;
BitBtn1.Width := 137;
BitBtn1.Height := 41;
BitBtn1.Caption := 'Ok';
BitBtn1.ModalResult := 1;
BitBtn1.TabOrder := 8;
end;

procedure ShowMsgBoxFormModal;
begin
frmDesign.ShowModal;
end;

Procedure MsgBox(Message:String;Size:integer;width:integer);
Var
V: TVariantArray;
begin
labelwidth:=width;
msg:=message;
txtsize:=size;
V := [];
ThreadSafeCall('LoadMsgBoxForm', V);
V := [];
ThreadSafeCall('ShowMsgBoxFormModal', V);
end;

begin
MsgBox('hello',15,360);
end.

Run it to check how it works.

You actually already can.. 2 ways: ShowMessage(msg : string); But that is pretty fucked up, ask freddy1990 to fix it.. Or you can do GetApplication.MessageBox('Ya','Ya',0);

Hobbit

2008-07-12 19:23:46

Meh… i think it's a good and useful idea.

Good job Waddo.. if I made scripts I'd prolly use it

Scaper

2008-07-12 19:31:28

program New;


begin
GetApplication.MessageBox('thank you for using','ya',0);
wait(1500);
begin
GetApplication.MessageBox('plz use again soon','ya',0);
end;
end.

yer that way works quite good actualy

showmeesage is meesed up wont even deplay it

Harry

2008-07-12 22:22:59

Or here is something MasterKill based, edited and 'l33t3d up by moi':


procedure StartClick(sender: TObject);
begin
frmDesign.ModalResult:= mrOk;
OkayClick := True;
end;

procedure InitForm;
var
Label1,Label2: TLabel;
StartButton: TButton;
begin
frmDesign := CreateForm;
frmDesign.Left := 300;
frmDesign.Top := 300;
frmDesign.Width := 500;
frmDesign.Height := 100;
frmDesign.Caption := upzor;
frmDesign.Color := clBlack;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := upzor;
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;

Label2 := TLabel.Create(frmDesign);
Label2.Font.Color := clNeonPink;
Label2.Parent := frmDesign;
Label2.Left := 5;
Label2.Top := 5;
Label2.Width := 46;
Label2.Height := 13;
Label2.Font.Size := 10;
Label2.Caption := onezor;

Label1 := TLabel.Create(frmDesign);
Label1.Font.Color := clNeonPink;
Label1.Parent := frmDesign;
Label1.Left := 5;
Label1.Top := 25;
Label1.Width := 46;
Label1.Height := 13;
Label1.Font.Size := 10;
Label1.Caption := twozor;

StartButton := TButton.Create(frmDesign);
StartButton.Parent := frmDesign;
StartButton.OnClick := @StartClick;
StartButton.Left := 5;
StartButton.Top := 45;
StartButton.Width := 480;
StartButton.Height := 21;
StartButton.Caption := 'Click here to Continue (The OK Button)';
StartButton.TabOrder := 10;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

procedure ErrorForm(Uptextt, msgone, msgtwo: String; Terminate: Boolean);
begin
Upzor := uptextt;
Onezor := msgone;
Twozor := msgtwo;
OkayClick := False;
PlaySound('C:\WINDOWS\Media\tada.wav'); // Hope I don't scare you... hehehe...
if not UseForm then
begin
WriteLn('@@@ '+Msgone+'.');
Writeln('@@@ '+Msgtwo+'.');
WriteLn(' ~~~~~~~~~~~~~ ');
if Terminate then
TerminateScript
else
begin
Wait(5000);
Exit;
end;
end;
repeat
SafeInitForm;
SafeShowFormModal;
if OkayClick then
Break;
PlaySound('C:\WINDOWS\Media\tada.wav');
WriteLn('Please press ''OK''!');
Wait(1+Random(250));
until(OkayClick);
if Terminate then
TerminateScript;
end;
You will have to edit it a bit to get it to work :D but it is cool when you get it working. Make sure you have the sound on ;)

mastaraymond

2008-07-13 05:17:16

From: Scaper
program New;


begin
GetApplication.MessageBox('thank you for using','ya',0);
wait(1500);
begin
GetApplication.MessageBox('plz use again soon','ya',0);
end;
end.

yer that way works quite good actualy

showmeesage is meesed up wont even deplay it

I told ya :)

Waddo

2008-07-13 07:29:55

Yer i know id already posted it tho when ya told ma.
but this is better you can choose the size infact I'm going to update it so you can do bold =]

Edit: changed it try it now ;-]

n3ss3s

2008-07-13 10:29:37


Waddo

2008-07-13 10:41:35

ha n3ss3s that piece of shit.

hardly works for anyone and doesn't have many options =]

Edit: IMHO this pwnz0rz ShowMessage =]

n3ss3s

2008-07-13 10:44:57

People usually don't be so… 'loud' about their own functions.

Maybe because it's so good, you should link Freddy to this thread so that he'd be convinced about how your one owns his 'shit' ShowMessage.

Waddo

2008-07-13 10:46:36

lol, mine may not look as tidy but it has more functonality =]

Edit: Anyway why cant you just humour me and make me feel good for once. =]

Edit2: The reason im so "loud" about it is because it is possibly the first real thing that could be good for SRL. =]

n3ss3s

2008-07-13 10:56:47

I really don't know what humouring means so I won't, but how would you feel like if Freddy came here and said - "Haha, shitty lil function, SCAR 3.16 has a new ShowMessage that gives you a cookie!"? Bad.

Also, what do you mean by this being the first useful thing for SRL?

ZephyrsFury

2008-07-13 11:00:03

WTF is this all about? Its a stupid little message box that can be made to appear in 3 different ways… whats so exciting??? Lol

Waddo

2008-07-13 11:00:19

I mean it could be the most beneficial thing ive ever done for SRL =]
and humouring some one just means to like go along with it to make them happy. =]

And if Freddy makes a better one then ill be happy cos mine spurred him on to give out free cookies. =]

n3ss3s

2008-07-13 11:05:07

I mean it could be the most beneficial thing ive ever done for SRL =]
and humouring some one just means to like go along with it to make them happy. =]

And if Freddy makes a better one then ill be happy cos mine spurred him on to give out free cookies. =]


.. I'm outta this thread.

Hippies…

Waddo

2008-07-13 11:07:27

Why no matter what i do is no one ever happy =[ what can i do that you would like.

Not something ridiculously stupidly hard.

Come on atleast i try. =[

n3ss3s

2008-07-13 11:14:52

You don't have to do anything, and for the goal of making something that's good for SRL, I suggest you try some runtime thing, because SRL is for macroing, usually long periouds, and I doubt people like to see tons of message boxes in the morning =D


You should also add FreeForm.

Waddo

2008-07-13 11:29:06

N3ss3s i was thinking more for final reports and things like "you don't have a stats account go here to get one" etc.

Markus

2008-07-13 12:14:41

Kick it to SRL Functions? This doesn't sound like something for in SRL imo, more for in scripts..