We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Dialogs in a static library

sdj
sdj asked
on
Medium Priority
524 Views
Last Modified: 2013-11-19
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.
Comment
Watch Question

Commented:
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.
sdj

Author

Commented:
If it's not a stupid question, what do I have to do to get it working?

Commented:
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.
sdj

Author

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!

Commented:
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.
sdj

Author

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?

Commented:
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.
sdj

Author

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.

Commented:
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.
sdj

Author

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!
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.