Link to home
Start Free TrialLog in
Avatar of mcmahling
mcmahling

asked on

Incompatible Types

I am using the call to application.messagebox to show a message when I run a syntac check the first calls below clear the syntac check but the third promotes the error "Incompatible types: String and PAnsiChar." The cursor blinks after the first string argument.  Does anyone know why I am getting this error?


1. application.MessageBox('Hello','Hello',mb_ok);
2. Application.MessageBox('You should try to finish'
  + ' the application normally.'#13#13'øTerminate it '
  + 'anyway?', 'Warning', MB_YESNO + MB_DEFBUTTON2 +
  MB_ICONQUESTION + MB_TASKMODAL);

3. if Application.MessageBox('Are you sure you want to delete version ' + intToStr(intVersion) + '?' , 'Question' , mb_YesNo) = ID_Yes then
    begin
end;
Avatar of odissey1
odissey1

Hi mcmahling,

if it wants a character, gie it a character

 S:='Are you sure you want to delete version ' + intToStr(3) + '?';
 if Application.MessageBox( PChar(S) , 'Question' , mb_YesNo) = ID_Yes then
 begin
 end;

regards,
odissey1
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow!
I just missed 250 points :-)
...Shu
i too, shu :-))
no guys, the points are going to  kretzschmar,
cause i've learned the unswer from him not long ago (for 50 points :).

regards,
odissey1

no no, odissey, you are first -> you deserve the points ;-)
:)
I'd also suggest using resourcestrings and Format
so you'd have smtn like:


resourcestring
  RSConfirmDeleteVersion = 'Are you sure you want to delete version %d';
  RSConfirmation = 'Cofirmation';

...

Application.MessageBox(PChar(Format(RSConfirmDeleteVersion, [VersionNo]), PChar(RSConfirmation), MB_ICONQUESTION or MB_YESNO)

:)
Don't make such a lot of code.

Use:

if MessageDLG('Are you sure?'+#13+'(Yes;No)', mtConfirmation, [mbYes, mbNo], 0)=mrYes then
begin
......
end;
--------------
To "kretzschmar"
__________
Please, read e-mail.
__________
thespian .. bleh .. 'coder'
think in advance and more flexibly ..
to thespian,
what eMail?

to mcmahling,
are you sure that my grading was not a mistake?
(because i attached no new information to odisseys comment)

meikl ;-)
Avatar of mcmahling

ASKER

Hello kretzscmar,

I intend to give you 250 points.
to kretzschmar,

you are graded right. The Q. was: '.. anyone know WHY I am getting this..'. But, honestly, I didn't know why - I know HOWTO.

sincerely,
odissey1  
well, ok then,
thanks :-))

glad to be helpful

meikl ;-)
To kretzschmar
________________
Check e-mail.
Several days ago I wrote a letter from Ukraine.
thespian,
i got it