|
Unsubclass[^] the window in a WM_CLOSE handler?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You means Unsubclass the child control in its parent's WM_CLOSE message handler? Yes, i calls myContrl.UnSubclassWindow() before EndDialog() call.
|
|
|
|
|
Im sorry, its my fault, i had declared two such controls, but unsubclssed only one. its ok now.
Regards.
|
|
|
|
|
Hi,
I created an ATL Exe Service using classwizard (VS60) and it contains 1 method. I installed the service using the -service keyword and manually started the service. However, when my client application tries to call the method of that service it basically hangs on the call. Any ideas?
Thanks
|
|
|
|
|
|
I've written a multi-threaded WTL util to stress test an in-house service.
Comms threads signal to the main thread that they've quit, so the main thread can delete their corresponding object.
They make the signal as so:
PostThreadMessage(m_dwParentThreadId, WM_THREADQUIT, 1, m_dwNetThreadId);
My problem is how to deal with the custom message I've defined .
WM_THREADQUIT is #define'd as WM_USER + 10
I wanted to use an entry in the message map to call a handler, e.g.:
BEGIN_MSG_MAP(CMainDlg)
MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
MESSAGE_HANDLER( WM_THREADQUIT, OnThreadQuit )
...
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
However, OnThreadQuit is never called.
The only way I can handle it is by calling the handler explicitly in PreTranslateMessage:
virtual BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_THREADQUIT )
{
BOOL blHandled;
OnThreadQuit(pMsg->message, pMsg->wParam, pMsg->lParam, blHandled);
return TRUE;
}
return CWindow::IsDialogMessage(pMsg);
}
I'm sure this isn't the correct way to do it ...
I'd love to know the correct way- can someone help!?
thanks
modified on Friday, November 6, 2009 6:46 AM
|
|
|
|
|
MSDN documentation mentions as follows:
"...Messages sent by PostThreadMessage are not associated with a window. As a general rule, messages that are not associated with a window cannot be dispatched by the DispatchMessage function. Therefore, if the recipient thread is in a modal loop (as used by MessageBox or DialogBox), the messages will be lost. To intercept thread messages while in a modal loop, use a thread-specific hook..."
http://msdn.microsoft.com/en-us/library/ms644946(VS.85).aspx[^]
You can consider using PostMessage() API.
|
|
|
|
|
Hi ,
I am using CreateWindowsEx()API to create button on toolbar. The code is as
CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,"Button","X",WS_VISIBLE | WS_CHILD |WS_CLIPCHILDREN ,2,0,25,25,m_hWnd,NULL,_Module.GetResourceInstance(),NULL);
I can add button on toolbar, but color of button is gray, I want this button with white background. So please send any solution to change button color.
Regards
abm
|
|
|
|
|
|
Hello.
I have created an ocx control in delphi and i put it on form of ATL Composite Control (Insert ActiveX Controls). Now i trying to access properties and methods, but i dont know how to do....
I tryed everythig but i always get error assert debug failed...
Is there any way that i "attach" or "getcontrol" like you can do with standard controls in toolbox?
Thanks, komofilms
|
|
|
|
|
By default, type library information is compiled into my ATL dll project. While I do want the .tlb file, I don't want it compiled into the dll. How do I turn that off?
|
|
|
|
|
Hello kcynic,
The type library information is stored as a resource in your ATL-based COM executable (i.e. DLL or EXE). To remove it, open the resource script file for your ATL project (i.e. <project name>.rc).
In your .rc file, look for a resource typed as "TYPELIB". It will usually be of the following form :
1 TYPELIB "<project name>.tlb"
Simply comment out this line.
By the way, besides removing type libs from your project's resource, you can also add more type libraries into your resource, e.g. :
2 TYPELIB "<some other type library>.tlb"
In this case, you must either supply a full path to the new type library or indicate a path to it in the "Resources" section of your project settings.
- Bio.
|
|
|
|
|
Thanks, i have tried successfully.
And another question, in some of my code, i use another interface witch is provided by ms, the code looks like following:
CComPtr<isomeinterface> pI;
HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface);
Here, if the code was used in my Atl dll project, i would got hr with E_NOINTERFACE error;
but if i use that code in a normal project(Not atl com dll), hr will be S_OK.
why?
|
|
|
|
|
>> And another question, in some of my code, i use another interface witch is provided by ms...
Do you mean that in your ATL COM object class, you implement the MS interface ? E.g. :
class ATL_NO_VTABLE CMyClass :
public ...
public ISomeMSInterface,
public ...
Or do you mean that the actual code :
>> CComPtr pI;
>> HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface);
is called in some function of your ATL COM object source codes ? E.g. :
STDMETHODIMP CMyClass::SomeMethod()
{
CComPtr pI;
HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface);
...
}
- Bio.
|
|
|
|
|
No. I really import the interface from the component.
so i directly use that interface like that.
|
|
|
|
|
To confirm, the creation of object of coclass CLSID_SomeInterface is actually called in some function of your ATL COM object source codes, e.g. :
STDMETHODIMP CMyClass::SomeMethod()
{
CComPtr pI;
HRESULT hr = pI.CoCreateInstance();
...
}
- Bio.
|
|
|
|
|
Yes. I packed this code in a static library as .lib.
But, it's strangely that if i direct use the static library, the code will work well( CoCreateInstance returns S_OK). but, if i use the static library in my atl com object and i call that code via the com dll, the CoCreateInstance would returns E_NOINTERFACE.
|
|
|
|
|
The use of a static library makes no difference as far as the creation of COM objects is concerned. Here's what I suggest :
1. Make sure that the correct interface ID is passed in. You'll have to check your source codes to be sure of this.
2. Make sure that the correct version of the target COM DLL is loaded. In debug run mode, use the VC++ "Modules" menu item.
Best of luck,
Bio.
|
|
|
|
|
Of course, they are OK.
Although the problem still remains, but i think it should due to my own fault. Just take it easy.
Thanks
|
|
|
|
|
hi, Bio. I use this method to remove type library information from the dll file successfully. but the target dll(without type library) can't be register successfully without the .tlb file and returns "Error loading library/DLL"
|
|
|
|
|
Hello kcynic,
If you want to remove the type library information from your COM DLL and yet be able to register your COM DLL, the you need to do some more tweaking in your DllRegisterServer() code.
This function is generated for you by ATL and it generally looks like the following :
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(/*TRUE*/ FALSE);
}
Here, as suggested by my code above, comment out the TRUE value and insert in FALSE. The issue is that _Module.RegisterServer() will attempt to perform 2 things :
1. Writes information of the COM objects in your DLL into the registry.
2. Registers the type library (the *.tlb) file generated for you by the MIDL compiler into the registry.
In order to do (2), the type library binary must be part of the resource of your DLL. Now, if you do not wish to register your type library, the FALSE value of the parameter to _Module.RegisterServer() will specifically not register your type library.
- Bio.
|
|
|
|
|
Cool. It really works.
Before post this question, I only know atl only register the component's AppID and clsid, so it would not work if i remove the type library information from the resource. I want to write my own code to register the interfaces by hand before. Now, i know i only just modify a parameter in the existent code.
Thanks very much.
Regards.
|
|
|
|
|
|
This forum is for questions not advertising. If people are interested they will find your article. Stick to the protocols.
|
|
|
|
|
Sorry and thank you. Now the message type has been changed to "News" instead of "Question".
My intent was to spread the word to those who may need it. This include those who use the MFC technolgy, COM and ATL, hence the 3 copies I posted at the three forums.
Respectfully.
Easy Profiler : Now open source !
http://www.codeproject.com/KB/cpp/easyprofiler.aspx
|
|
|
|