Hi Jon,
without having seenn your code, I guess the problem might be that you are trying to
create the control dynamically after the dialog has been shown. This is not possible
using MapBasic, so you have to create the dialog with a number of controls - as many
as you think there might be layers - and then show and hide these depending on how
many layers actually are used when the dialog is opened.
Have a look at this example:
***********************************************************''
Include "MapBasic.def"
Declare Sub Main
Declare Sub HandlerDialogLoad
Declare Sub HandlerCheckboxPicked
'**This holds the number of controls on your dialog
Define NUM_MAX_CTRLS 5
'-------------------------
Sub Main
Dim nNumLayers, nHeight As Integer
nNumLayers = 2 '**This is hardcoded here but should be dynamically
calculated before creating the dialog
nHeight = (nNumLayers * 30) + 30
Dialog
Title "SymbolPicker"
Height nHeight
Calling HandlerDialogLoad
'**This control is just used for sending a value to the handlers
Control EditText Position 5,5
ID 50
Value Str$(nNumLayers)
Hide
Control SymbolPicker Position 5,5 Width 25 Height 25
ID 110
Control CheckBox Position 35,15
ID 100
Title "Layer 1"
Calling HandlerCheckboxPicked
Control SymbolPicker Position 5,35 Width 25 Height 25
ID 210
Control CheckBox Position 35,45
ID 200
Title "Layer 2"
Calling HandlerCheckboxPicked
Control SymbolPicker Position 5,65 Width 25 Height 25
ID 310
Control CheckBox Position 35,75
ID 300
Title "Layer 3"
Calling HandlerCheckboxPicked
Control SymbolPicker Position 5,95 Width 25 Height 25
ID 410
Control CheckBox Position 35,105
ID 400
Title "Layer 4"
Calling HandlerCheckboxPicked
Control SymbolPicker Position 5,125 Width 25 Height 25
ID 510
Control CheckBox Position 35,135
ID 500
Title "Layer 5"
Calling HandlerCheckboxPicked
Control OKButton Position 5, (nHeight - 20)
Control CancelButton Position 45, (nHeight - 20)
If not CommandInfo(CMD_INFO_DLG_OK) Then
Exit Function
End If
End Sub
'-------------------------
Sub HandlerDialogLoad
Dim nLayers, i As Integer
nLayers = Val(ReadControlValue(50)) + 1
For i = nLayers To NUM_MAX_CTRLS
Alter Control (i * 100) Hide
Alter Control ((i * 100) + 10) Hide
Next
End Sub
'-------------------------
Sub HandlerCheckboxPicked
Dim nCtrl As Integer
nCtrl = TriggerControl()
If ReadControlValue(nCtrl) Then
Alter Control (nCtrl + 10) Show
Else
Alter Control (nCtrl + 10) Hide
End if
End Sub
***********************************************************
HTH,
Peter Horsb�ll M�ller
GIS Developer
Geographical Information & IT
COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark
Tel +45 6311 4900
Direct +45 6311 4908
Mob +45 5156 1045
Fax +45 6311 4949
E-mail [EMAIL PROTECTED]
http://www.cowi.dk/gis
Har du husket MapInfo Konferencen d. 8 og 9. september 2004.
Tilmelding samt yderligere information kan ses p�: http://www.cowi.dk/GIS
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, August 27, 2004 1:13 AM
To: [EMAIL PROTECTED]
Subject: MI-L Multiple Controls in a Dialog Box
Hello Listers,
I am curious if it is possible to place multiple Check Boxes as well as
multiple SymbolPicker controls in a Dialog Box.
My intent is to have the check boxes denote whether a point layer is drawn or
not, and that check box is related to the SymbolPicker Control adjacent to
it.
This way the end user would not only be able to decide whether the layers are
drawn but the style of points to use in the layers all from the same dialog
box.
At present I am attempting to develop a dialog box with four check boxes and
four
SymbolPicker controls, However I get an error stating that I cannot use the
"Control" command for the SymbolPicker after the checkboxes have been built.
I realize that I am probably doing something very stupid in my code but with
the lack of documentation in Mapbasic regarding Dialog Boxes I thought I would
give it a try by blindly crashing through it and typing as fast as I can to
see what developed.
Then I came to my senses and decided ask people more intelligent than me
whether it was even possible.
Thank you for any advice.
Jon Gramm
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 13102