Differences between Borland C++ 5.02 & 4.52

I have upgraded my Borland C++ compiler from v. 4.52 to 5.02.
But there seems to be some problems. I'm programming an MDI application,
been programming for some time, I am able to work with it only at weekends. So in this program I'm using a modal dialog box with some listboxes I want to include in transfer buffer. In older version this buffer works fine. But when compiled with newer version, it results an access violation error.

Doing it like:

struct TTransferFED {
   TTransferFED();
   uint Tag;
   TListBoxData valt;
   TListBoxData sanal;
};

TTransferFED::TTransferFED()
{
  Tag=BF_CHECKED;
}

class TEDialog : public TDialog
{
public:
   TEDialog(TWindow* parent,TTransferFED* trFed,TModule* module=0);
private:
   TListBox* valtied;
   TListBox* sanalist;
};

TEDialog::TEDialog(TWindow* parent,TTransferFED* trFed,
                             TModule* module)
    : TDialog(parent,"Search",module)
{
   valtied=new TListBox(...);
   sanalist=new TListBox(..);
   SetTransferBuffer(trFed);
}

and it is called:
TTransferFED trFed;

   if(TEDialog(this,&trFed).Execute()==IDOK) {
   ...
   }

The checkbox works correctly.

I don't now if there has been made some changes in class libraries or other
between these versions. I just don't have a clue about the problem.    
ekineeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexVirochovskyCommented:
Hm, it is very strange, i don't see
error in you text, but compare
with working example(of Borland), that
you can find in BC5\EXAMPES\OWL\TASKS\TRANSFER or
in my reply http://www.experts-exchange.com/jsp/qShow.jsp?ta=owl&qid=10230040 (5 pts).
0
JPMCommented:
When you use a TransferBuffer you must create the objects in the same order you declare them in the data struct.
what about uint Tag ?

Jean-Paul
0
ekineeAuthor Commented:
I have created checkbox comparing to Tag in correct order it is only missing from my question.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

JPMCommented:
Try out changing :
- constructor :
TEDialog::TEDialog(  ...... TTransferFED&  trFed ......

- call :
if(TEDialog(    this    ,   trFed)....

Jean-Paul

 
0
AlexVirochovskyCommented:
Hi, next is working example with you data:
transfer.h (not all values in use)
//----------------------------------------------------------------------------
// ObjectWindows
// Copyright (c) 1991, 1995 by Borland International, All Rights Reserved
//----------------------------------------------------------------------------
#define IDC_HSCROLL1        100
#define IDC_PUSHBUTTON1     101
#define IDC_PUSHBUTTON2     102
#define IDC_AUTOCHECKBOX1   103
#define IDC_AUTOCHECKBOX2   104
#define IDC_AUTOCHECKBOX3   105
#define IDC_EDIT1           106
#define IDC_EDIT2           107
#define IDC_LISTBOX1        108
#define IDC_DROPDOWNLIST1   109
#define ID_MENU             110
#define CM_DIALOG           111
#define CM_TRANSFER         112
#define CM_ADDLISTBOX       113
#define CM_ADDCOMBOBOX      114

#define IDD_DIALOG          200
#define ID_MRBUTTON         201
#define ID_MSBUTTON         202
#define ID_DRBUTTON         203
#define ID_NAMEEDIT         204
#define ID_ADDR1EDIT        205
#define ID_ADDR2EDIT        206
#define ID_CITYSTEDIT       207
#define ID_COUNTRYEDIT      208
#define ID_CHECKBOX1        209
#define ID_CHECKBOX2        210
#define ID_CHECKBOX3        211
#define ID_LISTBOX          212
#define ID_LISTBOXDATA      213
#define ID_COMBOBOX         214
#define ID_COMBOBOXDATA     215
#define ID_SCROLLBAR        216

#define ID_DISPLAY_INFO     300
#define ID_INFO             301

transfer.rc
//----------------------------------------------------------------------------
// ObjectWindows
// Copyright (c) 1991, 1995 by Borland International, All Rights Reserved
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
  #include <windows.h>
#endif
#include <owl/owlapp.rc>         // default owl app icon
#include <owl/except.rc>
#include <owl/window.rh>
#include "transfer.h"

ID_MENU MENU LOADONCALL MOVEABLE PURE DISCARDABLE
{
  PopUp "&App"
  {
   MenuItem  "&Dialog", CM_DIALOG
   MenuItem  "&Transfer", CM_TRANSFER
   MenuItem  Separator
   MenuItem  "&Exit", CM_EXIT
  }
}

IDD_DIALOG DIALOG 20, 25, 309, 188
STYLE WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU
CAPTION "Controls to transfer data from"
FONT 8, "MS Sans Serif"
{
 LISTBOX ID_LISTBOX, 6, 114, 50, 48, LBS_NOTIFY | WS_BORDER | LBS_SORT | WS_BORDER
 LISTBOX ID_LISTBOX+1,106, 114, 50, 48, LBS_NOTIFY | WS_BORDER | LBS_SORT | WS_BORDER
 DEFPUSHBUTTON "&Close", IDOK, 250, 166, 50, 14
}

transfer.cpp:
//----------------------------------------------------------------------------
// ObjectWindows
// Copyright (c) 1991, 1995 by Borland International, All Rights Reserved
//----------------------------------------------------------------------------
#define STRICT
#include <owl/pch.h>
#include <owl/applicat.h>
#include <owl/framewin.h>
#include <owl/dialog.h>
#include <owl/radiobut.h>
#include <owl/edit.h>
#include <owl/listbox.h>
#include <owl/combobox.h>
#include <owl/scrollba.h>
#include <string.h>
#include <cstring.h>
#pragma hdrstop
#include "transfer.h"

const MAXNAMELEN    = 26;
const MAXADDRLEN    = 47;
const MAXCITYSTLEN  = 27;
const MAXCOUNTRYLEN = 27;
const MAXLBDATALEN  = 30;
const MAXCBDATALEN  = 30;

const WM_DIALOG_CLOSED = WM_USER + 100;

#include <pshpack1.h>
struct TTransferFED {
  TTransferFED();
  TListBoxData valt;
  TListBoxData sanal;
  uint Tag;
};

#include <poppack.h>

TTransferFED::TTransferFED()
{
  Tag=BF_CHECKED;

  //
  // Pre-fill the listbox. It may be sorted, and/or multiselect
  //
  valt.AddString("Zebra");
  valt.AddString("Aardvark");
  valt.AddString("Ocelot");

  //
  // Pre-fill the combobox
  //
  sanal.AddString("Red");
  sanal.AddString("Pink");
}


//
// class TTransferDialog
// ~~~~~ ~~~~~~~~~~~~~~~
class TTransferDialog : public TDialog {
  public:
    TTransferDialog(TWindow* parent, int resId, TTransferFED& ts);
//    void CmAddListBox();
//    void CmAddComboBox();
    void EvDestroy();

    void CloseWindow(int ret);

  private:
    TListBox*   ListBoxValt;         // cache for transfer access.
    TListBox*   ListBoxSanal;         // cache for transfer access.
  DECLARE_RESPONSE_TABLE(TTransferDialog);

};

DEFINE_RESPONSE_TABLE1(TTransferDialog, TDialog)
  EV_WM_DESTROY,
END_RESPONSE_TABLE;

TTransferDialog::TTransferDialog(TWindow* parent, int resId, TTransferFED& ts)
:
  TDialog(parent, resId)
{
  ListBoxValt = new TListBox(this, ID_LISTBOX);
  ListBoxSanal = new TListBox(this, ID_LISTBOX+1);
  SetTransferBuffer(&ts);
}

//
// Lets transfer on close even though we are modeless
//
void
TTransferDialog::CloseWindow(int ret)
{
  TransferData(tdGetData);
  TDialog::CloseWindow(ret);
}


//
// Add a string to the list box.
//

void TTransferDialog::EvDestroy()
{
  // tell application that dialog is closing.
  //
  Parent->PostMessage(WM_DIALOG_CLOSED);
  TDialog::EvDestroy();
}


//
// class TTransferWindow
// ~~~~~ ~~~~~~~~~~~~~~~
class TTransferWindow : public TWindow {
  public:
    TTransferWindow(TWindow* parent = 0);
   ~TTransferWindow()
    {
      delete[] Label;
    }

    void CmDialog();
    void CmDialogEnable(TCommandEnabler& commandHandler);
    TResult EvDialogClosed(TParam1 wParam, TParam2 lParam);

  private:
    TTransferFED      TransferStruct;
    TTransferDialog*  TransferDialog;
    char*             Label;     // string to print on transfer.

  DECLARE_RESPONSE_TABLE(TTransferWindow);
};

DEFINE_RESPONSE_TABLE1(TTransferWindow, TWindow)
  EV_COMMAND(CM_DIALOG, CmDialog),
//  EV_COMMAND(CM_TRANSFER, CmTransfer),
  EV_COMMAND_ENABLE(CM_DIALOG, CmDialogEnable),
  EV_MESSAGE(WM_DIALOG_CLOSED, EvDialogClosed),
END_RESPONSE_TABLE;


TTransferWindow::TTransferWindow(TWindow* parent)
:
  TWindow(parent)
{
  Label = new char[1024];
  Label[0] = 0;
  TransferDialog = 0;
}

//
// Create modeless dialog.
//
void
TTransferWindow::CmDialog()
{
  TransferDialog = new TTransferDialog(this, IDD_DIALOG, TransferStruct);
  TransferDialog->Create();
  TransferDialog->ShowWindow(SW_SHOW);
}


//
// Disable the 'App|Dialog' menu item if dialog is already active.
//
void
TTransferWindow::CmDialogEnable(TCommandEnabler& commandHandler)
{
  commandHandler.Enable(!TransferDialog);
}

//
// The dialog has closed, notified by dialog.
//
TResult
TTransferWindow::EvDialogClosed(TParam1, TParam2)
{
  TransferDialog = 0;
  return 1;
}


//
// class TTransferApp
// ~~~~~ ~~~~~~~~~~~~
class TTransferApp : public TApplication {
  public:
    TTransferApp()
    :
      TApplication("TransferTest")
    {
    }

    void InitMainWindow()
    {
      TFrameWindow* frame = new TFrameWindow(0, "Test Dialog Transfer",
        new TTransferWindow);
      frame->AssignMenu(ID_MENU);
      SetMainWindow(frame);
    }
};

int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
  return TTransferApp().Run();
}

I hope, this helps. Alex
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JPMCommented:
Alex , it 's funny to seeing you 've just sent the example
provided in the ../examples/owl/tasks/transfer of the BC5  directory.  :))

may be the Borland team members should get the points  ;-))

Jean-Paul



 
0
AlexVirochovskyCommented:
JPM:
1. See my 1-st comment (from 12.12.99)
2. I 've changed this example for
  ekinee data
0
ekineeAuthor Commented:
I've found that when I put both listboxes and checkbox in the buffer, it doesn't work. But when I use them separately it does work. For my wiev I create them correctly.

struct TTransferFED {
        TTransferFED();
        uint Tag;
        TListBoxData valt;
        TListBoxData sanal;
};

class TEDialog : public TDialog
{
public:
    TEDialog(TWindow* parent,TTransferFED* trFed,TModule* module=0);
private:
     TListBox* valtied;
     TListBox* sanalist;
};

TEDialog::TEDialog(TWindow* parent,TTransferFED* trFed,
                             TModule* module)
        : TDialog(parent,"Search",module)
{
        ... I also create other stuff in this part which I disable with                                DisableTransfer() ...
        new CheckBox(...);
        valtied=new TListBox(...);
        sanalist=new TListBox(..);
        SetTransferBuffer(trFed);
}

Changing constructor doesn't help.  
0
AlexVirochovskyCommented:
Hi, i make ~same thing, and all works
May be:

>>new CheckBox(...); ->not !
 change to
 tCheckBox =  new CheckBox(...);
where tCheckBox must be in class, of course.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.