1

Further to my previous question, I had an error when trying to call MessageDlg()

[DCC Error] MainForm.pas(54): E2003 Undeclared identifier: 'mtError'

So I pulled up help and found that mtError is declared in Dialogs.

I opened Project/Options/Unit scope names and added Dialogs.

And I still get the same error.

I can has halpz?

Community
  • 1
  • 1
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
  • 1
    There's something strange about your project. If I use `File->New->VCL Forms Appiication`, create a new `FormCreate` event, and then type `MessageDlg('Test message', mtError, [mbOK], 0);`, it compiles fine without any warnings or errors using the default compiler options. – Ken White Jan 08 '12 at 07:22
  • 1
    This was answered specifically in the second link I posted to your last question (the subtopic `Fully Qualified Names Must Include the Unit Scope Name`). :) – Ken White Jan 08 '12 at 07:32
  • +2 Ken, I agree there is soemthing strange. I am now creating a new project from scratch & slowly adding things. I will report back, but you might want to post soem kind of answer whcih I coudl award... – Mawg says reinstate Monica Jan 08 '12 at 08:03
  • +1 just for the reference to lolcats :) go get yourself a cheeseburger to help with the re-adding. – Marjan Venema Jan 08 '12 at 09:57

2 Answers2

5

Add Vcl instead of Dialogs in Project->Options->Unit scope names.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
  • 3
    To elaborate in this, `Dialogs` is a unit that exists in the `Vcl` scope. In the `Unit Scope Names` list, you specify scopes, not units. Then, to allow `mtError` to resolve, add `Dialogs` to your `uses` clause. If `Vcl` is not specified in the `Unit Scope Names` list, then the `uses` clause needs to specify `Vcl.Dialogs` instead. – Remy Lebeau Jan 09 '12 at 02:21
4

This was answered in the second link I posted to your last question (the subtopic Fully Qualified Names Must Include the Unit Scope Name.

There's something strange about your project, though. If I create a new VCL project (File->New->VCL Forms Application), and then add the following code, it compiles fine with no changes to default compiler settings.

procedure TForm1.FormCreate(Sender: TObject);
begin
  MessageDlg('Test message', mtError, [mbOK], 0);
end;
Ken White
  • 123,280
  • 14
  • 225
  • 444
  • +1 Thansk very, very much for your help Ken. I can't remember if my project was inmported from D7; failing that it was based on an Indy demo & I think those are also D7. In any case, starting from scratch & adding components and codes piece by piece has gotten it working – Mawg says reinstate Monica Jan 08 '12 at 08:19