2 dialog boxes error mapbasic

161 views
Skip to first unread message

Snashall, Scott (0610930)

unread,
Apr 10, 2014, 8:47:34 AM4/10/14
to mapi...@googlegroups.com

Hello all,

 

I have an application that opens a custom dialog box(dialog 1). Dialog 1 has a listbox(listbox1 (control id 1) and a custom button(control id 2) within it. When the user clicks the custom button another dialog box(dialog 2) is opened where the user enters data. based on the data from the user an array is updated which I would like to update into Dialog 1 listbox1(control id 1). Currently when I do this I get an error Invalid control id 1. Question is there a way to make dialog 1 the active dialog  after Dialog 2 has been removed?

 

Any help is appreciated

 

Thanks


Scott

 

Bill Thoen

unread,
Apr 10, 2014, 4:09:17 PM4/10/14
to mapi...@googlegroups.com
If dialog #1 invokes dialog #2, when you then execute a dialog remove command on #2, it should close and leave you where you were on dialog #1 when you called #2. However, while dlg #2 is open and active you can't touch anything in #1. But dialog boxes are probably the biggest source of vexation in programming MapBasic, so read the doco carefully and believe it when it says that "such and such" behavior occurs only when called from an OK button control, etc. no matter how arbitrary or inconsistent it seems.
--
Bill Thoen
GISnet - www.gisnet.com
303-786-9961

James Moloney

unread,
Apr 15, 2014, 3:03:16 AM4/15/14
to mapi...@googlegroups.com
Hi Scott,
 
This should do what you want. Compile this simple example to get the idea?
 
Hope this helps
 
Cheers
 
James
 
 
Include "Mapbasic.def"
 
Declare Sub Main
Declare Sub AddItemDialog
Declare Sub AlterMainDialog
 
Dim gsaListItems() as String
'---------------------------------------------------------------------------
Sub Main
 
   Dialog Title "Main Dialog"
      Control StaticText Title "List"
      Control PopupMenu ID 1 Title from variable gsaListItems Width 100
      Control Button Title "Add Item" ID 2 Calling AddItemDialog
      Control OkButton
      Control CancelButton
 
End Sub
'---------------------------------------------------------------------------
Sub AddItemDialog
  
   Dim strAddItem as String
  
   Dialog Title "Add Item Dialog"
      Control EditText Width 100 Into strAddItem
      Control OkButton Title "Add" Control
      CancelButton
 
   If CommandInfo(CMD_INFO_DLG_OK) Then
      Dim i as Integer
      i = Ubound(gsaListItems)
      Redim gsaListItems( i + 1)
      i = Ubound(gsaListItems)
      gsaListItems(i) = strAddItem
     
      Call AlterMainDialog
   End If
 
End Sub
'---------------------------------------------------------------------------
Sub AlterMainDialog
 
   Alter Control 1 Title from variable gsaListItems
 
End Sub
'---------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages