Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dialogs and libraries...can't get DoModal to work 1

Status
Not open for further replies.

txjump

Programmer
May 17, 2002
76
US
Hello all,

ive created a class that has a dialog box. i first tested it as an exe, then i moved it to a dll, tested the dll and it works fine from there. then i decided that i didnt want it in a dll but want to make it a library for static linking. so i started shifting it to a library compile and testing.

i have an exe that tries to use the library (everything compiles fine). the dialog class is instantiated...but when it comes down to DoModal, nothing shows up. im still new to MSVC and dialog boxes. could anyone give me an idea as to what im missing?

Code:
	msgBox lmg;
	lmg.showAfxMsgBox();  //just a test function to make
                              //sure the class is working
	int retVal = lmg.DoModal();
	char temp[30];
	sprintf(temp, "rcvd: %d", retVal);
	AfxMessageBox(temp, MB_OK, 0);

any help would be greatly appreciated. :)
txjump
[ponytails2]
 
you are probably missing something in the resource definition. Perhaps you have not included "resource.h" in your library OR the "resource.h" you are including is an older one which doesn't have the resource ID for the dialog. If this isn't the problem then the problem is almost certainly something to do with the resource ID.
Is your dialog resource in the project that contains the library?
 
hi qednick,

it's in the resource file for the library project. there's only one resource file for that project and it is included in the library header file. :-(

if a resource id is missing, don't you usually get a compile error?

thanks for the suggestion, any other ideas?
txjump
[ponytails2]
 
Try sticking the dialog resource in the actual .exe project file rather than the .lib project. You should find it'll work.

:)
 
the thing is that i have to create several dll's and i want them all to use the same dialog box. so instead of repeating code id like to put it in a .lib and statically link them.

im trying to refrain from using a dll for the dialog (which already works) because then my dlls would use a dll. which means there's a chance that it wont work if the dialog dll isnt in the right place.

but, im trying one last thing and if it doesnt work out, then im just gonna use the same class files and import them into each dll project workspace. grrrr...but it would work.

thanks for the suggestion though!
txjump
[ponytails2]
 
I tend to create dialogs, fill in the classes and then make a .lib of the class files (keeping the dialog resource in the .exe project). I then remove the dialog classes from the project and add the lib instead. Makes the whole thing compile so much faster!!! I think a better bet for you would be to do the same and simply import the .lib into each project BUT copy and paste the dialog resource into each project also. It'll compile faster and keep things neater.

:)
 
I don't know how you do the static linking but i am doing this way:
- I create the dll
- I copy the files with .dll, .lib, .h extensions, where I want to use it
- I include the header of MyDll in the header of my executable:
#include "MyDll.h"
#pragma comment (lib,"MyDll.lib")

 
viorel,
i have tried that and ive got it working. but i dont want to use a dll. i want it all compiled together. thanks though. :)


qednick,
i will try that, im still not used to using resource files and i think that is the problem im having. the resource file for the .lib is not in the right spot. which you mentioned before, but i didnt realize i should move it out of the lib project and into the exe project.

how do you handle multiple resource files? for example: say you create three library files each w/ their own resource. then you start creating your exe code. is it as simple as renaminging your .rc files? and any references to them?

thanks for your help qednick. [wink]
txjump
 
oops...

i just remembered the .rc files are named after the project. so i guess that answers my question. (i was thinking of the resource.h files)

[ponytails2]
 
qednick! it worked! :-{}

thank you! thank you! thank you! [sunshine]

txjump
 
no prob: BTW... how do you get all those different emoicons on here? :)
 
below the area where you type your message is a link for "emoticons/smileys"...click there to see them in a separate window.

type or copy/paste the phrases into your message. then just make sure that you put a check mark in the box next to "emoticons/smileys". it should automatically select the box for "process tgml".

(no spaces)
[party ] = [party]
[ponytails2 ] = [ponytails2]

you can even put in links to your own emoticons, like if you have some on your web site. you can see the syntax for that in the "process tgml" link.

happy emoticonning ;-)
 
Ahhh, it never even crossed my mind to click on the Emoticons/Smileys link for a list!!

Good one!
[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top