|
WHat are the special things to be done to make the toolabr button and a corresponding menu item both run the same code? Would one give the same ID to both the button and the menu item? Is that legal?
Thanks,
ns
|
|
|
|
|
ns wrote:
Would one give the same ID to both the button and the menu item?
Yes.
ns wrote:
Is that legal?
Yes.
--------
PMGRE --Shog9 --
|
|
|
|
|
That worked. I tried making a getToolbar() public method in mainframe returning the toolbar object created in CMAinFrame, but it said no copy constructot available. SO I'll put my code in the frame class, though theres data involved that I'm not sure the frame needs to know about...
Thanks a million,
ns
|
|
|
|
|
I have a 3rd party library that shipped with only the DLL itelf and a header file with function prototypes and constants. All the procedures inside the DLL are declared using the dllimport keyword. Does this mean that I can't dynamically link into this DLL at runtime because none of the functions were exported? I've already written an app that links to this DLL statically, and that works fine, but I'd rather use dynamic linking.
Everything I've read so far points me to the fact that since there isn't a .DEF file, and the functions aren't declared using dllexport, I can't dynamically link to this library. Am I right?
Thanks guys...
-Mike Zinni
email: mzinni@rimail.com
AIM: zin9999
|
|
|
|
|
Do you have a lib file? You should be able to link with it.
Best regards,
Alexandru Savescu
|
|
|
|
|
Yes. I have the .LIB file and the directory is included in my Tools->Options->Directories->Library files settings. I wrote the following code to link to the DLL.
typedef int (CALLBACK* LPOMNICREATEFUNC)(void);
BOOL COmniDoc::LoadOmniLibrary()
{
m_bOmniLoaded = FALSE;
m_hOmniLibrary = LoadLibrary("SD2.dll");
if(m_hOmniLibrary)
{
m_bOmniLoaded = TRUE;
m_lpfnSD_Create = (LPOMNICREATEFUNC)GetProcAddress(m_hOmniLibrary, "SD_Create");
}
return m_bOmniLoaded;
}
m_lpfnSD_Create is of type LPOMNICREATEFUNC.
LoadLibrary returns a valid handle, but the m_hlpfnSD_Create variable is set to NULL after the call to GetProcAddress...
-Mike Zinni
email: mzinni@rimail.com
AIM: zin9999
|
|
|
|
|
OK. Made some progress. I used the Depends tool that comes w/ VC++ and found out that the names of the exported functions are all messed up. That "SD_Create" procedure is actually exported as "_SD_Create@0". Now I'm at least returning a valid function pointer.
Is there any particular reason that the name is changed like that? And secondly, if I didn't use the Depends tool, how in the HELL was I ever supposed to come up with that?
-Mike Zinni
email: mzinni@rimail.com
AIM: zin9999
|
|
|
|
|
mikez99 wrote:
found out that the names of the exported functions are all messed up. That "SD_Create" procedure is actually exported as "_SD_Create@0".
That's not messed up, that's the usual name mangling taking place for PASCAL (aka __stdcall) calling convention functions.
|
|
|
|
|
No, thats not name mangling for C-style __stdcall calling convention, but is the name mangling of the C++ compiler (so called "decorated names").
The reason for this is that C++ supports overloading, but at link time every function identifier needs to be unique. So the C+++ compiler codes the numer and types of the functions arguments into the name and links against this name. The @0 in you case indicates a function without arguments.
Note that decorated names are always used if the functions are exported with __declspec(dllexport).
If possible you should link against the .lib file and so implictly load your DLL. You may also use the VC6 and above delay load feature.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Why do I get an access violation when I try to get the value of the iterator "it" in this piece of code? When I look at the iterators they have no valid pointers to the strings.
typedef vector<CString*> TFileList;
typedef TFileList::iterator TFileListIt;
CStringList strlistFiles;
fsDlg.SelectFile(&strlistFiles);
int nFiles = strlistFiles.GetCount();
if (nFiles > 0)
{
int nIndex;
TFileList FileList(nFiles);
CString strFileName, strNewFileName;
POSITION pos;
for (nIndex = 0; nIndex < nFiles; nIndex++)
{
pos = strlistFiles.FindIndex(nIndex);
FileList.push_back(&strlistFiles.GetAt(pos));
}
TFileListIt start, end, it;
start = FileList.begin();
end = FileList.end();
for (it = start; it != end; it++)
{
TRACE("> %s\n", **it);
}
}
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
Try *(*it)? (Just guessing ).
Best regards,
Alexandru Savescu
|
|
|
|
|
The problem is that my vector seems to be empty, even though I am filling it with valid pointers.
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
Did you call size() to see if it is empty?
Best regards,
Alexandru Savescu
|
|
|
|
|
size() returns 8, but I have added 4 pointers to the vector.
I have noticed that the vector elements does not point to m_pchData of the string list elements I am using, but to some other address.
_First and _Last of the vector are updated when adding to the vector.
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
Try not to store pointers, store CStrings directly. There is not much of a performance differnce since the CString does not get copied, its reference is increased.
Best regards,
Alexandru Savescu
|
|
|
|
|
Nah, didn't work either. The push_back seems broken...
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
It's this line:
Fredrik Skoog wrote:
TFileList FileList(nFiles);
This creates nFiles items initially empty and I guess NULL pointers. That's why you had 8 items, because 4 have already been created.
You shoud use:
TFileList FileList;
FileList.reserve (nFiles);
reserve allocates enough space, but does not create any items.
Best regards,
Alexandru Savescu
|
|
|
|
|
Yep, that's it. Thanks a million!
I think I'll have to hit the books now
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
Hi...
I've a class MyClass which contain a member CFile m_MyFile.
I want to pass this file (open) to another class CMyOtherFile derived from CFile...
I tested while passing the handle of m_MyFile but that doesn't work (and it's not recommanded)...
Anybody can help me???
Thanks...
Hello World!!!
from Raphaël
|
|
|
|
|
If I understand you correctly, I think you should rethink your design strategy.
I think it might be better to pass the file name if possible.
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
Of course... I've found another solution... A better solution...
Thanks...
Hello World!!!
from Raphaël
|
|
|
|
|
Hi,
I have an MDI CFormView that makes itself the exact size of the outer frame, and resizes with it. However, you can still grab the right bottom edge and size the child viewform independently. I want this to not happen. The user should not be able to resize just the child form, only the outer frame with which the child form resizes faithfully as it is currently written.
Thanks,
ns
|
|
|
|
|
I think
cs.style &= ~WS_THICKFRAME;
in the child precreate is doing what I want. Thanks!
ns
|
|
|
|