Solved

Incompatible Types

Posted on 2003-12-10
16
770 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

15 Experts available now in Live!

Get 1:1 Help Now