Autor Beitrag
pmw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Do 29.05.03 12:25 
Hallo!

Wie kann ich der Komponente HTTPServer.OnCommandGet die Procedure "CommandGet" zuweisen? Delphi bringt immer die Fehlermeldung "Inkompatible Typen: 'Methodenzeiger und reguläre Prozedur'". Die Parameter in der Procedure sind auf jeden Fall richtig.

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:
program ZeitServer;

uses
  Windows, Messages, IdBaseComponent, IdComponent, IdTCPServer, IdCustomHTTPServer, IdHTTPServer;

{$R *.res}

var
  HTTPServer: TIdHTTPServer;
  msg: TMsg;

procedure CommandGet(AThread: TIdPeerThread; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin

   AResponseInfo.ContentText := '<html><head><title>Hallo!</title></head><body><h1>' + ARequestInfo.Command + '</h1></body></html>';

end;

begin

   HTTPServer := TIdHTTPServer.Create(nil);

   with HTTPServer do begin

      Name := 'IdHTTPServer1Execute';
      Bindings.Add;
      Bindings.Items[0].IP := '0.0.0.0';
      Bindings.Items[0].Port := 44;
      DefaultPort := 44;
      Greeting.Text.CommaText := '<body><h1>Herzlich Willkommen!</h1>Mein 1. Server ...</body>';
      Greeting.TextCode := 'text/html';
      OnCommandGet := CommandGet; // <-- Fehlermeldung
      Active := True;

   end;

   while GetMessage(msg,0,0,0do begin
      TranslateMessage(msg);
      DispatchMessage(msg);
   end;

  ExitCode := msg.wParam;

end.


Viele Grüße
Martin Winandy
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 29.05.03 19:20 
Mal so ins Blaue reingeraten:
ausblenden Delphi-Quelltext
1:
OnCommandGet := @CommandGet;					

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Do 29.05.03 20:14 
Dann bekomme ich leider diese Fehlermeldung:

ausblenden Delphi-Quelltext
1:
Inkompatible Typen: 'TIdHTTPGetEvent' und 'Pointer'					
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Do 29.05.03 22:28 
hi so einfach geht das nicht. das eine ist eine stinknormale procedure, das andere eine innerhalb einer Klasse/interface. Dat jeht so nich.
Die beste methode wäre, die Klasse mit dieser procedure zu ergänzen bzw. overwriten.
grez
msch
pmw Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Do 29.05.03 23:12 
Wie geht das? Muss ich die Prozedur in den Quelltext der Indy9-Komonente schreiben???
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 30.05.03 07:55 
Es geht mit einem kleinen Trick:
ausblenden Delphi-Quelltext
1:
@OnCommandGet := @CommandGet;					

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Fr 30.05.03 20:18 
na, da war ich doch nah dran...

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Fr 30.05.03 21:14 
tommie-lie hat folgendes geschrieben:
na, da war ich doch nah dran...
Knapp daneben ist eben auch vorbei - überigens wollte ich diese Frage auch gerade stellen.
:idea: Jetzt kann ich so tun, als hätte ich es schon gewust...
:flüster: Danke

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.