|
Thank you Michael Dunn for ur reply.
-Friendly Dracula
|
|
|
|
|
I've been trying to use WTL controls in my large MFC based project. I've got the WTL7 libraries installed on my VC6 system. I can compile the WTL ctrl's sample code just fine, but when I try using it with MFC code, I'm getting all sorts of namespace collisions. CEdit, CButton, etc.
Can WTL and MFC code be intermingled? Does anyone have an example of how to do this? I'm guessing careful use of "using ... { ... }" is the key, or being more explicit with class names.
|
|
|
|
|
aha, CodeProject to the rescue.
http://www.codeproject.com/wtl/mix_wtl_mfc.asp
Apparently there are some #define's you can set to cause WTL to not define symbols that will clash with MFC (which puts everything in the global namespace)
|
|
|
|
|
Please not that is for VC6/ATL3. It may not work with your development environment if it's VS.NET/ATL7.
Come to think of it, there is some wizard in VS.NET that allows "adding ATL support to MFC projects". Please try that before trying my previous response.
And the #define stuff mentioned in the article too.
--
He just smiled and gave me a vegemite sandwich.
|
|
|
|
|
WTL7.1 in an ATL7 environment (VS.NET and later) will assume there is a global variable called _AtlBaseModule .
I can't remember all functions it must have, but you'll figure it out as you see the compilation errors. I know it needs a function called GetResourceHandle() . It should just return the HINSTANCE for your resources.
I would suggest that you do something like this in your stdafx.h:
#include "youratlbasemodule.h"
extern YourAtlBaseModuleEmulator _AtlBaseModule;
#include <atlapp.h>
#include <atlctrls.h>
...
And then in your youratlbasemodule.h:
class class YourAtlBaseModuleEmulator {
HINSTANCE m_hInstance;
public:
void SetResourceInstance(HINSTANCE hInstance) { m_hInstance = hInstance; }
HINSTANCE GetResourceInstance() { return m_hInstance; }
};
And then in your "main" cpp file:
#include "youratlbasemodule.h"
...
YourAtlBaseModuleEmulator _AtlBaseModule;
...
_AtlBaseModule.SetResourceInstance(hInstance);
I think something along those lines should work. I have never done it before.
--
He just smiled and gave me a vegemite sandwich.
|
|
|
|
|
Thanks for the explicit examples!
There are so many hot (trendy?) WTL controls out there that I'd love to use in my apps, but getting the code to compile together has always been a bottle neck.
|
|
|
|
|
I want to harness the power of STL in my code. But I am not able to become comfortable with STL. May be because of my inexperience.
Presently I am working with string . What I want to pass from a dll a function which will accept List of employees and Number of employees and I will save it in a class member variable. How to do it is the question?
|
|
|
|
|
Hello everyone:
Could you teach me how to read file line by line?
If having some samples, please send to me by email.
Thank you.
-Freehawk.
|
|
|
|
|
freehawk wrote:
Could you teach me how to read file line by line?
Look up getline.
freehawk wrote:
If having some samples, please send to me by email.
No. If you won't look here again for your answer, especially when the site sends you an email to say you've been replied to, why should we send you an email and risk ending up on a spam list somewhere ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thank you for the reply.
where is the "getline"? Could I use it in a wtl7.1 project?
-Freehawk
|
|
|
|
|
the beauty of solutions like using getline are that they are part of C++, not part of any framework. Therefore you can use them in any C++ project. I *think* getline lives in iostream ( NOT iostream.h ). ifstream lives in fstream.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Here is the solution using std::getline().
std::string sInput;
std::getline(inputStream, sInput);
Kuphryn
|
|
|
|
|
Thank you very much.
It is just what I need.
I will try it.
-Freehawk
|
|
|
|
|
Hello everyone:
Example I receive some messages and want to do somethings same with clicking the button of toolbar, how to realize?
and how to disble/enable the buttons of toolbar?
Thank you.
-Freehawk.
|
|
|
|
|
|
Thank you very much.
I will try it.
-Freehawk
|
|
|
|
|
Hello everyone:
I want to transfer a function pointer from a WTL project to a MFC dll.
Do I need to make the function as a CALLBACK function?
How to transfer it?
-Freehawk
|
|
|
|
|
Through a function call perhaps? How would you do it otherwise?
Just define the function pointer type in a header file which the MFC dll and WTL project has access to during compile time. And add a function in the MFC dll which can deliver the function pointer.
I.e.:
typedef void (*FuncPtr)(type, type2, type3);
void InstallFunctionCallback(FuncPtr fptr);
And implement InstallFunctionCallback accordingly in your MFC dll.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
Thank you for the reply.
I finished it, but I have not made the function as a callback function.
could you tell me what difference is between a function and a callback function translated
to dll as a function pointer?
-Freehawk
|
|
|
|
|
freehawk wrote:
tell me what difference is between a function and a callback function translated
to dll as a function pointer?
There is no difference really. Callback is just a semantic label for programmers.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
Thank you for the reply.
I did it.
-Freehawk
|
|
|
|
|
I need to allocate and fill a large block of bytes in an ATL object, then pass that memory back to the client, which can delete it when it wants to.
i tried this:
<br />
[id(3), helpstring("method MFIGetFrame")] HRESULT MFIGetFrame([in] ULONG FrameIdx, [out] unsigned char **FrameArray, [out,retval] ULONG* Retval);<br />
but the COleDispatchDriver wrapper returns DISP_E_BADVARTYPE, because it doesn't know what to do with the "unsigned char **" .
i've tried using:
[id(3), helpstring("method MFIGetFrame")] HRESULT MFIGetFrame([in] ULONG FrameIdx, [out] SAFEARRAY(unsigned char)*FrameArray, [out,retval] ULONG* Retval);<br />
but the compiler keeps giving me: "error C2061: syntax error : identifier 'tagSAFEARRAY'".
i'm using VS.Net, which seems to make everything twice as hard as it needs to be.
any ideas?
ClickPic | ImgSource | CheeseWeasle
|
|
|
|
|
First, if you are returning an array in COM/IDL, you need to make it "conformant". You do that by indicating the number of elements in your array. I.e.:
HRESULT MFIGetFrame([in] ULONG FrameIdx, [out] ULONG* ArraySize, [out, size_is(1, *ArraySize)] unsigned char** FrameArray, [out, retval] ULONG* Retval)
At least that's what Essential IDL by Martin Gudgin told me last night.
As for the SAFEARRAY business, have you tried importing oaidl.idl? import "oaidl.idl"; It should be imported by default if I'm not mistaken though.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
Jörgen Sigvardsson wrote:
have you tried importing oaidl.idl? import "oaidl.idl";
i tried that. but the error is actually happening in the "__interface" section of the ATL object's .H header (not in the IDL). apparently VC7 puts the IDL stuff right in the .H file, instead of an external IDL... ?
and, i can't figure out how to do an import in that __interface section.
ClickPic | ImgSource | CheeseWeasle
|
|
|
|
|
Just out of curiosity.. if you are calling the object using COleDispatchDriver, why not call using the vtable instead? Or is the interface a pure dispinterface, and you cannot in any way make the interface dual?
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|