atl

Marshalling BSTRs from C++ to C# with COM interop

末鹿安然 提交于 2019-12-12 07:26:51
问题 I have an out-of-process COM server written in C++, which is called by some C# client code. A method on one of the server's interfaces returns a large BSTR to the client, and I suspect that this is causing a memory leak. The code works, but I am looking for help with marshalling-out BSTRs. Simplifying a bit, the IDL for the server method is HRESULT ProcessRequest([in] BSTR request, [out] BSTR* pResponse); and the implementation looks like: HRESULT MyClass::ProcessRequest(BSTR request, BSTR*

Exposing methods to JS on a CAxWindow from a BHO ( C++ )

江枫思渺然 提交于 2019-12-12 05:04:21
问题 I have this BHO which I successfully exposed method to JS from it using this thread: Calling BHO method from Javascript?. When I open a CAxWindow in order to host HTML docs, I'd like to use this exported method but it seems that it doesn't work for that window as well. I tried to make a custom class like: class Bubble: public CAxWindow, public IDispEventImpl<1, Bubble, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 0> { public: BEGIN_SINK_MAP(Bubble) SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2,

Error when trying to hook up a control with DDX_CONTROL

左心房为你撑大大i 提交于 2019-12-12 04:17:58
问题 This is the code I'm trying to get to work right now: #pragma once #include "stdafx.h" #include "resource.h" class MusicPlayerDialog : public CDialogImpl<MusicPlayerDialog>, public CWinDataExchange<MusicPlayerDialog> { public: MusicPlayerDialog(); ~MusicPlayerDialog(); enum { IDD = IDD_MAINDIALOG }; BEGIN_MSG_MAP_EX(MusicPlayerDialog) MESSAGE_HANDLER(WM_CLOSE, OnClose) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_INITDIALOG, OnInit) COMMAND_ID_HANDLER_EX(IDC_CLOSE,

GDI+ erroneous drawing under Windows explorer window

痴心易碎 提交于 2019-12-12 04:06:32
问题 I am using GDI* plus to do custom drawing, but I have a drawing error when my window gets drawn under a windows explorer window, it looks like this: As u can see just under the explorer window.. the colors are weird.. the top right are buttons and the checkbox is also a button .. "Are you.." is a static control.. they are all inherited and implemented as custom controls.. when receiving WM_PAINT. I also use a buffered image in WM_PAINT.. anyway.. I can't explain this, any ideas? It works fine

Calling my COM method from C# results in a null structure returned if HRESULT is not 0

房东的猫 提交于 2019-12-12 03:54:57
问题 Here is my C# code: static void Main(string[] args) { CrappyCOMService service = new CrappyCOMService(); CrapStructure crapStructure = new CrapStructure(); try { service.TestCrap(1337, "This is bananas.", out crapStructure); } catch (Exception exception) { Console.WriteLine(exception.ToString()); } Console.WriteLine(crapStructure.ErrorCode); Console.WriteLine(crapStructure.ErrorMessage); } Here is my IDL: [ object, uuid(61B0BFF7-E9DF-4D7E-AFE6-49CC67245257), dual, nonextensible, pointer

'Interface not Registered' error on ATL out-of-process callback interface

我与影子孤独终老i 提交于 2019-12-12 02:29:46
问题 I have an ATL in-process server that implements a callback interface like so: .idl interface IClientEvents : IUnknown{ [] HRESULT TestEvent(void); }; interface IATLSimpleObject : IDispatch{ [id(1)] HRESULT Advise([in] IClientEvents* clientEvents); [id(2)] HRESULT Unadvise(void); }; .h private: IClientEvents* m_ClientEvents; public: STDMETHOD(Advise)(IClientEvents* clientEvents); STDMETHOD(Unadvise)(void); .cpp STDMETHODIMP CATLSimpleObject::Advise(IClientEvents* clientEvents) { m_ClientEvents

Extract CString between tags

家住魔仙堡 提交于 2019-12-12 01:45:17
问题 How can I extract a CString between two tags ? <tag1>My Text</tag1> I don't want to calculate the start and end position then use Mid, maybe there is another easier method using STL ? 回答1: Disclaimer: the following idea is bad and should not be used in production code. I'm assuming you just want a quick hack for testing. Use a regular expression to match the tags. Microsoft provides this in CAtlRegExp. If you're using Visual Studio 2008 or newer, download ATL here. Then, just provide myString

ATL: I want to create a coclass that I can use as a parameter for a method in my class. Why can't I get this to work?

懵懂的女人 提交于 2019-12-12 01:17:16
问题 I've created a COM object using ATL. I want to create a new object that can be returned from a method, and passed in as a parameter. I've created the coclass, but I can't figure out how to add a method that will accept it as a parameter. The error I'm getting is MIDL2025: syntax error: expecting a type specification near "IgBrush". I'm using Visual Studio 2008. When I added an enumeration, I recall playing around with the IDL quite a bit, and eventually got it to accept the enumeration as a

WM_SYSCOMMAND SC_MOVE eats up mouse events and mouse up is not fired

二次信任 提交于 2019-12-12 00:30:24
问题 My program is a chromeless window and I want to move the window when user drag any part of my dialog. Once WM_SYSCOMMAND is used, all subsequent mouse events are lost. First I wrote a program to capture the mouse events and all working fine with WTL. BEGIN_MSG_MAP(CMainDlg) MSG_WM_LBUTTONUP(OnMouseUp) MSG_WM_LBUTTONDOWN(OnMouseDown) .... LRESULT OnMouseDown ( UINT uKeys, CPoint pt ) { print ("on mouse down"); return 0; } LRESULT OnMouseUp ( UINT uKeys, CPoint pt ) { print ("on mouse up");

PostMessage(), SendMessage not working in ATL dll (event handling)

百般思念 提交于 2019-12-11 20:43:52
问题 sorry, my english skill is very low. i make a ATL(C++) dll. and handled by VB. i make under base code. WaitAndReadData, Thread_WaitAndReadData is working. but, ::SendMessage, ::PostMessage is not working in Thread_WaitAndReadData or WaitAndReadData. and breakpoint not working in Get_Data_Messagehandler. (+ another function call.) #define WM_SERVERTHREADFIREEVENT (WM_USER+2) BEGIN_MSG_MAP(CHello) CHAIN_MSG_MAP(CComControl<CHello>) MESSAGE_HANDLER(WM_SERVERTHREADFIREEVENT, GetData