|
Excellent. This works perfectly - have tested it now, here's a summary of the working method for the benefit of other readers.
The typedef is in the interface .h, so all you need to do in the MFC is
#include "../wherever/QXMyWrapper.h"
#pragma comment(lib, "../whereverlibis/QXMyWrapper")
In the MFC, can now do all the usual CString operations and function calls, and can transfer other CStrings easily in and out of the QXString form like this
QXMyWrapper wrapper;
CString cstr("qwertyuiop");
QXString str = cstr;
int k = wrapper.Hello(str);
// str is modified by Hello
The working QXMyWrapper.h looks like this...
//--------------------------------------------------------------------------
/*
File name: QXMyWrapper.h
This file contains all the DLL interfacing object declarations,
Notice: we use the same header file for compiling the .DLL and the .exe (application).
The header file exports the target DLL objects if we are building the DLL,
otherwise it imports the DLL objects into an application which uses the DLL.
Here we assume the DLL is being built in WTL/ATL and the caller is an MFC app, so we use _AFX to differentiate the two
Based on http://www.codeproject.com/KB/DLL/RegDLL.aspx
and http://www.codeproject.com/script/Forums/View.aspx?fid=4486
*/
#ifndef _QXMYWRAPPER_H_
#define _QXMYWRAPPER_H_
#ifdef _AFX // MFC apps define this
#define DECLDIR __declspec(dllimport)
#include <atlstr.h> // allows us to use QXString in MFC
#else
#define DECLDIR __declspec(dllexport)
// WTL definitions for the non MFC environment
#include <atlstr.h>
#include <atlbase.h>
#include <atlapp.h>
#define _WTL_NO_CSTRING
#include <atlmisc.h>
#endif
// Define QXString as a specialized CStringT which will behave like the usual MFC CString but
// is consistently defined and has consistent mem (re)allocation between MFC callers and the DLL
typedef CStringT<char, StrTraitATL<char> > QXString;
class DECLDIR QXMyWrapper
{
public:
QXMyWrapper();
~QXMyWrapper();
int Hello(QXString& name);
};
#endif // _QXMYWRAPPER_H_
//--------------------------------------------------------------------------
Finally, in the WTL .cpp you can put all the other stuff you need to implement the wrapper, and this is where all the other #include's needed for your WTL code go, so the shared .h doesn't drg them in and confuse the MFC code. This lets you wrap a WTL DLL effectively and keep it separate from the MFC. The other nice thing is that the debugging works fine, you can step in and out of the WTL code during an MFC debugging session and watch what is happening. Many thanks for the accurate comments to make this all work...
DaveB
|
|
|
|
|
Hi,
I have written a ATL COM Service with VS 2005. I'm trying load MFC dll from the service. It compiles okay. However, when I am trying to start the service LoadLibrary Fails.
I have overridden the Start() function and written call to Loadlibrary() there.
When using this dll from a simple MFC application it works fine.
What am I doing wrong?
Thanks,
Abhijit
|
|
|
|
|
abhijitr wrote: When using this dll from a simple MFC application it works fine.
Have you tried calling the DLL from an ATL or straight Win32 application? Have you used GetLastError() to find what error LoadLibrary is signalling? Another thing you could try is adding a 'DebugBreak' call just before the LoadLibrary, to get the service to break into a debugger.
|
|
|
|
|
why WTL ListViewCtrl's LVN_GETDISPINFO notification is not getting fired?
i am a WTL beginner
i have a WTL SDI framewnd application
and a user-defined class, which is inherited from WTL CListViewCtrl
to create a virtual listview control, will act as view class of the application
i've set the(LVS_OWNERDATA) style for it.
i've also read the following thread
<WTL: Reflect notifications to a control>
http://www.codeproject.com/script/Forums/View.aspx?fid=4486&msg=468889
my problem is somehow different
listview is wrapped by a WTL::CSplitterWindow class then the splitter is added to
MainFrame window, acutally the mainframe window is splitted into two views
i have reflected the message in mainframe class and i am processing it in
my view class ( which is inherited from WTL CListviewctrl) using
REFLECTED_NOTIFY_CODE_HANDLER(LVN_GETDISPINFO,OnGetDispInfoFileList)
DEFAULT_REFLECTION_HANDLER()
as the above mentioned thread reply says (by MIKE) mainframe message is reflected back ...
but i don't know if there is problem in splitterwindow class, which is in between
the listview and framewindow ...i don't know how to modify
splitterwindow( i suppose not ) because it is pre-written WTL class ...
my machine soft config is
WIN XP-SP2
DOTNET 2005 enterprise ed.
latest PSDK
IE 6
anyone if you know, could you tell me why
Thanks in advance.
RAM
*********
|
|
|
|
|
problem is fixed !!!
As microsoft says, notification messages of child window is posted to parent window
here, my parent windows is a splitter so it needs a message feeder in order to convey all messages to top level window.
adding the following thing in the splitterwnd sets a pullstop to the problem..
FORWARED_MESSAGES()
RAM
** i've never seen a wand it gives anything **
** i am never going to deny it after seeing CP **
|
|
|
|
|
i got the same problem with you, i don't how to solve it. Anyone could help ?
|
|
|
|
|
Hi
I am trying to open a file for reading using C++ I/O. The call to read is simple
#include <fstream>
using namspace std;
int _tmain()
{
std::string infile(_T("testreport.txt"));
ifstream fin(infile.c_str(), ios::in);
if(!fin)
{
cout << "unable to open file for reading";
}
return 0;
}
when I execute the program I always get the failure. However if I specify the full path to the file like "d:\\testdata\\debug\\testreport.txt", I am able to open the file successfully.
I am using VC++ 2005 compiler and debugging with in VC IDE. How do I make VC++ to automatically take the relative path of the file.
This problem only occurs when I am debugging through the VC++ IDE.
Thanks and Regards
modified on Thursday, March 27, 2008 5:49 AM
|
|
|
|
|
psychedelic_fur wrote: How do I make VC++ to automatically take the relative path of the file.
First it has nothing to do with Visual C++. You are using a library called STL to open the file. It uses the OS support to open the file and they both support relative paths. But just like an absolute path you have to get the relative path correct or it won't work.
led mike
|
|
|
|
|
You have to configure your IDE to use d:\testdata\debug as working directory when debugging. On Visual Studio 2005, for instance, select Project->Properties menu item and then (on the newly appeared window) select the Configuration Properties->Debugging node, select Working Directory item (on the Local Windows Debugger ) list and finally assign it the d:\testdata\debug path.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
psychedelic_fur wrote: Thank you
You're welcome.
psychedelic_fur wrote: It could probably be that MFC is setting the working directory automatically.
I don't think so.
Anyway now it works, why bother?
Best wishes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hello All
Previously i have posted this message to wrong forum.
I am Developing ATL Project in which i have added ATL Dialog.
Now on this Dialog i want to add ShockwaveFlash Activex Control.
I am able to add this control but Problem is that i can not add Variable to this Control.
So is there anybody who can solve my problem?
Any help will be appriciated
Thanks in advance
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
|
Thanks for your reply
I got it
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
I wrote an ActiveX control. At first there was no GDI+ code in it and it worked well. Then I added follow code:
class ATL_NO_VTABLE MyControl:
public .........
{
...
BOOL OpenImageFile(BSTR FilePath) // added a method
{
USES_CONVERSION;
m_pBitmap = Bitmap::FromFile(FilePath);
return m_pBitmap!=NULL;
}
Bitmap *m_pBitmap; // added a point
}
After I added a point and a method, MyControl was no long created successfully. I searched in www.codeproject.com and finded Ryan Johnston's article----http://www.codeproject.com/KB/GDI-plus/gdipluscontrol.aspx, I read the article and thought it would resolve my problem, en..., it didn't.
It's very strange that after I remove my method, MyControl can be created, but if I add "static InitGDIPlus GDI_Plus_Controler;" in MyControl.cpp, MyControl can not be created again. I have not call the object's method yet, only declare a static global. Why this declaration make MyControl create failed?
I hope someone can help me resolving this problem. Suggestion, article, code example, anything may be helpful is appreciated, thank you.
My System: Windows 2000 Server, VC6(ATL3.0), Windows Server 2003 SP1 SDK
modified on Tuesday, March 18, 2008 11:06 AM
|
|
|
|
|
I change the system to windows 2003, the problem was resolved.
|
|
|
|
|
Sounds like you're missing gdiplus.dll. That didn't come with Win 2K.
|
|
|
|
|
We have two EXE. one COM EXE.
when calling some methods written in COM EXE, shows the following message.
What is the exact problem?
" This action cannot be completed because the other program is busy.
Choose 'Switch To' to activate the busy program and correct the problem"
|
|
|
|
|
Many things can cause this...
1. Your COM server or Main thread died
2. Main thread is processing a long operation
God bless,
Ernest Laurentin
|
|
|
|
|
Hello,
I am naive to Windows Services.
I have few queries regarding Windows Services which are as follows: -
How to manage User account?
For example there are several users present on a single machine and how to restrict users group from accessing the Windows Service?
Can do it using CoInitializeSecutriy(), if yes then How?
Thanks in Advance.
|
|
|
|
|
tony_udz wrote: How to manage User account?
tony_udz wrote: Can do it using CoInitializeSecutriy()
The obvious answer is to use the Windows User Management tool. If you want to develop your own software to do that it is going to be far more complicated that using a couple of API calls. If you want to do Windows Security development I suggest you find a good book that covers that topic in depth.
led mike
|
|
|
|
|
Hey Led,
Yes i am looking for Windows Security Management.
Can you please tell me the name of that book?
Thanks!
|
|
|
|
|
Never read one myself. If I wanted to find one I would start here[^]
led mike
|
|
|
|
|
Hello Friends,
I have developed one ATL com dll for IE tool bar.
My Ie toolbar is having buttons which i have created dynamically.
buttons are having Icon images also.
but i am facing one problem...
I can show only the Icon with "Bit Depth=8" of .ico image.
Actually i want to show Icons with "Bit Depth=32" also.
I am using below code..
UINT colormap = LR_DEFAULTSIZE |LR_LOADMAP3DCOLORS| LR_LOADFROMFILE | LR_CREATEDIBSECTION|LR_LOADTRANSPARENT;
HBITMAP hBitmap =(HBITMAP) ::LoadImage ((HINSTANCE)::GetModuleHandle(NULL),ImagePath,IMAGE_BITMAP,0,0,colormap);
In above code...
while Debugging i came to know that i am getting null in hBitmap variable for Icons with "Bit Depth=32". for Bit Depth up to 24 it is working fine.
Please suggest me the solution....
modified on Monday, March 10, 2008 2:06 AM
|
|
|
|
|
Why are you using IMAGE_BITMAP if you're trying to load icons?
You should try IMAGE_ICON.
Hope it helps
rotter
The metaller programmer
|
|
|
|