Solved

Incompatible Types

Posted on 2003-12-10
16
771 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now