michaelk Posted December 18, 2011 Share Posted December 18, 2011 I must have some syntax wrong, or I'm using an incorrect call. Can someone give me an example of how to assign values to the variables from the user choices made in the dialog box? Thanks! mk Procedure DialogQuestion; {Badly scripted by Michael Klaers} VAR DialogId,DialogResult : LONGINT; lineStyle,lineWeight, lineColor : INTEGER; BEGIN {Stuff happens} {Stuff happens} {Line weight and color dialog box.} DialogId := CreateLayout('Cell Borders',TRUE,'OK', 'Nevermind'); CreateStaticText(DialogId,4,'Select a Line Weight and Style',-1); CreateLineAttributePopup(DialogId,5); CreateStaticText(DialogID,6,'...and a line color',-1); CreateColorPopup(DialogId,7,-1); SetFirstLayoutItem(DialogId, 4); SetBelowItem (DialogId,4,5,0,0); SetBelowItem (DialogId,5,6,0,2); SetBelowItem (DialogId,6,7,0,0); SetHelpString(1,'Select line weight, style and color'); SetHelpString(2,'Cancel the operation and exit.'); SetHelpString(5,'Select line weight and style'); SetHelpString(7,'Select line color'); DialogResult := RunLayoutDialog(DialogId,NIL); {Assuming no callback to a procedure.......... how do I get lineStyle := lineWeight := lineColor := } {More Stuff Happens} END; RUN(DialogQuestion); Quote Link to comment
maarten. Posted December 19, 2011 Share Posted December 19, 2011 You can get those values in a Dialog_Handler Procedure. Have a look at this for an example. I never used it before, but i think you need to use GetPopUpChoiceIndex to get the values. Quote Link to comment
michaelk Posted December 20, 2011 Author Share Posted December 20, 2011 Thanks, maarten. I've been looking at that script - especially the procedure Dialog_Handler. Dialog handler has two LONGINT variables - a and b. I don't get how a is passed to the procedure and I can't see where b is ever used. I tried running the script with debug on. The value of A changes from garbage to 1 when OK is pressed on the dialog box. But how? And what is B for? mk Quote Link to comment
MullinRJ Posted December 21, 2011 Share Posted December 21, 2011 Michael, ???In Maarten's example, variable "a" is the ITEM number of the dialog item that was clicked on, or typed in. Every dialog event passes the relevant item number to a "Dialog_Handler" routine. If you want to do something for an event, then you need to have that item number enumerated in the CASE statement in the dialog handler routine with some code to be executed. ???Variable "b" in Maarten's example is "DATA". For the most part DATA is not used by the user. I have only found one instance in 10 years where I've used it and am waiting patiently for another. I'm not holding my breath. ???The formal declaration of the event handler procedure should look something like this: PROCEDURE Dialog_Handler(ITEM :Longint; DATA :LONGINT); ???This procedure is called from the "RunLayoutDialog()" command. Its declaration is defined in the VS Function Reference. "RunLayoutDialog" is a function that starts a dialog then returns the result of the dialog in an integer when the dialog closes ? 1 for OK and 2 for CANCEL. ???The name of the event loop, in this case "Dialog_Handler", is passed in the second parameter of "RunLayoutDialog()". Though the example cited above is a bit cryptic at first glance, a simpler example of this call would be: Result := RunLayoutDialog (dialogID, Dialog_Handler); ???While a dialog is running, the Modern Dialog machinery passes the item number of every item that is invoked to the callback procedure, which again in this case is "Dialog_Handler". The parameter list of "Dialog_Handler" is understood to be two Longints, ITEM and DATA, and does not get spelled out in your code. HTH, Raymond Quote Link to comment
michaelk Posted December 21, 2011 Author Share Posted December 21, 2011 Thank you, Raymond! That finally makes sense. Not sure I'll be able to fix my code - but now I understand why! mk Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.