Undeclared Identifier

i've got an elementary question, so elementary that i'm almost afraid to ask,..but i gotta do what i gotta do...i'm trying to customize the CreateMessageDialog function from the Dialogs unit. I've copied and pasted the function into my code and renamed it CreateMyMessageDialog. I have included the Dialogs unit in my uses clause. When i try to compile my code i get this error:

[Error] SwipeForm.pas(xxx): Undeclared identifier: 'TMessageForm'

on this line:

Result := TMessageForm.CreateNew(Application);

which is pretty much the first line of code in the function (snippet included), so what am i doing wrong

function TfrmSwipeEntry.CreateMyMessageDialog(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons): TForm;
  mcHorzMargin = 8;
  mcVertMargin = 8;
  mcHorzSpacing = 10;
  mcVertSpacing = 10;
  mcButtonWidth = 50;
  mcButtonHeight = 14;
  mcButtonSpacing = 4;
  DialogUnits: TPoint;
  HorzMargin, VertMargin, HorzSpacing, VertSpacing, ButtonWidth,
  ButtonHeight, ButtonSpacing, ButtonCount, ButtonGroupWidth,
  IconTextWidth, IconTextHeight, X, ALeft: Integer;
  B, DefaultButton, CancelButton: TMsgDlgBtn;
  IconID: PChar;
  TextRect: TRect;
  Result := TMessageForm.CreateNew(Application); <--error happens here

Open in new window

Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
ThievingSixConnect With a Mentor Commented:
The other thing you can do is make the TMessageDialog type declaration public. You can do this by moving this:

  TMessageForm = class(TForm)
    Message: TLabel;
    procedure HelpButtonClick(Sender: TObject);
    procedure CustomKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure WriteToClipBoard(Text: String);
    function GetFormText: String;
    constructor CreateNew(AOwner: TComponent); reintroduce;

to somewhere above this:

Add "Dialogs" to your uses clause.

Michael SterlingWeb Applications DeveloperAuthor Commented:
its in there,..i mentioned that in the description...also my ultimate goal here is to change the size of the MessageDlg window. I've got the font changed but now the window itself is too small for the font and i need to change the size of it...
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Ah, I completely missed it. Your going to have to import the TMessageForm type and all it's methods to your unit as well because TMessageForm isn't publicly declared in dialogs.
Michael SterlingWeb Applications DeveloperAuthor Commented:
ok,...i was wondering if i'd have to do that, but didn't understand why,..until now. thanks.
Michael SterlingWeb Applications DeveloperAuthor Commented:
i think i like the last suggestion better,..its less work... ;-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.