?
Solved

Incompatible Types

Posted on 2003-12-10
16
Medium Priority
?
781 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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