Link to home
Start Free TrialLog in
Avatar of sathishkumar
sathishkumar

asked on

Creating a view class as a resource

Hi,

Is it possible to have a view class as a resource in an MFC application? (i.e. defined in .rc and with a resource ID).If yes, how can it be done?

Thanks,
Sathish.
Avatar of AlexFM
AlexFM

Take a look on CFormView class, it is based on dialog resource.
Avatar of sathishkumar

ASKER

We have a view class(say ViewDll) in a dll inheriting from CView. In our application(exe) we have a different view class (say ViewApp) which inherits from CFormView.

As per the requirement, we are trying to have the ViewDll class inheriting from ViewApp.
When we tried to instantiate the ViewDll class, we get a compilation error saying "There is no default constructor available for ViewApp class".

The ViewApp class constructor accepts a resource id corresponding to the type of view needed. we are trying to achive this by

ViewDll :: ViewDll() : ViewApp(int ResourceID).

In this case also we get the same compilation error.


The compilation error is sorted out. But there is an link error saying that "cannot open file ViewDll.lib"...  The ViewDll.lib is supposed to be created after the ViewDll is built.

The exact message in my workspace is as follows:

LINK : fatal error LNK1104: cannot open file "../lib/ViewDll.lib"
LINK : fatal error LNK1141: failure during build of exports file
Error executing link.exe.

Avatar of DanRollins
A view is really a block of program code, while a resource is (almost always) a block of data.  I don't think there is any *normal* way to include a View as a program resource.

If the resource ID refers to a dialog resource, then that is possible, but your question is unclear as to that regard.

Please explain your need very specifically. Describe what you want the end result to be.
The end result is that I want to succeed in making the inheritance of ViewDll class from ViewApp class which are detailed below.

Details:
1) ViewDll class is in an dll application.
2)ViewDll is inheriting from CView.

1)ViewApp class is in an exe.
2)ViewApp class is inheriting from CFormView.
3)ViewApp class constructor takes a resource id as parameter corresponding to the type of dialog.

End Result: To inherit ViewDll class from ViewApp.

Problems encountered: While instantiating ViewDll class, we get a compilation error saying that There is no default constructor available for ViewApp class".
Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
     Notice one thing if you are not exporting any class or a function the .lib will not be created.First check the library is exporting the required class by using __declspec(dllexport) and then try with loading of the library.

-Surya.
sathishkumar,
Can you describe what you did to solve this problem?  All I did was "shotgun" several potential problem areas.  It would be good for the EE database if this question contained a short description of the actual solution that you used.  Thanks!

- Dan