Solved

Dialogs in a static library

Posted on 1998-07-02
11
492 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.
0
Comment
Question by:sdj
  • 5
  • 5
11 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1318634
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
 

Author Comment

by:sdj
ID: 1318635
If it's not a stupid question, what do I have to do to get it working?
0
 
LVL 7

Expert Comment

by:galkin
ID: 1318636
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
 

Author Comment

by:sdj
ID: 1318637
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
 
LVL 7

Expert Comment

by:galkin
ID: 1318638
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:sdj
ID: 1318639
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
 
LVL 7

Expert Comment

by:galkin
ID: 1318640
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
 

Author Comment

by:sdj
ID: 1318641
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
 
LVL 7

Expert Comment

by:galkin
ID: 1318642
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
 

Author Comment

by:sdj
ID: 1318643
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
 
LVL 1

Accepted Solution

by:
Arkadiy earned 50 total points
ID: 1318644
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wait notify demo infinite loop 3 81
Fibonacci challenge 11 84
noX challenge 17 77
how to split multiple lines delimiter : 8 55
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now