Autor Beitrag
Tor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23


D5 Ent
BeitragVerfasst: Mi 20.10.04 10:19 
Hi

Ich Hab ein Live Chat Program das in Delphi 5 Geschrieben Wurde und jedes mal wen der Live Chat onlin ist und ich mit jemanden Chate und der jenige dann bei seinem Browser Auf Aktuallisieren Drückt geht bei mir ein Neues Fenster Auf wie Kan ich das Verhindern? Zum Programm selbst ist halt in Delphi geschrieben und Funst so das ich es Starte und Button betätige das ich Online bin auf einer Inet Seite wird dan angezeigt das ich on bin. Bei Klick auf den Link öfnet sich im Browser ein Chatfenster und bei mir aufem Rechner eben fals

Der Code für Fenster öffnen und neue message senden
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
 
var
  Req, Html  : String;
  n,x,i      : integer;
  id         : string;
  msg        : string;    // Nachricht
  modus      : integer;  // 0=Normal,1= Chatmsg
  ref        : string;   // HTML-Refer
begin
  Req   := ARequestInfo.Document;
  modus := 0;
  id    := '0';

  if (ARequestInfo.Params.Count > 0) then begin
      for i:=0 to ARequestInfo.Params.Count-1 do begin
          x:=Pos ('id=', ARequestInfo.Params[i]) ;
          if x > 0 then id:=Copy ( ARequestInfo.Params[i], x+3, 10);
          x:=Pos ('ref=', ARequestInfo.Params[i]) ;
          if x > 0 then ref:=Copy ( ARequestInfo.Params[i], x+4, 500);
          modus:=1;
      end;
  end;

  // neue Message
  if Pos ('chat_main', Req) > 0 then begin
     ChatFenster[iChats].update := time;
     if ARequestInfo.Params.Count >1 then begin
        x:=Pos ('msg=', ARequestInfo.Params[1]) ;
        if x > 0 then begin
           msg:=Copy ( ARequestInfo.Params[1], x+4, 2000);
           iChats:=0;
           for i:=1 to iChatsMax do begin
               if ChatFenster[i].id=ID then begin
                  iChats:=i;
               end;
           end;
           ChatFenster[iChats].msg.Add(msg);
        end;
     end;
  end;

  // Start Neues Chatfenster
  if Pos ('chat.htm', Req) > 0 then begin
     if ARequestInfo.Params.Count >0 then begin
        iChats:=0;
        for i:=1 to iChatsMax do begin
            if ChatFenster[i].aktiv=0 then begin
               iChats:=i;
            end;
        end;
        if iChats>0 then begin
           ChatFenster[iChats].ID:=id;
           ChatFenster[iChats].aktiv:=1;
           ChatFenster[iChats].update:=time;
           ChatFenster[iChats].refer:=ref;
           ChatFenster[iChats].msg:=TStringList.Create;
           msg:='User: ' +id + ' ist online um ' +  TimeToStr (Time);
           ChatFenster[iChats].msg.Add(msg);
        end;
     end;
     if chkMusik.Checked = True then begin
        with MediaPlayer1 do begin
          if FileExists(ExtractFilePath(Application.Exename) + 'anruf.wav') then begin
             Filename := ExtractFilePath(Application.Exename) + 'anruf.wav';
              try
              Open;
              Play;
              finally end;
          end;
        end;
     end;
     timer1.Enabled:=true;
  end;

  if Req [1] = '/' then Req := Copy (Req, 2, 1000);
  case modus  of
      0: begin
         Req:=ExtractFilePath(Application.Exename)+'html\'+Req;
         if FileExists(Req) then begin
            IdHTTPServer1.ServeFile(AThread,AResponseInfo,Req);
         end else begin
            Html:= Req;
            AResponseInfo.ContentText := Html;
         end;
      end;
      1: begin
         Req:=ExtractFilePath(Application.Exename)+'html\'+Req;
         if FileExists(Req) then begin
            Html:=lese_HTML_vorlage(req,id);
         end else
            Html:='Seite nicht gefunden';
            AResponseInfo.ContentText := Html;
      end;
  end;

  for n := 0 to Screen.FormCount - 1 do
  begin
     if Screen.Forms[n] is TfrmChat then
     begin
        if pos(id ,TfrmChat(Screen.Forms[n]).Caption) > 0 then
        begin
            iChats:=0;
            for i:=1 to iChatsMax do
            begin
                if ChatFenster[i].id=id then
                begin
                   iChats:=i;
                end;
            end;
            TfrmChat(Screen.Forms[n]).txtChatText.Clear;
            for i:= 0 to ChatFenster[iChats].msg.count-1 do
            begin        
TfrmChat(Screen.Forms[n]).txtChatText.Lines.Add(ChatFenster[iChats].msg.strings[i]);
            end;
        end;
     end;
  end;
end;