Undeclared Identifier

Posted on 2008-11-03
Last Modified: 2012-05-05
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

Question by:mikesExpertExchange
    LVL 13

    Expert Comment

    Add "Dialogs" to your uses clause.

    LVL 1

    Author Comment

    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...
    LVL 13

    Expert Comment

    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.
    LVL 1

    Author Comment

    ok,...i was wondering if i'd have to do that, but didn't understand why,..until now. thanks.
    LVL 13

    Accepted Solution

    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:

    LVL 1

    Author Closing Comment

    i think i like the last suggestion better,..its less work... ;-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    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…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    759 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

    7 Experts available now in Live!

    Get 1:1 Help Now