|
It's all in msdn
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Using Visual Studio 2002 and i can't find a "Callers Graph" view like the one that is in VC6. Am i a dope or did they leave it out?
-pete
|
|
|
|
|
it's not called "Callers Graph"!!!
it's called "Call Stack"!!!
have a look at the help files, maybe this term helps...
Don't try it, just do it!
|
|
|
|
|
Thanks Alexander, but it's not the same thing. In VC6 there was both a "Callers Graph" and a "Call Graph" that could be viewed starting from a function. They are not actually graphs but rather a tree control. It was part of the "Browser" functionality. Definitely not the "Call Stack" which is the current running context of course. Quite handy actually, it is very sad if it was left out of VC7 "Browser".
P.S. Are you always that easily exited? All those exclamation characters just seem to fly off your keyboard
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Hi all
I wrote a simple win32 dll (non MFC) and tried to invoke its functions using run-time Loading (LoadLibrary). When I call GetProcAddress() function it returns me always NULL.
I checked in Dependency Walker tool this dll add saw that in some reason to all exported symbols were added some gibrish. for instance: function Foo() is writen like this: ?Foo@@YAHHH@Z. So when i give GetProcAddress() function name it never finds it
strange...
Have any ideas why? and how can i sole this?
b.w.: I'm using VC6 and win XP
thanks.
|
|
|
|
|
Edit your .def-File like this:
EXPORTS
Foo=?Foo@@YAHHH@Z
There must be some option to partially disable name mangling of exported functions, but I can't find it right now :/
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Anonymous wrote:
I wrote a simple win32 dll (non MFC) and tried to invoke its functions using run-time Loading (LoadLibrary).
This does not indicate that two DLLS are being used. I presume this is not the case and that there are actually two DLLS, one MFC and the other non-MFC. Yes?
Are the exported functions written in C++? If so, it sounds like name-mangling is at work here.
|
|
|
|
|
bad answer greg!!!
i assume u defined your function like this:
void __declspec( dllexport ) foo()
{
...
}
this causes c++ name convention when using a c++ compiler!
to get a c export(which u want), use:
extern "C" void __declspec( dllexport ) foo()
{
...
}
Don't try it, just do it!
|
|
|
|
|
10x
Another question: is there any way to use a class defined and exported from a dll loaded by LoadLibrary() ?
Its if you can explain what is a "name convention" it would be grate
thanks.
|
|
|
|
|
i askey myself this question many times, it is possible, the half-life engine does it, but i still dont know how...
Don't try it, just do it!
|
|
|
|
|
Yes there is..
In fact, I pondered over this same problem a while back. The idea was that I was supposed to use a class which is completely declared inside a DLL. I only had the header files for reference.
So, here we go, first the actual class, declared with typedef. Do this in a seperate header file:
[code]
typedef class {
public:
// Some initialization functions ?
virtual HRESULT InitModule(void);
virtual HRESULT QuitModule(void);
// A member variable perhaps ?
int iMemberVariable;
} MyExportedClassType;
// Pointer-to-function returning address-of WindowPlugin class
typedef MyExportedClassType* (*GetClass)(void);
[/code]
What ? A pointer-to-function blablabla ? What's that ?
Simple: That is the key to this whole mess: a pointer to a function. Why is it declared there ? Because the same header file is used in the loading application. Just for the sake of simplicity.
Now, when we have the actual class, let's see the DLL exporting it:
[code]
// On global level, declare an instance of the class
MyExportedClassType MyClass;
// At the DllMain, initialize the class' members
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpVoid)
{
.... Some code here
MyClass.iMemberVariable = 10;
.... More code here
return TRUE
}
// Add an exported function, which returns the address of our class
__declspec(dllexport) MyExportedClassType* ProvideAddressOfClass(void)
{
return &MyClass;
}
[/code]
Lastly, create a module definition file
[code]
LIBRARY
EXPORTS
ProvideAddressOfClass @1
[/code]
Ok, now the DLL is ready, go compile it. Next up, the loading application:
[code]
// We must include the typedef declaration
#include "myclasstypedef.h"
HDLL hDll;
// See here: let's create a pointer-to-function which returns a class' address.. Remember, we exported this type of function from the DLL !
GetClass MyClassProvider;
// A pointer to our class type
MyExportedClassType* lpImportedClass;
// Your main function
int main(void)
{
.... Some code ?
// Load module
hDll = LoadLibrary(ModuleName[iCount]);
// Resolve address of exported function
MyClassProvider = (GetClass)GetProcAddress(hDLL, "ProvideAddress");
// Get address of class within the DLL, using the exported function
lpImportedClass = MyClassProvider();
// Let's use it !
lpImportedClass->iMemberVariable = 1;
.... Some more code
// Remember to unload the library !
UnloadLibrary(hDll);
// End application
return 0;
}
[/code]
Seems difficult ? Well, it really isn't.. To sum it all up programmer-wise:
1. Create a class using typedef
2. Create a function which returns the address of your class
3. Export this function in the DLL with __declspec AND .def file
4. Create a typedef for 'pointer-to-function' of the address-provider function
5. Load the DLL in another application
6. Get the address of the exported function
7. Use the function to get the address of the class
8. Use the class
9. NULLify pointers, unload the DLL etc clean-up work
10. Quit and get some sleep
I have created an example of this, an application which actually creates it's main window in a seperate DLL, and adds event handlers to this window's procedure in another DLL. You can download the entire workspace (3 projects: WinDLL, InpDLL, WinLoader) from here.
Enjoy !
-Antti
|
|
|
|
|
[EDIT]I'm using VS6[/EDIT]
This is an obscure problem: I'm using an edit control labeled IDC_EDIT2 in a dialog-based app. To restrict the length of the content to 8, I use the following function that is called whenever the content changes:
void CFileCryptDlg::OnChangeEdit2()
{
char strPassword[10];
if(GetDlgItemText(IDC_EDIT2,strPassword,10)>8)
{
strPassword[8]='\0';
SetDlgItemText(IDC_EDIT2,strPassword);
}
}
It works fine, except for one small problem: till I type the 8th character, everything's as expected. But when the 9th character is typed, the cursor moves back to the first location in the edit box. How do I retain the cursor position?
Thanks,
Vikram.
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.- Dijkstra
KI klike KDE kand kuse kit, kbut KI kmust kadmit, kstarting kall knames kwith K kis ksilly. KI khope kthey kwill kgive kup kthis kwhole kscheme ksoon kand kcome kup kwith kreal knames.
pI vThink aHungarian nNotation vIs iA aWonderful nThing cAnd pEveryone avShould vUse pIt aAll dThe nTime, adNo nMatter pWhat dThe nContext, adEven adWhen vSpeaking.
|
|
|
|
|
Why don't you just do SendMessage(wndOfYourEdit, EM_EXLIMITTEXT, 8, 0); ?
This will limit the edit control to accept max. 8 chars.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I tried what David said below and it works.
On a purely academic note, how come neither
::SendMessage(((CEdit *)GetDlgItem(IDC_EDIT2))->m_hWnd, EM_EXLIMITTEXT, 8, 0);
nor
GetDlgItem(IDC_EDIT2)->SendMessage(EM_EXLIMITTEXT, 8, 0);
works when called from the dialog's InitInstance() function? They don't restrict the number of characters at all.
Cheers,
Vikram.
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.- Dijkstra
KI klike KDE kand kuse kit, kbut KI kmust kadmit, kstarting kall knames kwith K kis ksilly. KI khope kthey kwill kgive kup kthis kwhole kscheme ksoon kand kcome kup kwith kreal knames.
pI vThink aHungarian nNotation vIs iA aWonderful nThing cAnd pEveryone avShould vUse pIt aAll dThe nTime, adNo nMatter pWhat dThe nContext, adEven adWhen vSpeaking.
|
|
|
|
|
Probably because a dialog does not have such a method. Are you talking about OnInitDialog() ? Either way, the EM_EXLIMITTEXT message is for rich edit controls.
|
|
|
|
|
Is your edit control already created in InitInstance()? I'd prefer OnInitDialog().
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Why not just use SetLimitText(8) ?
|
|
|
|
|
Works!
Thanks a zillion !
Regards,
Vikram.
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.- Dijkstra
KI klike KDE kand kuse kit, kbut KI kmust kadmit, kstarting kall knames kwith K kis ksilly. KI khope kthey kwill kgive kup kthis kwhole kscheme ksoon kand kcome kup kwith kreal knames.
pI vThink aHungarian nNotation vIs iA aWonderful nThing cAnd pEveryone avShould vUse pIt aAll dThe nTime, adNo nMatter pWhat dThe nContext, adEven adWhen vSpeaking.
|
|
|
|
|
COleSafeArray::PutElement
Does this function append to the array ?
|
|
|
|
|
Nope. I can say this caregorically, since it's a wrapper around the SafeArrayPutElement function, and that doesn't.
Use the source, Luke
Steve S
|
|
|
|
|
This should be a simple question, but how do you create a CRichEditCtrl for version 2.0/3.0 using either Create or CreateEx?
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
What specifically is not working for you? If the control's parent is a dialog, add a control variable to the dialog's .H file, and then in the dialog's OnInitDialog() method, add:
AfxInitRichEdit();<br />
richedit.Create(...);
|
|
|
|
|
Might be that they're wanting specifically to create a richedit with Word-style paragraph formatting (left, centre, right, align). The default MFC way means that an old style rich edit is created all the time. In some cases, the way I've done this is in OnInitDialog to get the old one's attributes, trash it and recreate the control in place, before calling the default OnInitDialog in case that maps a control.
There are two Windows class names, "RichEdit" which is v1.0 and RICHEDIT_CLASS which expands at compile time to produce the appropriate name for v2 or later.
Steve S
|
|
|
|
|
The AfxInitRichEdit() loads the RICHED32.DLL with is version 1.0. I want to load 2.0/3.0
Thanks
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
My bad. When I saw richedit32, I just assumed v3.2, not 1.0. You have to go to richedit20 in order to get v3.0. Are we confused yet?
So, the moral to your story is that the CRichEditCtrl class does not support the Rich Edit v2.0 control. In order to use Rich Edit 2.0 in an MFC application, call LoadLibrary() to load the Riched20.dll and access its functionality through the Win32 API. Hmmm
|
|
|
|
|