Autor Beitrag
PeterKiers
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Di 31.10.06 09:52 
Hallo,

ist es möglich eine variabel HostName in einem String einzugeben

zb.

ausblenden Delphi-Quelltext
1:
'you must disconnect' + HostName + 'Do you want to disconnect now?'					


Nun sieht meine Prozedure bis jetzt so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TMainForm.Warning1; 
begin 
  if (Application.MessageBox( 
    'You must disconnect before opening another connection.' + #10 + #13 + 
    'Do you want to disconnect?', 
    'Access2All', 
    MB_YESNO + MB_DEFBUTTON1 + MB_ICONEXCLAMATION) = ID_YES) then 
  begin 
    Disconnect1Click(self); 
    Connect1click(self); 
  end; 
end;


könnt ihr mir vieleicht zeigen wie man sowas macht?
danke schonmal für eure antworten,

Peter Kiers

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Di 31.10.06 10:00 
ausblenden Delphi-Quelltext
1:
'you must disconnect' + HostName + 'Do you want to disconnect now?';					


das ist richtig unter der Vorraussetzung HostName ist n String/Char

_________________
GEIZ IST GEIL! - Ihr Sozialamt
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Di 31.10.06 10:16 
1. procedure TMainForm.Warning1;
2. begin
3. if (Application.MessageBox(
4. 'You must disconnect'+ ConnectHostName +'before opening 5. another connection.' + #10 + #13 +
6. 'Do you want to disconnect?',
7. 'Access2All',
8. MB_YESNO + MB_DEFBUTTON1 + MB_ICONEXCLAMATION) =
9. ID_YES) then
10. begin
11. Disconnect1Click(self);
12 Connect1click(self);
13. end;
14. end;

Regel 6:

[Error] Main.pas(3120): Incompatible types: 'String' and 'PChar'

Peter
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 31.10.06 10:23 
Hallo,

die Funktion MessageBox fordert für die Parameter Text und Caption einen Pchar(Zeiger auf nullterminierten String).
Wenn der String aus Variablen zusammengesetzt wird, muss man den String in einen Pchar casten (umwandeln).

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if (Application.MessageBox(   
    Pchar('you must disconnect' + HostName + 'Do you want to disconnect now?'),   
    'Access2All',   
    MB_YESNO + MB_DEFBUTTON1 + MB_ICONEXCLAMATION) = ID_YES) then
    //...

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
PeterKiers Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26


D7
BeitragVerfasst: Di 31.10.06 10:24 
Danke...


Peter Kiers