Jo emn du kan ikke rigtigt se noget ud fra koden. Jeg har lavet programmet sideløbene med mit arbejde uden forberedelse, så det er en rigtig gang skraldespandkode tror jeg :-) men hva faen jeg er heller ikke programmør:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
NMMSG, Psock, StdCtrls, Buttons, ExtCtrls, unit2, MPlayer, Menus,
ScktComp, shellapi ;
type
TForm1 = class(TForm)
Memo1: TMemo;
ComboBox1: TComboBox;
Bevel1: TBevel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
NMMSGServ1: TNMMSGServ;
NMMsg1: TNMMsg;
Bevel2: TBevel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Timer1: TTimer;
Timer2: TTimer;
Label1: TLabel;
Label2: TLabel;
MediaPlayer1: TMediaPlayer;
BitBtn3: TBitBtn;
Button5: TButton;
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure NMMSGServ1MSG(Sender: TComponent; const sFrom, sMsg: String);
procedure Button1Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure ApplicationEventsMessage(var Msg: tagMSG; var Handled: Boolean);
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
procedure Timer2Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn3Click(Sender: TObject);
procedure gemdata;
procedure hentData;
procedure Button5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure Image2Click(Sender: TObject);
procedure Image3Click(Sender: TObject);
private
fejl: string;
{ Private declarations }
public
procedure sethost{ Public declarations };
procedure setDNS;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BitBtn2Click(Sender: TObject);
var
text:string;
i:integer;
begin
timer1.Enabled:=false;
FlashWindow(Application.Handle, False);
if combobox1.Text = 'Arla gruppen' then
begin
fejl:= 'Carstens';
nmmsg1.Host:= '10.11.15.36';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.36') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Anne Margretes';
nmmsg1.Host:= '10.11.15.22';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.22') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Kims';
nmmsg1.Host:= '10.11.15.39';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.39') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Mariannes';
nmmsg1.Host:= '10.11.15.37';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.37') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Jespers';
nmmsg1.Host:= '10.11.15.35';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.35') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Karins';
nmmsg1.Host:= '10.11.15.15';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.15') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Bentes';
nmmsg1.Host:= '10.11.15.16';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.16') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Lenes';
nmmsg1.Host:= '10.11.15.12';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.12') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
fejl:= 'Gittes';
nmmsg1.Host:= '10.11.15.30';
text:= edit1.Text;
try
if not (nmmsg1.LocalIP = '10.11.15.30') then
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
//showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
//memo1.Lines.Add('-> ALLE: '+ text);
end
else
begin
sethost;
text:= edit1.Text;
try
nmmsg1.PostIt(text);
except
nmmsg1.Disconnect;
showmessage('Kunne ikke kontakte ' + fejl +' computer!' );
end;
end;
memo1.Lines.Add('-> ' + combobox1.Text + ': ' + text);
edit1.Clear;
edit1.SetFocus;
//showmessage('ok');
end;
procedure TForm1.FormCreate(Sender: TObject);
var
f:textfile;
s:string;
begin
combobox1.ItemIndex:=0;
Application.OnMessage := ApplicationEventsMessage;
SetDNS;
hentData;
end;
procedure Tform1.sethost;
begin
if combobox1.Text = 'Carsten' then
begin
fejl:='Carstens';
nmmsg1.Host:= '10.11.15.36'; //'leccaav';
end
else
if combobox1.Text = 'Marianne' then
begin
fejl:='Mariannes';
nmmsg1.Host:= '10.11.15.37' // 'lecpbl1v';
end
else
if combobox1.Text = 'Kim' then
begin
fejl:='Kims';
nmmsg1.Host:= '10.11.15.39' //'leckiev';
end
else
if combobox1.Text = 'Anne Magrete' then
begin
fejl:='Anne Margretes';
nmmsg1.Host:= '10.11.15.22' //'lecams1v';
end
else
if combobox1.Text = 'Gitte' then
begin
fejl:='Gittes';
nmmsg1.Host:= '10.11.15.30' //'lecgra1v';
end
else
if combobox1.Text = 'Jesper' then
begin
fejl:='Jespers';
nmmsg1.Host:= '10.11.15.35' //'lcjeh1';
end
else
if combobox1.Text = 'Karin' then
begin
fejl:='Karins';
nmmsg1.Host:= '10.11.15.15' //'leckia1v';
end
else
if combobox1.Text = 'Bente' then
begin
fejl:='Bentes';
nmmsg1.Host:= '10.11.15.16' //'lecbes1v';
end
else
if combobox1.Text = 'Lene' then
begin
fejl:='Lenes';
nmmsg1.Host:= '10.11.15.12' //'lecleh1v';
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if bitbtn1.Caption = 'Mere' then
begin
height:= 506;
bitbtn1.Caption := 'Mindre'
end
else
begin
height:= 403;
bitbtn1.Caption := 'Mere'
end;
end;
procedure TForm1.NMMSGServ1MSG(Sender: TComponent; const sFrom,
sMsg: String);
begin
Timer1.Enabled:= true; //sætte til at blinke i processlinie
memo1.Lines.Add('');
memo1.Lines.Add('');
memo1.Lines.Add('Fra '+sFrom + ' > ' + sMsg);
mediaplayer1.Open;
mediaplayer1.play; //afspil pliing
if nmmsg1.LocalIP = '10.11.15.36' then
begin
gemdata; // gemmer data på serveren til log
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
telefonnumre.ShowModal;
end;
procedure TForm1.setDNS;
begin
if nmmsg1.LocalIP = '10.11.15.36' then nmmsg1.FromName := 'Carsten'
else
if nmmsg1.LocalIP = '10.11.15.22' then nmmsg1.FromName := 'Anne Margrete'
else
if nmmsg1.LocalIP = '10.11.15.39' then nmmsg1.FromName := 'Kim'
else
if nmmsg1.LocalIP = '10.11.15.12' then nmmsg1.FromName := 'Lene'
else
if nmmsg1.LocalIP = '10.11.15.37' then nmmsg1.FromName := 'Marianne'
else
if nmmsg1.LocalIP = '10.11.15.30' then nmmsg1.FromName := 'Gitte'
else
if nmmsg1.LocalIP = '10.11.15.15' then nmmsg1.FromName := 'Karin'
else
if nmmsg1.LocalIP = '10.11.15.16' then nmmsg1.FromName := 'Bente'
else
if nmmsg1.LocalIP = '10.11.15.35' then nmmsg1.FromName := 'Jesper'
else
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
edit1.SetFocus;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
FlashWindow(Application.Handle, True);
end;
procedure TForm1.FormClick(Sender: TObject);
begin
timer1.Enabled:=false;
FlashWindow(Application.Handle, False);
end;
procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
begin
case Message.CmdType of
SC_MINIMIZE:
begin
timer1.Enabled:=false;
FlashWindow(Application.Handle, False);
//ShowMessage('FORM Minimize');
end;
SC_RESTORE:
begin
//ShowMessage('FORM Restore');
end;
SC_MAXIMIZE:
begin
//ShowMessage ('FORM Maximize');
end;
end;
inherited;
end;
procedure TForm1.ApplicationEventsMessage(var Msg: tagMSG; var Handled: Boolean);
begin
if not Msg.message = WM_SYSCOMMAND then
exit;
case Msg.wParam of
SC_MINIMIZE:
begin
//ShowMessage('APP Minimize');
end;
SC_RESTORE:
begin
timer1.Enabled:= false;
FlashWindow(Application.Handle, False);
//ShowMessage('APP Restore');
//FlashWindow(Application.Handle, false);
//application.Terminate;
end;
SC_MAXIMIZE:
begin
//ShowMessage ('APP Maximize');
end;
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
//timer2.Enabled:= false;
//mediaplayer1.Open;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action := caNone;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.gemdata;
var
f:textfile;
text:string;
dato:tdatetime;
filnavn: string;
begin
dato:= date;
text:= memo1.Text;
filnavn:= datetostr(date);
filnavn:= filnavn + '.txt';
try
assignfile(f,'\\lecsrv35\p0760txt\caa\'+filnavn);
rewrite(f);
append(f);
writeln(f,text);
flush(f);
closefile(f)
except
showmessage('Du kan ikke gemme');
end;
end;
procedure TForm1.hentData;
var
f:textfile;
text:string;
dato:tdatetime;
filnavn:string;
begin
dato:= date;
filnavn:= datetostr(date);
filnavn:= filnavn + '.txt';
try
assignfile(f,'\\lecsrv35\p0760txt\caa\'+filnavn);
Reset(f);
while not (eof(f)) do
begin
Readln(f,text );
Memo1.Lines.Add(text);
end;
CloseFile(f);
except
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
memo1.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
shellexecute(0,'open','calc.exe',nil,'c:\winnt\system32',sw_normal);
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
shellexecute(0,'open','Iexplore.exe','
www.arlafoods.dk','C:\Programmer\Internet Explorer',sw_normal);
end;
procedure TForm1.Image2Click(Sender: TObject);
begin
shellexecute(0,'open','Iexplore.exe','
www.lec.dk','C:\Programmer\Internet Explorer',sw_normal);
end;
procedure TForm1.Image3Click(Sender: TObject);
begin
shellexecute(0,'open','Iexplore.exe','\\\Linkside for KundeService.htm','C:\Programmer\Internet Explorer',sw_normal);
end;
end.