Solved

Incompatible Types

Posted on 2003-12-10
16
773 Views
Last Modified: 2010-04-05
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;
0
Comment
Question by:mcmahling
  • 6
  • 3
  • 3
  • +3
16 Comments
 
LVL 2

Expert Comment

by:odissey1
ID: 9918334
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
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 250 total points
ID: 9918414
you must typecast you're string as PChar,
as shown by odissey1,
specially for concataneted strings

>application.MessageBox('Hello','Hello',mb_ok);
here does delphi the typecast for you internally

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

here you must typecast

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

meikl ;-)


0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9918469
Wow!
I just missed 250 points :-)
...Shu
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 9918503
i too, shu :-))
0
 
LVL 2

Expert Comment

by:odissey1
ID: 9918616
no guys, the points are going to  kretzschmar,
cause i've learned the unswer from him not long ago (for 50 points :).

regards,
odissey1

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9918791
no no, odissey, you are first -> you deserve the points ;-)
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 9919299
:)
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)

:)
0
 
LVL 5

Expert Comment

by:-Thespian-
ID: 9920920
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;
0
 
LVL 5

Expert Comment

by:-Thespian-
ID: 9920954
--------------
To "kretzschmar"
__________
Please, read e-mail.
__________
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 9920999
thespian .. bleh .. 'coder'
think in advance and more flexibly ..
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9921331
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 ;-)
0
 

Author Comment

by:mcmahling
ID: 9921425
Hello kretzscmar,

I intend to give you 250 points.
0
 
LVL 2

Expert Comment

by:odissey1
ID: 9921492
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  
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9921561
well, ok then,
thanks :-))

glad to be helpful

meikl ;-)
0
 
LVL 5

Expert Comment

by:-Thespian-
ID: 9921911
To kretzschmar
________________
Check e-mail.
Several days ago I wrote a letter from Ukraine.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9922411
thespian,
i got it
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree compare node issue 14 125
Help on project with Soap 10 57
drawing animated level bar based on numbers 3 104
shape, triangle, dbctrlgrid 3 17
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question