From: anto@sol.acs.unt.edu (Anto Prijosoesilo)
Subject: Help: OWL problem
Summary: Dialogs with ComboBox causes hangs
Keywords: borland c++ owl combobox
Organization: University of North Texas
Date: Sun, 15 Nov 1992 23:00:59 GMT

Hi netters,

Can somebody tell me what I did wrong here? In this test app (an extremely
condensed form of an app I'm writing which still exhibits the problem)
I can choose File|New Dialog... to show the dialog. If I select OK the
dialog disappears and reappears (it's meant to do that). All is well up to
here. If I change the selection in the combobox, however, I can select OK
once and the second time it hangs my machine.

So, these work:

File|New Dialog, Cancel
File|New Dialog, OK
File|New Dialog, Change ComboBox' Selection, OK, Cancel

But this doesn't:

File|New Dialog, Change ComboBox' Selection, OK, OK

nor does this:

File|New Dialog, Change ComboBox' Selection, OK, Change ComboBox' Selection, OK

I'm including the source files below.

My compiler settings are:
Precompiled headers turned on,
Large memory model,
Smart callback,
All libraries are linked as DLL.

Thanks for any clues & help anybody can give me..

Desperately seeking, :-)

Anto.

<Included: CBoxTest.h>
#define CM_TestDlg	101
#define ID_TestCBox	101

<Included: CBoxTest.cpp>
// CBoxTest.cpp

// Test file for testing ComboBox transfer to/from a dialog

#define WIN31
#define STRICT
#define _CLASSDLL

#include <owl.h>
#include <combobox.h>
#include "cboxtest.h"

_CLASSDEF (TTestApp)
class TTestApp: public TApplication
{
public:
  TTestApp (HINSTANCE, HINSTANCE, LPSTR, int);
  virtual void InitMainWindow ();
};

_CLASSDEF (TTestFrame)
class TTestFrame: public TMDIFrame
{
public:
  TTestFrame (PTModule = NULL);
  virtual void CMTestDlg (RTMessage) = [CM_FIRST + CM_TestDlg];
};

_CLASSDEF (TTestDlg)
class TTestDlg: public TDialog
{
public:
  TTestDlg (PTWindowsObject, PTModule = NULL);
};

// TTestApp's member functions

TTestApp::TTestApp (HINSTANCE AnInstance, HINSTANCE APrevInstance, 
                    LPSTR ACmdLine, int ACmdShow):
  TApplication ("Test App", AnInstance, APrevInstance, ACmdLine, ACmdShow)
{
}

void TTestApp::InitMainWindow ()
{
  MainWindow = new TTestFrame;
}

// TTestFrame's member functions

TTestFrame::TTestFrame (PTModule AModule):
  TMDIFrame ("Test MDI App", "TestMenu", AModule)
{  
}

void TTestFrame::CMTestDlg (RTMessage)
{
  struct
  {
    PTComboBoxData CBxData;
  } XferBuf;

  XferBuf.CBxData = new TComboBoxData;

  XferBuf.CBxData -> AddString ("First String");
  XferBuf.CBxData -> AddString ("Second String");
  XferBuf.CBxData -> AddString ("Third String");
  XferBuf.CBxData -> AddString ("Fourth String");
  XferBuf.CBxData -> AddString ("Fifth String");

  PTTestDlg TheDlg;
  do
  {
    TheDlg = new TTestDlg (this);

    TheDlg -> SetTransferBuffer (& XferBuf);

  } while ((GetApplication () -> ExecDialog (TheDlg)) == IDOK);

  delete XferBuf.CBxData;
}

// TTestDlg's member function

TTestDlg::TTestDlg (PTWindowsObject AParent, PTModule AModule):
  TDialog (AParent, "TestDlg", AModule)
{
  new TComboBox (this, ID_TestCBox, 24, AModule);
}

int PASCAL WinMain (HINSTANCE AnInstance, HINSTANCE APrevInstance, 
                    LPSTR ACmdLine, int ACmdShow)
{
  TTestApp TestApp (AnInstance, APrevInstance, ACmdLine, ACmdShow);

  TestApp.Run ();

  return TestApp.Status;
}

<Included: CBoxTest.rc>
#include "windows.h"
#include "owlrc.h"
#include "cboxtest.h"

TestMenu MENU 
BEGIN
	POPUP "&File"
	BEGIN
		MENUITEM "&Test Dialog...", CM_TestDlg
		MENUITEM SEPARATOR
		MENUITEM "E&xit\tAlt+F4", CM_EXIT
	END

END


TestDlg DIALOG 18, 18, 102, 43
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Test Dialog"
BEGIN
	CONTROL "", ID_TestCBox, "COMBOBOX", CBS_DROPDOWNLIST | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 6, 17, 49, 57
	CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 64, 6, 32, 14
	CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 64, 23, 32, 14
	LTEXT "&Test List", -1, 6, 6, 49, 8, WS_CHILD | WS_VISIBLE | WS_GROUP
END

<Included: CBoxTest.def>
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 4096
STACKSIZE 5120

<End of included files>
Newsgroups: comp.os.ms-windows.programmer.misc