More dialogs

Posted on 1998-11-05
Last Modified: 2010-04-16
what running dialogs boxes in TPW 1.5 i need to know how to put in values to edit boxes as soom as they are run.
Question by:pobwest
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Expert Comment

ID: 1215973
do you mean the default values that appear in an edit box as soon as the dialog appears?


Author Comment

ID: 1215974
no, i can put in default values using the workshop, i need to know how to pass variables into them when they are executed.

LVL 27

Expert Comment

ID: 1215975
If you are programming with object pascal then you have a PEdit object and you can call the setText method.
   If you are programming with raw windows (à la Petzold as I say) then we are going to write SendDlgItemMessage(hDlg,IDD_ITEM,EM_SETTEXT,0,Long(PChar(@Text))); or something similar!
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 1215976
not quite what i meant.

When i run a dialog with:
 Application^.ExecDialog(New(PMyDialog, Init(@Self, DIALOG_2')));    

I want value to appear staight away, ie loaded from suitable variables.

I know how to send the data there:

for example; but i need this to be run as soon as the dialog box is initiated.
LVL 27

Expert Comment

ID: 1215977
You have a type TMyDialog and PMyDialog = ^TMyDialog. The object TMyDialog is probably extended from TDialog. The method SetupWindow is called on WM_INITDIALOG and at this point the "handle to window" TMyDialog.hWindow is valid and you can call setdlgitemint if you want.

Author Comment

ID: 1215978
I'm still a bit lost with this dialog thing malarky.
Could you write down how you would run a dialog designed in resource work shop and enter values in it to see if I'm on the right lines?

Author Comment

ID: 1215979
ha, stumped you all hey?
LVL 27

Accepted Solution

BigRat earned 70 total points
ID: 1215980
Stumped not, I forgot to mark my reply with e-mail notification! Probably I was asleep like a dormouse.
   When you wrote TMyDialog you specified an Init procedure (the constructor) which takes two parameters, the Window above (on the call specified as @self) and the name of the dialog resource (DIALOG_2 which you made in resource workshop).
   First your Init constructor does not pass any variables which you could put in the boxes. You could make them global, or you could pass them by changing the definition of the constructor. You cannot in the constructor put these values into the boxes since there is no hWindow at this time. One does this at window initialisation time, namely when SetupWindow is called. So we design it as follows :-

   BoxId = 123;    (* IdNr of box in dialog from ResourseWorkshop *)
    TMyDialog   = object(TDialog)

                          Value1 : Integer;

                          constructor Init(AParent : PWindowsObject;
                                                AName  : PChar;
                                                AValue  : Integer);
                           procedure SetupWindow; virtual;

constructor TMyDialog.Init(AParent : PWindowsObject;
                                       AName  : PChar;
                                       AValue  : Integer);
   inherited Init(AParent,AName);
   (* save parameter for later *)

procedure TMyDialog.SetupWindow;
   (* initialize my boxes *)
   (* etc... *)
Is that clear? And does Rat get the cheese?


Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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