How can a .rc file be converted to .resx?

N

nick.n.xu

Not sure if this question was posted before.
When I loaded an app.rc file from VC++ 6.0 to VC .NET 2003, I can see
all screens in resource view. But when I right-clicked and did 'add a
class' and tried to attached a class to a dialog or screen, I found out
that I am only able to add MFC class like CDialog. I can not attach
..NET class like WindowForm. So my question is that do we have some way
to convert a dialog defined in .rc file to one in .resx? Does .NET
support this kind of migration? Do we have to always start from scratch
to create a WindowForm-based dialog? I got hundreds of dialogs created
in VC++ 6.0 and wanted to reuse them in .NET framework.

Thanks in advance.

Nick
 
C

Carl Daniel [VC++ MVP]

Not sure if this question was posted before.
When I loaded an app.rc file from VC++ 6.0 to VC .NET 2003, I can see
all screens in resource view. But when I right-clicked and did 'add a
class' and tried to attached a class to a dialog or screen, I found
out that I am only able to add MFC class like CDialog. I can not
attach .NET class like WindowForm. So my question is that do we have
some way to convert a dialog defined in .rc file to one in .resx?
Does .NET support this kind of migration? Do we have to always start
from scratch to create a WindowForm-based dialog? I got hundreds of
dialogs created in VC++ 6.0 and wanted to reuse them in .NET
framework.

AFIAK you have to start from scratch. You might do some googling around -
maybe someone's made a dialog resource -> winforms convertor, but I'm pretty
sure there isn't any such functionality "out of the box" for visual studio.

-cd
 
O

Olaf Baeyens

When I loaded an app.rc file from VC++ 6.0 to VC .NET 2003, I can see
all screens in resource view. But when I right-clicked and did 'add a
class' and tried to attached a class to a dialog or screen, I found out
that I am only able to add MFC class like CDialog. I can not attach
.NET class like WindowForm. So my question is that do we have some way
to convert a dialog defined in .rc file to one in .resx? Does .NET
support this kind of migration? Do we have to always start from scratch
to create a WindowForm-based dialog? I got hundreds of dialogs created
in VC++ 6.0 and wanted to reuse them in .NET framework.
There is no automatic conversion form res file to the .NET verison. They are
too different.

You are probably refering about one dialog box template reused by different
parts of the program?

If you inherit from System.Windows.Forms.UserControl then you can create
your own custom controls by drag and drop.
Then later you can create another UserControl and drag your previously
created custom UserControl, so you can build controls on controls on
controls.
So no, you do not have to create every reoccuring form with minor changes
from scratch, you can create complete buildingblocks very easily. Even my
grandmother can do that.

I think this is called form inheritance.
 
N

nick.n.xu

Carl and Olaf. Thanks so much for your input and ideas.
Olaf, I am new to .NET and not quite follow the way you described
here(using System.Windows.Forms.UserControl). Do you have some examples
or links I can play with it?

Appreciate your help.
 
O

Olaf Baeyens

Olaf, I am new to .NET and not quite follow the way you described
here(using System.Windows.Forms.UserControl). Do you have some examples
or links I can play with it?
I believe that this link will help you a little further:
http://www.akadia.com/services/dotnet_user_controls.html

It is C# but these controls can then be used in managed C++.
You will discover that mixing C#, VB.NET and managed C++ is fun. :)
Although at this moment, you cannot create one dll (assemblie) with C# and
managed C++ together. You must crate a C# assemblie (dll) and then use it in
the managed C++. But I believe that VS2005 could do just that.

This way you can create custom controls in a modular way.
One example is I have a static text a slider and a spinbutton together in a
usercontrol (looks like a form) then I put the code behind it that
synchronizes the spin button with the slider and the other way around. The
static text is used as description.

Now in a late stage, I create another usercontrol and put these
slider+spinbutton control on that newly created usercontrol. I use this to
move something in a 3D scene , so I have an X, Y and Z slider+spinbutton.

Finally in my result project I use that last created custom control by drag
and drop.
So you can create a custom control using other custom controls using other
custom controls using ....

Coming from a MFC C++ backrgound moving into the .NET way of thinking will
be a steep learning curve, but it is very rewarding and you will notice that
the develop cycle is far much shorter. I prefer C# now since it is a
lightning fast compiler, but other parts of my code is still C++ too.

There is one issue about .NET that you must be aware of, that it has an
increased security so your programs might not run imemdiately on a machine
when you try to access a LAN folder or Internet. The administrator of that
machine should give enough execution rights, but luckily enough if you
create a setup project, no need of advanced user knowledge is needed if you
wish to distribute a program that needs LAN and Internet access. This
configuration could be done automatically.

One thing I wish Microsoft would implement in the next .NET is a user
friendly way of saying that this program does nt have enough rights to
execute on that machine. Right now, you get a scare error that looks like an
access violation dialog box, and it will take the user years of
psychotherapie to recover from that trauma. ;-) One solution might be a
dialog box with a simple explanation that this program might not have enough
rights to run or that the .NET framework is not installed yet, and an
advanced button the gives more details.

Another problem is that installing the .NET framework is aparently a very
scary thing to do, since I have had so many users now that just refuses to
install it. You have no idea what reasoning they had not to install the .NET
framework but all based on superstition. Luckily, it is getting more and
more accepted. I still believe that Microsoft should have promoted the .NET
installation on the Windows updated like they did with SP2.

Have a lot of fun :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top