home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / tools / 1698 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.2 KB  |  92 lines

  1. Path: sparky!uunet!enterpoop.mit.edu!eru.mt.luth.se!kth.se!news.kth.se!hagelin
  2. From: hagelin@elixir.e.kth.se (Martin Hagelin)
  3. Newsgroups: comp.os.ms-windows.programmer.tools
  4. Subject: OWL & transfer to Combobox
  5. Message-ID: <HAGELIN.92Dec14141029@elixir.elixir.e.kth.se>
  6. Date: 14 Dec 92 13:10:29 GMT
  7. Sender: usenet@kth.se (Usenet)
  8. Distribution: comp
  9. Organization: School of EE, Royal Institute of Technology, Sweden
  10. Lines: 79
  11. Nntp-Posting-Host: elixir.e.kth.se
  12.  
  13.  
  14.  
  15. Hello everybody !
  16.  
  17. I have a problem with OWL and transfer to/from Comboboxes in a dialog.
  18. I try to display a combobox in a dialog and fill it with information
  19. but somehow the Gods aren't with me. I'm running BC++ v3.1 with OWL.
  20.  
  21.  
  22.  
  23. The code looks like this:
  24.  
  25.  
  26. struct TMyTransferStruct {
  27.   ...
  28.   PTComboBoxData pcbxdata;
  29.   ...
  30. };
  31.  
  32.  
  33. class TMyWindow : public TWindow
  34. {
  35.   ...
  36.   TMyTransferStruct MyTransferStruct;
  37.   ...
  38. };
  39.  
  40.  
  41. TMyWindow::DoTheBox()
  42. {
  43.   MyTransferStruct.pcbxdata = new TComboBoxData();
  44.  
  45. // Fill the list
  46.   MyTransferStruct.pcbxdata->AddString("bla bla");
  47.   ...
  48.  
  49. // Create the dialog and it's components
  50.   PTDialog MyDialog = new TDialog(this, ID_MYDIALOG);
  51.   ...
  52.   new TComboBox(MyDialog, ID_MYCOMBOBOX);
  53.   ...
  54.  
  55. // Set the TransferBuffer to my transferstruct
  56.   MyDialog->SetTransferBuffer(&MyTransferStruct);
  57.  
  58. // Do the dialog
  59.   if ( GetApplication()->ExecDialog(MyDialog) == MB_OK ) {
  60.     strcpy(answer, MyTransferStruct.pcbxdata->Selection);
  61.     ...
  62.   }
  63.  
  64. // problem statement
  65.   delete MyTransferStruct.pcbxdata;
  66. }
  67.  
  68.  
  69. Because I create a TComboBoxData with new, I must delete it
  70. afterwards. But if I do this, everything crashes the second time I run
  71. DoTheBox(), and if I omit the delete statement everything works fine
  72. for maybe 10 or 20 times then it crashes (probably because more and
  73. memory is taken by the TComboBoxData:s).
  74.  
  75. The manual is not very informative about transfering and especially
  76. not to/from comboboxes. Am I doing this totally backwards ?
  77.  
  78. From what I believe (not that I havn't studied the manuals), manages
  79. the ExecDialog() the deletion of the dialogbox and it's children when
  80. the routine is finished.
  81.  
  82. I'd sure appriciate some help on this subject, or some other solutions
  83. on how to get your transfer to/from dialog boxes to work. 
  84.  
  85.  
  86. /Martin
  87.  
  88. --
  89. --------
  90. Martin Hagelin
  91. hagelin@elixir.e.kth.se
  92.