|
I am new to COM/ATL,i have very beginner question, i want to know ho wto create events and raise that event in From ATL DLL.
thanks for every Suggestion
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Yeah,
Sorry i found it myself,as AtlCom wizard itslef Provide support for Event,you just mere have to Check the IConnectionPoint Box ,rets of thing will be handle by Wizard itself
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I have develop a List view control. Control has propert Columns which implements the IColumns interface. Now i want to persist this property by including it in Prop map.
Below is the code
<br />
BEGIN_PROP_MAP(CGridAdv)<br />
PROP_ENTRY("Columns", 14, CLSID_ColumnsProp)<br />
END_PROP_MAP()<br />
After doing that control crashes whenever container try to dislay it.
Can anyone tell me how to do that?
thanks
qur
|
|
|
|
|
Is there a way to get ostream_iterator to work with pair?
typedef int Number;
typedef float Voltage;
typedef pair<Number, Voltage> SamplePair;
std::ostream& operator<<(std::ostream& stream, const SamplePair& sample)
{
return stream << "Number: " << sample.first << ", Voltage: " << sample.second;
}
void ostreamIteratorPairTest()
{
typedef vector<SamplePair> Samples;
Samples samples;
for (int i = 1; i <= 10; i++)
{
SamplePair sample(i, float(i));
samples.push_back(sample);
cout << sample << endl;
}
copy (samples.begin(), samples.end(),
ostream_iterator<Sample>(cout, "\n"));
}
int main(int argc, char* argv[])
{
ostreamIteratorTest();
return 0;
}
In VC6 I get the following error:
c:\program files\microsoft visual studio\vc98\include\xutility(19) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct std::pair<int,float>' (or there is no acceptable conversion)
C:\Program Files\Microsoft Visual Studio\MyProjects\ConsoleTest\ConsoleTest.cpp(120) : see reference to function template instantiation 'class std::ostream_iterator<struct Sample,char,struct std::char_traits<char> > __cdecl std::copy(struct
std::pair<int,float> *,struct std::pair<int,float> *,class std::ostream_iterator<struct Sample,char,struct std::char_traits<char> >)' being compiled
Error executing cl.exe.
In VC7.1 I get a slightly different error saying that operator << hasn't been defined for pair when it has.
Kevin
|
|
|
|
|
Umm, you've stumbled on a particular tricky issue with argument-dependent lookup (ADL, also called Koenig lookup, if you don't know what this is just ask).
ostream_iterator tries to find operator<< in the namespace where ostream and SamplePair belong, namely std --SamplePair is just a typedef of std::pair , so it is really std::pair that's being used. And you've defined your operator<< in the global namespace, hence the problem.
One dirty hack is to just define the thing inside namespace std :
#include <iostream>
#include <utility>
#include <vector>
#include <iterator>
typedef int Number;
typedef float Voltage;
using namespace std;
typedef pair<Number, Voltage> SamplePair;
namespace std{
std::ostream& operator<<(std::ostream& stream, const SamplePair& sample)
{
return stream << "Number: " << sample.first << ", Voltage: " << sample.second;
}
}
void ostreamIteratorPairTest()
{
typedef vector<SamplePair> Samples;
Samples samples;
for (int i = 1; i <= 10; i++)
{
SamplePair sample(i, float(i));
samples.push_back(sample);
cout << sample << endl;
}
copy (samples.begin(), samples.end(),
ostream_iterator<SamplePair>(cout, "\n"));
}
int main(int argc, char* argv[])
{
ostreamIteratorPairTest();
return 0;
} But take this into account: strictly speaking, the former is not legal C++; the language does not allow you to overload any function in namespace std . AFAIK there's nothing you can do to prevent this, except turn SamplePair into an actual user-defined type (maybe by inheriting from std::pair and adding the proper constructors.) IMHO, you can just leave the thing as it is, knowing that it is not conformant C++.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Joaquín M López Muñoz wrote:
there's nothing you can do to prevent this, except turn SamplePair into an actual user-defined type
Yes, I'd done this anyway. But it would have been nice to be able to just use pair as-is in this context.
This wasn't actually production code, just me conducting research. Although the example was derived from some real code I'd worked on in the past before I'd discovered the "copy to ostream_iterator" technique. I often do this kind of thing after I've finished some real work - investigate how to do something better next time!
Kevin
|
|
|
|
|
Hi,
I'm following the guide in the platform sdk docs, and the information found on http://www.trigeminal.com/usenet to create a unicode WTL application that uses MSLU (Microsoft Layer for Unicode).
The project is created in VS.NET 2003 and WTL version 7.5.4196 (latest) is used. MSLU (unicows) .lib and .dll comes from Feb,2003's PSDK. In the WTL App Wizard, only "view type" in the "user interface features" section was changed to "HTML Page" so that I can get a web browser control hosted.
Then I changed:
_Module.Init(NULL, hInstance);
to:
_Module.Init(NULL, hInstance, &LIBID_ATLLib);
to avoid the LIBID debug assertion problem.
Before compilation, I made the following changes to the project settings:
Use of ATL -> Static Link to ATL
Minimize CRT Use in ATL -> No
Character Set -> Use Unicode
Ignored those libraries mentioned in the psdk guide, and linked to unicows.lib and all previously ignored libraries, as is specified by the guide.
The compiled executable (release build) worked on Windows XP but it generated a kernel32.dll crash on Windows 98. The debug build will complain about a failed assertion at an IsWindow check of m_hWnd. I figured it was because the web browser control window wasn't created.
Then I reset the settings back to get an ANSI build, and it worked on Windows 98. Is it a known problem with MSLU? Is there any way to solve it?
Thanks in advace,
|
|
|
|
|
Hi
I've captured some information about this crash. The crash happens in line 2968 of atlwin.h (microsoft visual studio .net 2003\vc7\atlmfc\include\atlwin.h). It's a "writing to location violation"
The function is:
LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
#ifdef STRICT
// This is where the crash happens
return ::CallWindowProc(m_pfnSuperWindowProc, m_hWnd, uMsg, wParam,
lParam);
#else
return ::CallWindowProc((FARPROC)m_pfnSuperWindowProc, m_hWnd, uMsg,
wParam, lParam);
#endif
}
In the function context, uMsg = 0x0000000d (13), wParam = 0x0000000d (13), lParam = 0x005e0f7c (6164348).
The calling parent is LRESULT CALLBACK CWindowImplBaseT< TBase, TWinTraits >::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam). And the calling child is unicows.dll!_GodotCallWindowProcW@20() + 0x52 and unicows.dll!_GodotTransmitMessage@44() + 0x1148 There is another unrecognized calling child. Apparently, 0x0d is the WM_GETTEXT message. And the crash happens right there. When
GodotTransmitMessage traps this message.
I saw a little note in the WM_GETTEXT description in PSDK Document:
Windows NT/2000/XP:ANSI applications may have the string in the buffer reduced in size (to a minimum of half that of the wParam value) due to conversion from ANSI to Unicode.
Does this note have something to do with this crash? I do hope someone can try follow my steps and see if it's a problem with MSLU.
Thanks
|
|
|
|
|
I wanted to write a small batch file so that i cud copy the data from
my pc to a remote pc but i fail 2 do...
i know Brilliant Minds wud say me why
md "%date%"
cd "%date%"
xcopy c:\me \\192.168.2.17 -z
exit /B
|
|
|
|
|
Sorry for little rude,
have check the secuirty permission or do u have write permission on remote computer.
if yes,you can use CopyFile api to copy file to remote computer
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello.
I've posted similar question in the COM forum but got no response.
May be someone in this forum will be able to help.
The question is as follows:
I have an out of process DCOM server, client software, that will be connecting to the server, can be written on any programming language. How do I create/transfer a structure/class between the client and the server?
Any help will be greatly appreciated. I'm pretty mach stuck with this issue since the only solutions that I found, talk about C++ only clients which is not applicable in my case.
|
|
|
|
|
VC++ 6.0 SP5
I have an MFC dialog application and I wanted to expose a COM interface for it so that other apps may call the interface while the dialog is up and running. I wanted to make the application free threaded so that calls to the interface from multiple clients would not be serialised.
I have done this by clicking on the Insert menu in VC6 and selecting 'New ATL Object...'. Once the object was inserted into the project I then edited stdafx.h and replaced _ATL_APARTMENT_THREADED with _ATL_FREE_THREADED. I then changed the ATL class so that it derives from CComObjectRootEx<CComMultiThreadModel>.
Testing has shown that when multiple clients call the interface the calls are all serialised because the ATL object in the dialog application is running on the UI thread. Is there any way in an MFC app to force COM to pick an RPC-managed pool thread rather than do all the work on the UI thread?
Regards
Martin
|
|
|
|
|
|
Did you initialize the apartment as multithreaded? See CoInitializeEx (or AfxInitializeOle, or whatever it's called in MFC)
--
Wir müssen leben bis wir sterben.
|
|
|
|
|
Thanks. That was the problem.
Regards
Martin
|
|
|
|
|
Hello!
I am yet learning MFC, but I intened to learn the ATL and WTL... What I want to ask is that what the WTL really is, what are the benifits of it over MFC. Also, please guid me about the ATL as well...
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
Read Michael Dunn's post in the thread "ATL / STL : Dumb question maybe" just a few lines below
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanx a lot... You guided me well... However, Just few more questions... What are the benifits of using WTL over MFC?(if any...) Moreover, I am learning MFC... Any tips to minize the learning curve will be helpfull, Also, when it is a good time to learn ATL?
Lastly, How you see the future of MFC/ATL/VC++ in the world of .NET (especially, please consider the 'interpreted' nature of .NET...)
Moreover, if Microsoft is not maintaining WTL, then who is?
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
First of all, I know very little about ATL, so some of my responses are tentative at best.
What are the benifits of using WTL over MFC?
It is cleaner, it does not suffer from some design defects affecting MFC (most notably in multithreading issues) and does not impose a complete framework on you (that meaning, you can add just a bit of WTL to an otherwise perfectly regular Win32. MFC, OTOH, forces you to write the whole app according to the framework it provides.)
On the cons side, WTL does not provide you with wizards (I think) and it is somewhat harder to learn, as the tecnhiques it relies on are more advanced.
Also, when it is a good time to learn ATL?
I couldn't say. Probably, knowing some UI stuff (plain Win32 or MFC) before delving into WTL is good.
Lastly, How you see the future of MFC/ATL/VC++ in the world of .NET (especially, please consider the 'interpreted' nature of .NET...)
I think WTL just does not apply to .NET UI.
Moreover, if Microsoft is not maintaining WTL, then who is?
http://sourceforge.net/projects/wtl/[^]
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
MFC is not only a set of classes, it is an entiere framework.
if you plan to program a console based program, you won't use MFC...
more, STL (standard template library) provides a collection of containers and algorythms that permit to manipulate every types (it is the purpose of the templates).
TOXCCT >>> GEII power
|
|
|
|
|
I found 2-byte leak in my application, and trying to detect it I cut everything except this:
class CMyWindow : public CWindowImpl<CMyWindow>
{
public:
DECLARE_WND_CLASS("MyName")
BEGIN_MSG_MAP(CMyWindow)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()
LRESULT OnPaint(UINT nMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
{
return 0;
}
};
extern "C" int WINAPI _tWinMain(HINSTANCE , HINSTANCE hPrevInstance,
LPTSTR , int nShowCmd)
{
#ifdef _DEBUG
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF);
#endif
{
ATLASSERT(AUX_SUCCEEDED(OleInitialize(0) == S_OK));
AtlAxWinInit();
{
CMyWindow w;
w.Create(0, 0, 0, WS_OVERLAPPEDWINDOW);
w.DestroyWindow();
}
AtlAxWinTerm();
OleUninitialize();
}
#ifdef _DEBUG
if (_CrtDumpMemoryLeaks())
::MessageBeep(MB_ICONEXCLAMATION);
#endif
}
The following dump is written to output:
Detected memory leaks!
Dumping objects ->
{49} normal block at 0x00944D70, 2 bytes long.
Data: < > DA C2
Object dump complete.
When I comment out w.Create(0, 0, 0, WS_OVERLAPPEDWINDOW); leak disappears.
Then I created another program, almost the same:
#define WIN32
#define _WINDOWS
#define _CRTDBG_MAP_ALLOC
#define _ATL_MIN_CRT
#define _DEBUG
#include <windows.h>
#include <comutil.h>
#include <stdio.h>
#include <tchar.h>
#include <atlbase.h>
#include <atlwin.h>
#include <windows.h>
class CMyWindow : public CWindowImpl<CMyWindow>
{
public:
DECLARE_WND_CLASS("MyName")
BEGIN_MSG_MAP(CMyWindow)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()
LRESULT OnPaint(UINT nMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
{
return 0;
}
};
extern "C" int WINAPI _tWinMain(HINSTANCE , HINSTANCE hPrevInstance,
LPTSTR , int nShowCmd)
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
HANDLE logFile;
logFile = CreateFile("bstr_t_leak_LOG.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, logFile);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, logFile);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, logFile);
{
ATLASSERT(OleInitialize(0) == S_OK);
AtlAxWinInit();
{
CMyWindow w;
w.Create(0, 0, 0, WS_OVERLAPPEDWINDOW);
w.DestroyWindow();
}
AtlAxWinTerm();
OleUninitialize();
}
exit(0);
}
and there is no leak!
|
|
|
|
|
You can try to identify the code which allocates this particular memory block using
_CrtSetBreakAlloc(49);
where the 49 is the chunk number from the leaked memory report. In debug mode, your app will break into the debugger when it is allocated. Since the number is so low, it seems like it is constant in your application. If it isn't, it will get a little bit more complicated.
HTH
|
|
|
|
|
I have a Class CMyEdit which is inherit from CWindowImpl class and contains the Message Map for LButtonDown message.
Now at run time I want to attach this class with Edit box using its window handler and want to capture the LButtondown event. Problem is i am not able to capture the LButtonDown message even if CMyEdit class is attached to Edit box.
Code below show the way i am doing it.
<br />
class CMyEdit : public CWindowImpl <CMyEdit><br />
{<br />
BEGIN_MSG_MAP(CMyEdit)<br />
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)<br />
END_MSG_MAP()<br />
<br />
};<br />
<br />
<br />
CMyEdit oMyEdit;<br />
oMyEdit.Attach(hWdnEdit);
<br />
thanks
qur
|
|
|
|
|
Is possible to use ATL 7.0 in VC.6 ?
I want to use CRBMultiMap template, but unfortunately I had to use VC 6.0.
Thanks.
Rodrigo Pinho Pereira de Souza
|
|
|
|
|
install the correct SDK...
TOXCCT >>> GEII power
|
|
|
|
|