[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 511
  • Last Modified:

Dialogs in a static library

Is it possible to add dialogs, and possibly use the ClassWizard when writing a static library? I have written a static library that handles dib images, and want to add a dialog for setting properties, however their is no resource tab, and there is no class wizard.

I selected the "Win32 Static Library" option from the project wizard and I dynamically link to the MFC library. I am using VC 5.0 SP3.
0
sdj
Asked:
sdj
  • 5
  • 5
1 Solution
 
galkinCommented:
Yes it is possible. When you create static library AppWizard doesn't specify that you want to link you library with MFC. Also only project fil is created and no sources are generated.
0
 
sdjAuthor Commented:
If it's not a stupid question, what do I have to do to get it working?
0
 
galkinCommented:
If you create static library you need first enable MFC in your peoject. go to Project->Settings and add MFC support choosing MFC as shared or static library from combo box. Then you need to to include MFC header files. I would suggest you create MFC DLL, add whatever classes and functions you want using ClassWizard. Then copy code from DLL project to static library project.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
sdjAuthor Commented:
I'm not sure this is really answering my original question. Perhaps I should try to clarify. I have written a static library it does use MFC it works fine.

The problem is, the ClassWizard menu is disabled and there is no tab for resources. I can add a resource file, but it does not get added to my code so I can not use it.

For simple resources such as cursors, I have created a resource only DLL, but what I really want to do is add a dialog and let classwizard wrap it up for me. But I can not do this under the static library project. Is there a particular reason why the classwizard is disabled? Perhaps there is a setting in the project files, if it was only the clw file then this would be regenerated when you selected classwizard!
0
 
galkinCommented:
ClassWizard is disabled when project is static library. Thre is nothing to do here. ClassWizard is enabled only when MFC is enabled initially when project is created using AppWizard. I suggest you creating some dummy project with MFC add classes there using Classwizard and then copy code to original project.
0
 
sdjAuthor Commented:
If this is the case, what happens to classes based on CDialog that are set to a resource ID in the DLL resource file when it gets transferred into the static library project?

Is it possible then to also compile the resource file into the static library?

e.g.

CMyDialog::CMyDialog() : CDialog(CMyDialog::IDD);

CMyDialog::IDD, generally resolves to a dialog resource ID, how do I make my static library resolve to the same resource ID?
0
 
galkinCommented:
you need to add new resource file into your static library project. Then resource pane will be added. So you can now add new resources or copy from existing projects. resource.h file will also be generated.
0
 
sdjAuthor Commented:
That is the problem! You can add a new resource file via:
new->resource script. The resource pane does *NOT* get added to the workspace view however.
0
 
galkinCommented:
Add new resource file. Open Files pane in project window. Select your resource file by double clicking on it. You will see resource file icon. Open resource file you want to copy resources from. Tile these window vertically or horizontally.Select resources you want to copy and now draw them onto your resource file icon.

You are right resource pane doesn't not appear in project window but you can manage resources in the way I showed you.
0
 
sdjAuthor Commented:
I'm probably being really stupid here but: You can do this, and I have, before posting to this group, but the resource file does not get compiled into the static library.

Am I still missing some crucial "tick" in the settings that tells the resource compiler to work? In the Project settings for a static library the resource compiler tab is disabled!
0
 
ArkadiyCommented:
Well, the sad truth is that static libraries cannot contain resourses. It is simply a matter of file format. So, the resourse compiler will never be enabled, and the class wizard will never be smart enough to recognize the resources. A workaround: create a dummy MFC application or DLL project, include it in your static lib as subproject. The resource file for the dummy app  will be the resource file you actually use when you link your static library to where it belongs (beware, the app or dll using your static library must provide the resources!). Then you use the class wizard in dummy project to create your dialogs, and you include the dialogs in your real project.
If you really want to have resources in a statically linked library (as opposed to using the resources of app/dll it's linked to), that is not a small feat. You will need to extarct the dialog template from the resource file it's in, link the resulting binary data into your lib as a big byte array, and, when you create a dialog, pass the pointer to that array as a template. I've never done this, just theory here.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now