|
I've only worked with SubclassWindow in the same process, so can't answer to that, other than to say give it a go and see what happens
delete this;
* poof! *
|
|
|
|
|
FlyWithYou wrote: 2.can SubclassWindow() and Attach() Attach other process windows?
No. I don't see how you could call the original window procedure, nor do I see how the other process can call the subclassed window procedure.
|
|
|
|
|
wtl or atl had some about this function?
|
|
|
|
|
I had an simple object by using ATL Object wizard and a generic class CTCPSocket.
The com object name is CTest and interface is ITest. This class had a interface Add and a connection point Fire_notify.
And CSocket had two methods add_in and notify.
The code as following:
//CTest class
CTest:Add(long port)
{
CTCPSocket sk;
sk.add_in(port);
}
CTest:OnNotify()
{
Fire_notify();
}
//CTCPSocket class
CTCPSocket:add_in(long port)
{
//create a socket and listening
}
CTCPSocket:notify()
{
//created a tcp connectiong?
//when created a socket accept,pass the event to CTest:OnNotify()
}
when the client call the CTest->Add method, CTCPSocket will create a socket and listening, but the problem is: when there is a tcp connection event,how to pass the event to CTest:OnNotify() from CTCPSocket:notify()?
Thanks
Brygid
www.ecq.name
brygid
www.ecq.name
|
|
|
|
|
Store the pointer to the CTest class in a CTCPSocket member and call the OnNotify() within CTCPSocket:notify().
CTest::Add(long port)<br />
{<br />
CTCPSocket sk;<br />
sk.m_ptest=this;<br />
sk.add_in(port);<br />
sk.m_ptest=0;<br />
}<br />
CTCPSocket::notify()<br />
{<br />
if(m_ptest) m_ptest->OnNotify();<br />
}
|
|
|
|
|
Hello
I'd like to have a specific hWnd's content drawn at my EMF's DC.
I've tried several techniques but they don't seem to work.
As I do
// >>>
HDC hDC = GetDC(hWnd);
hBmp = CreateCompatibleBitmap(hDC, width, height);
ReleaseDC(hWnd, hDC);
HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
SelectObject(hDCMem, hOld);
DeleteObject(hDCMem);
// <<<
it successfully grabs the output to my bitmap
but the similar code
// >>>
HDC hDC = GetDC(hWnd);
hEmfDC = CreateEnhMetaFile(hDC, NULL, NULL, NULL);
ReleaseDC(hWnd, hDC);
SendMessage(hWnd, WM_PRINT, (WPARAM) hEmfDC, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);// <<<
doesn't.
Guys at microsoft go further with recursive enumerating of child windows. That somehow improves the solution as most of dialog controls appear on EMF's DC.
But the window's header doesn't.
Now I doubt that it is possible at all.
I'd like to have any info about it.
Especially concerning grabbing output of non-client area and window's header.
|
|
|
|
|
Some printing routines distinguish between raster and vector devices. It's also possible that the printing routine decides that the enclosing rectangle is to small for printing. Try to call the CreateEnhMetaFile with a valid rectangle.
|
|
|
|
|
How do I write a function that will help sort my array, by some
dynamically specifiable criteria. For example:
class Sortable{<br />
int a;<br />
int b;<br />
int c;<br />
int d;<br />
int e;<br />
};<br />
<br />
void SomeFunction()<br />
{<br />
std::vector< Sortable> items;<br />
<br />
int sortBy = 2;
std::stable_sort(items.begin(), items.end(), SortByAorBorC);<br />
}<br />
Is it possible to write a function "SortByAorBorC" that takes a paramter (the int sortBy )??? Right now I'm writing a separate function for each (e.g. "SortByA" "SortByB" and then using a switch statement - it works but it's not very elegant.
I can't quite get it going...
Many Thanks
Warren
|
|
|
|
|
You want to use a function object. For example:
class CMySortFn
{
private:
int m_nSortBy;
public:
CMySortFn(int sortBy) : m_nSortBy(sortBy) { }
bool operator()(const Sortable& a, const Sortable& b) const
{
switch (m_nSortBy)
{
case 1:
return a.a < b.a;
case 2:
return a.b < b.b;
etc.
}
}
};
std::sort(items.begin(), items.end(), CMySortFn(2));
You could also use a struct as the function object, if you want it even simpler. e.g.:
struct mysortfn
{
int m_nSortBy;
mysortfn(int sortBy) : m_nSortBy(sortBy) { }
bool operator()(const Sortable& a, const Sortable& b) const
{
...
}
};
HTH. Have a good weekend.
|
|
|
|
|
Robert,
Yes! That's exactly what I was looking for, I just didn't know the syntax.
Thanks very much!
Warren
|
|
|
|
|
I wanted to parse database query and replace any single quotes in any value to two single quotes.
eg:
problem query : insert into tbl (col1,col2,col3) values('correct','in'correct',''also incorrect');
expected query after parsing : insert into tbl (col1,col2,col3) values('correct','in''correct','''also incorrect');
can some one share code to accomplish the above using std::string or with some other STL class.
Thanks in advance.
|
|
|
|
|
|
hi,
i Create a application in ATL COM application,( for dll based application)
with simple get and set method for adding 2 nos
which is very similar to the link
http://www.codersource.net/atl_tutorial_events_properties.html[^]
but after build the appliaction i get error as
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject<class csimpleobj="">' : cannot instantiate abstract class due to following members:
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : warning C4259: 'long __stdcall ISimpleObj::total(void)' : pure virtual function was not defined
E:\templqw12\SimpleAtlCom\SimpleAtlCom.h(106) : see declaration of 'total'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject<class csimpleobj="">' : cannot instantiate abstract class due to following members:
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1827) : warning C4259: 'long __stdcall ISimpleObj::total(void)' : pure virtual function was not defined
E:\templqw12\SimpleAtlCom\SimpleAtlCom.h(106) : see declaration of 'total'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" csimpleobj=""> >::CreateInstance(void *,const struct _GUID &,
void ** )'
SimpleObj.cpp
reply me
send reply
|
|
|
|
|
ISimpleObj::total needs to be implemented by the look of things (the errors).
Steve
|
|
|
|
|
Hi,
I am very new to windows programming. I want to write, may be you want
to call it a shell extension, for an application that I use everyday.
I am using CA Brightstor Manager to manage my backup jobs. In that
manager you will be able to view the files and directories so that you
can select or deselect for backup. I always felt that it would be much
great if I was able to delete a file from the manager application
itself, instead of doing it over the windows explorer (at the least
when I am managing my backup job).
For this purpose I thought, if I can write a program to show the
ShellContextMenu by right clicking any folder or file in the manager
application. I am not sure how possible it is to do that without having
the code for the manager application and compiling it again.
As I told you I am very much a novice in windows programming. Any help
that you can provide is much appreciated.
Thank you,
Empit.
|
|
|
|
|
Hi ...
I have written a Windows Service using ATL COM (ATL3 / Visual Studio 6.0). The service works fine, I am able to start and stop the service.
I have created a COM Class called CTest with a methof called TestBeep(). I would like to access this object and call the method from the CServiceModule::Run() method.
Below is the CServiceModule::Run() Method.
The code will fail on both attempts to create the ITest* pTest using CoCreateInstance(). The error message are written to the event log
"Error: ITest failed"
"CoCreateInstance failed"
Any help is appreciated,
Thanks,
Chris
void CServiceModule::Run()<br />
{<br />
_Module.dwThreadID = GetCurrentThreadId();<br />
<br />
HRESULT hr = CoInitialize(NULL);<br />
<br />
_ASSERTE(SUCCEEDED(hr));<br />
<br />
CSecurityDescriptor sd;<br />
sd.InitializeFromThreadToken();<br />
hr = CoInitializeSecurity(sd, -1, NULL, NULL,<br />
RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);<br />
_ASSERTE(SUCCEEDED(hr));<br />
<br />
hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, REGCLS_MULTIPLEUSE);<br />
_ASSERTE(SUCCEEDED(hr));<br />
<br />
LogEvent(_T("Blue Service started"));<br />
LogEvent(_T("Message 1"));<br />
LogEvent(_T("Message 2"));<br />
<br />
if (m_bService)<br />
SetServiceStatus(SERVICE_RUNNING);<br />
<br />
MSG msg;<br />
while (GetMessage(&msg, 0, 0, 0))<br />
DispatchMessage(&msg);<br />
<br />
_Module.RevokeClassObjects();<br />
<br />
<br />
<br />
char progID[] = "Blue.Test.1";<br />
<br />
CLSID clsid;<br />
wchar_t wide[80]; <br />
mbstowcs(wide, progID, 80);<br />
CLSIDFromProgID(wide, &clsid);<br />
<br />
LogEvent(_T("Attempt to use ITest"));<br />
<br />
ITest* pTest = NULL;<br />
if(SUCCEEDED(CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_ITest, (void**)&pTest)))<br />
{<br />
pTest->TestBeep(); <br />
}<br />
else<br />
{ <br />
LogEvent(_T("Error: ITest failed"));<br />
} <br />
<br />
<br />
<br />
CComPtr<ITest> pObj;<br />
hr = pObj.CoCreateInstance(OLESTR("Blue.Test.1"));<br />
if( SUCCEEDED(hr) )<br />
{<br />
hr = pObj->TestBeep();<br />
if( SUCCEEDED(hr) )<br />
{ <br />
LogEvent(_T("Call to ITest was successful"));<br />
}<br />
else<br />
{ <br />
LogEvent(_T("Error: ITest failed"));<br />
} <br />
}<br />
<br />
if( FAILED(hr) )<br />
{ <br />
LogEvent(_T("CoCreateInstance failed"));<br />
}<br />
<br />
CoUninitialize();<br />
}<br />
This is the implementation of the CTest Class and the TestBeep() method
<br />
#ifndef __TEST_H_<br />
#define __TEST_H_<br />
<br />
#include "resource.h"
<br />
class ATL_NO_VTABLE CTest : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CTest, &CLSID_Test>,<br />
public IDispatchImpl<ITest, &IID_ITest, &LIBID_BLUELib><br />
{<br />
public:<br />
CTest()<br />
{<br />
}<br />
<br />
DECLARE_REGISTRY_RESOURCEID(IDR_TEST)<br />
<br />
DECLARE_PROTECT_FINAL_CONSTRUCT()<br />
<br />
BEGIN_COM_MAP(CTest)<br />
COM_INTERFACE_ENTRY(ITest)<br />
COM_INTERFACE_ENTRY(IDispatch)<br />
END_COM_MAP()<br />
<br />
public:<br />
STDMETHOD(TestBeep)();<br />
STDMETHOD(GetCount)();<br />
int nCount;<br />
};<br />
<br />
#endif //__TEST_H_<br />
<br />
<br />
<br />
#include "stdafx.h"<br />
#include "Blue.h"<br />
#include "Test.h"<br />
<br />
<br />
<br />
STDMETHODIMP CTest::GetCount()<br />
{<br />
<br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CTest::TestBeep()<br />
{<br />
Beep(4000, 200); <br />
Beep(1000, 50); <br />
Beep(4000, 200); <br />
Beep(1000, 50); <br />
return S_OK;<br />
}<br />
<br />
Thanks
Chris
|
|
|
|
|
Hi ...
The solution to this problem is to put the com call to ITest above the message loop. Below is the corrected code.
Thanks,
Chris
void CServiceModule::Run()<br />
{<br />
_Module.dwThreadID = GetCurrentThreadId();<br />
<br />
HRESULT hr = CoInitialize(NULL);<br />
<br />
_ASSERTE(SUCCEEDED(hr));<br />
<br />
CSecurityDescriptor sd;<br />
sd.InitializeFromThreadToken();<br />
hr = CoInitializeSecurity(sd, -1, NULL, NULL,<br />
RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);<br />
_ASSERTE(SUCCEEDED(hr));<br />
<br />
hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, REGCLS_MULTIPLEUSE);<br />
_ASSERTE(SUCCEEDED(hr));<br />
<br />
LogEvent(_T("Blue Service started"));<br />
LogEvent(_T("Message 1"));<br />
LogEvent(_T("Message 2"));<br />
<br />
if (m_bService)<br />
SetServiceStatus(SERVICE_RUNNING);<br />
<br />
<br />
<br />
char progID[] = "Blue.Test.1";<br />
<br />
string strTemp; <br />
char szTemp[10]; <br />
<br />
CLSID clsid;<br />
wchar_t wide[80]; <br />
mbstowcs(wide, progID, 80);<br />
CLSIDFromProgID(wide, &clsid);<br />
<br />
LogEvent(_T("Attempt to create the ITest Com Object"));<br />
<br />
ITest* pTest = NULL;<br />
<br />
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_ITest, (void**)&pTest); <br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
pTest->TestBeep(); <br />
}<br />
else<br />
{ <br />
sprintf(szTemp, "%h", hr); <br />
strTemp = "Error: ITest failed. HResult=" + (string)szTemp; <br />
LogEvent(_T(strTemp.c_str()));<br />
} <br />
<br />
<br />
MSG msg;<br />
while (GetMessage(&msg, 0, 0, 0))<br />
DispatchMessage(&msg);<br />
<br />
_Module.RevokeClassObjects();<br />
<br />
<br />
CoUninitialize();<br />
}<br />
<br />
|
|
|
|
|
Hi
I am creating a new ActiveX from an existing ActiveX. I just creted class id using GUIDGen.exe and compile the project. But the new control is not downloading to machine where the old control present.
Do we need to change the class name of ActiveX too?
How to chnage the class name? There are many existence of class name in the project? Please advise..
|
|
|
|
|
|
In ATL, you have CWindow which wraps most of the Win32 functionality in an easy to use class. Would that work for you?
George Mileka
|
|
|
|
|
must use _Module.Init(NULL, hInstance); in dllMain?
|
|
|
|
|
I quick search through the ATL source for "_Module" got 155 hits - so yeah you should call _Module.Init .
Steve
|
|
|
|
|
these code what action?
HRESULT hRes = ::CoInitialize(NULL);
ATLASSERT(SUCCEEDED(hRes));
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_BAR_CLASSES);
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
......
_Module.Term();
::CoUninitialize();
|
|
|
|
|
|
I am using an ocx in my asp.net project but as I am recompiling my ocx code, it stops working in my asp.net page where I am using it even though I am making the registry entry again.
The same recompiled code works in html page. Is there any kind of security setting which we have to set or some other king of thing. I am totally stuck!
Kindly help...
padma gahlot
|
|
|
|
|