Solved

Incompatible Types

Posted on 2003-12-10
16
772 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
Gigs: Get Your Project Delivered by an Expert

Select from 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.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add combobox item based on numbers 9 141
Delphi - replicating a form 8 72
Print Graphic and Text to Epson TM-T88v 12 243
CheckListBox usage 3 58
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

805 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