Solved

Upgrading VC++ 1.53 app to VC++ 5.0

Posted on 1998-09-23
8
393 Views
Last Modified: 2012-05-04
Platform: Win95/Win32, Compiler: VC++ 5.0 (Visual Studio)

I have an application wich was made in Visual C++ v.1.53. It uses the VBX-control GRID.VBX to display data in grid-form.

Now I'm going to upgrade the app. to Visual C++ v.5.0, and had two immediate problems upon trying to build the converted app. (automatic upgrade in VC). The first was the _near keyword, wich I was told is obsolete, and that it just can be removed as it isn't neccesary in the Win32 development platform.

The second problem is the VBX-comtrol, wich I have to replace with the GRID32.OCX.

I'm a novice to C++, and C also, for that matter, and would like an easy to understand explanation to what steps I have to undergo to make this application work with the GRID32.OCX instead of the old VBX.

WR
O.E. Auran
0
Comment
Question by:oddau
8 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1173541
I can confirm that just need to remove the near and far keywords.  Or you can use
#define _near
#define _far
to define them "nothing".  Then they won't cause problems and can be deleted more liesurely.
0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1173542
Near and Far are not used in the win32 flat memory model. All data is automatically declared with far (32bit) access. This means that the near keyword does not apply and the far keyword might not give you any problems. It only determines where in memory the variables live and thus should not change the working of your code. (Local variables that are stored on the heap are a bit different but they will work so do not worry, since you claim to be a novice I will try not to go into too much detail)

The interfaces and fucntion calls should look much the same. If you are lucky you can just replace grid.vbx with grid32.vbx without too much effort. If the interfaces are the same (as they should be) the code will work without modification.
0
 
LVL 2

Expert Comment

by:shchuka
ID: 1173543
Actually, that would be grid32.ocx

I've gone through the convertion the code for grid.vbx to grid32.ocx.  While most interfaces are the same, some are different, plus some Get/Set methods have changed a bit.  Unfortunately, I don't have the code of that now (I did that about 3 years ago with VC 4.0), but in general, it's not much trouble at all.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:oddau
ID: 1173544
Hi, and thanks for the replies. I tried to add the GRID32.OCX, and got the classes for the control installed, however when trying to replace the visual control of the VBX with the new (OCX), GRID control, I got a message saying that I didn't have a runtime-licence for the control. That made me mad, and I replaced the GRID32.OCX with the MSFLEXIGRID control instead.

The methods for this OCX was quite similar, except for the syntax, and the conversion went well. (Apparently well, that is, I still haven't got the chance to see for myself).

The problem I now am left with is the .RemoveItem and the .AddItem methods.
The VBX-way to do this was to include a string parameter, and a integer for the rowindex.

This is not true with the FlexiGrid control however. I have tried to convert the int to a long, but this is not the way to do it either. The Visual Basic help topic for this control says the second parameter is a Long, and that it is optional.

The error I get is this:
---
  CREDITINFORM: C:\Program Files\DevStudio\MyProjects\VC\CreditInform\BenchMark\Sokresul.cpp
C:\Program Files\DevStudio\MyProjects\VC\CreditInform\BenchMark\Sokresul.cpp(132) : error C2664: 'AddItem' : cannot convert parameter 2 from 'long' to 'const struct tagVARIANT &'
C:\Program Files\DevStudio\MyProjects\VC\CreditInform\BenchMark\Sokresul.cpp(274) : error C2664: 'AddItem' : cannot convert parameter 2 from 'const int' to 'const struct tagVARIANT &'
Generating Code...
Error executing cl.exe.
Creating browse info file...

BenchMrk.exe - 2 error(s), 2 warning(s)
---

WR
O.E. Auran

0
 
LVL 1

Author Comment

by:oddau
ID: 1173545
Do someone have the spesifics of the .AddItem method call on the MSFlexiGrid-control, and how to implement such calls? I don't get the meaning of the tagVariant parameter...

Pleez help now!

O.E. Auran
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1173546
struct tagVariant is of the dispatch type variant. The tag variant is just something that you can use for your own purpose. So if you do not use it you can pass a reference to a 0 pointer.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 500 total points
ID: 1173547
Mirkwood's comment is incoherent; please ignore it.

The parameters for the wrapper function generated by the gallery are LPCTSTR and a const VARIANT&.  If you read the documentation for this method on the control, you'll find that it takes two parameters: a string (which is the item) and an index, which is the item within the control where the new row is to be placed.

You need to construct a VARIANT that contains that information. A VARIANT is a structure which allows data to be passed safely from one OLE object to another. OLE requires this because it might have to step in and marshall the data--translate the data as it's being passed so it makes sense to both the giver and the receiver.

The documentation also says that the parameter is optional.  If you don't want to pass the parameter, you still have to make a variant--just make the variant empty. So, to pass nothing:

    COleVariant varEmpty;
    m_FlexGrid.AddItem("Column1\tColumn2", varEmpty);

to pass 35 as an 2-byte integer:

    COleVariant varNumber((short) 35, VT_I2);
    m_FlexGrid.AddItem("Column1\tColumn2", varNumber);

I used a cast to make sure I got the right COleVariant constructor. Since variants can handle so many types, the constructor is heavily overloaded and I have to be careful here.  The type of the variant is given by "VT_I2". If you look at the COLeVariant documentation, you'll see the other types available.

For other functions which require variants, you'll need to formulate the call and variant yourself. By reading the documentation for the control, you can deduce the type of variant you need from the context. For example, numbers are almost always VT_I2 or VT_I4.

B ekiM

0
 
LVL 1

Author Comment

by:oddau
ID: 1173548
This has been a question under construction, and I got a little help from most of the comments, and the answer from fellow biker Mike was satisfactory, although I recently found the answer for this from an other source. (I got tired of waiting).

So, thanks to everyone who made the effort!

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question