|
Hello,
I have a CRichEditCtrl box on a CMDIChildWnd which is created and displayed properly on the window.
But when the window loses focus and if the focus is brought back to the window then the focus mouse cursor doesnt appear on the window. The mouse cannot be clicked on the CRichEditCtrl window or if clicked the editing mouse cursor doesnt appear on the CRichEditCtrl window. The CrichEditCTrl window appears as if dead on the CMDIChildWnd where the text is visible but cannot be edited or clicked .
What must be the reason?
Prithaa
|
|
|
|
|
I have tried implementing isenslogon but i am not able to get notification.
I have out logs in the function implementation for logon/logoffas follows
interface MyISensLogon : public ISensLogon
{
private:
long ref;
HWND IsensLog;
public:
MyISensLogon()
{
ref = 1;
}
STDMETHODIMP QueryInterface(REFIID iid, void ** ppv)
{
if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDispatch) ||IsEqualIID(iid, __uuidof(ISensLogon)))
{
*ppv = this;
AddRef();
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef ()
{
return InterlockedIncrement(&ref);
}
ULONG STDMETHODCALLTYPE Release ()
{
int tmp;
tmp = InterlockedDecrement(&ref);
return tmp;
}
HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT *pctinfo )
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE GetTypeInfo ( UINT iTInfo, LCID lcid,ITypeInfo **ppTInfo)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE GetIDsOfNames (REFIID riid, LPOLESTR *rgszNames,UINT cNames, LCID lcid,DISPID *rgDispId)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE Invoke (DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags, DISPPARAMS *pDispParams,VARIANT *pVarResult, EXCEPINFO *pExcepInfo,UINT *puArgErr)
{
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE Logon(BSTR bstrUserName)
{
WriteLog( "Ctrl-LogON event\n\n" );
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE Logoff(BSTR bstrUserName)
{
sprintf(temp,"Logoff for user %s with CurrentSID = %s",user,CurrentSID);
WriteLog(temp);
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE StartShell( BSTR bstrUserName)
{
WriteLog("Inside StartShell");
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE DisplayLock( BSTR bstrUserName)
{
WriteLog("Inside DisplayLock");
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE DisplayUnlock( BSTR bstrUserName)
{
WriteLog("Inside DisplayUnlock");
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE StartScreenSaver( BSTR bstrUserName)
{
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE StopScreenSaver( BSTR bstrUserName)
{
return S_OK;
}
};
subscription func is follows :-
static MyISensLogon *pISensLogon = 0;
HRESULT SubscribeLogoffNotification()
{
IEventSubscription* pIEventSubscription = 0;
HRESULT hr = S_OK;
HRESULT comInit = E_FAIL;
HRESULT res = S_OK;
WCHAR buffer[64] = {0};
int i = 0;
comInit = CoInitialize(0);
if (comInit != RPC_E_CHANGED_MODE)
{
hr = comInit;
if (FAILED(hr))
{
goto error;
}
}
res=CoCreateInstance(__uuidof(CEventSystem), 0,CLSCTX_SERVER,__uuidof(IEventSystem),(void**)&pIEventSystem);
if((FAILED(res))|| (NULL == pIEventSystem))
{
WriteLog("SubscribeLogoffNotification : Error create com instance for CEventSystem");
goto error;
}
pISensLogon= new MyISensLogon();
char temp[220];
for(i=0; i<7; i++)
{
sprintf(temp,"\nSubscribeLogoffNotification for i=%d started",i);
WriteLog(temp);
res=CoCreateInstance(__uuidof(CEventSubscription),0, CLSCTX_SERVER,__uuidof(IEventSubscription),(LPVOID*)&pIEventSubscription);
if((FAILED(res))
|| (NULL == pIEventSubscription))
{
goto error;
WriteLog("\nSubscribeLogoffNotification : Error create com instance for CEventSubscription");
}
res=pIEventSubscription->put_EventClassID(OLESTR("{d5978630-5b9f-11d1-8dd2-00aa004abd5e}"));
if(FAILED(res))
goto error;
res=pIEventSubscription->put_SubscriberInterface((IUnknown*)pISensLogon);
if(FAILED(res))
goto error;
MultiByteToWideChar(0,0,methods[i],-1,buffer,64);
res=pIEventSubscription->put_MethodName(buffer);
if(FAILED(res))
goto error;
MultiByteToWideChar(0,0,names[i],-1,buffer,64);
res=pIEventSubscription->put_SubscriptionName(buffer);;
if(FAILED(res))
goto error;
MultiByteToWideChar(0,0,subids[i],-1,buffer,64);
res=pIEventSubscription->put_SubscriptionID(buffer);
if(FAILED(res))
goto error;
res=pIEventSystem->Store(PROGID_EventSubscription,(IUnknown*)pIEventSubscription);
if(FAILED(res))
goto error;
pIEventSubscription->Release();
pIEventSubscription=0;
sprintf(temp,"\nSubscribeLogoffNotification for i=%d Completed",i);
WriteLog(temp);
}
res = S_OK;
return res;
error:
CoUninitialize();
return res;
}
with loads of thanks
|
|
|
|
|
Hi,
I am working in an application with docking window like Visual Studio 2005 interface. I do it with Visual Studio 2008 and MFC.
The left pane is a CTreeCtrl. I put items in it. When I click on an item, I want to display a form in the view portion of the application.
To do that, I have a member function called void CViewTree::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) to catch the event.
To display the form associated with the item clicked, I have to access the view class and after that the document class.
I access the view like that from the CViewTree::OnTvnSelchanged function:
CFrameWnd *pFrameWnd = (CFrameWnd*)AfxGetApp()->m_pMainWnd;
CCDSView* pView;
pView = (CCDSView*)pFrameWnd->GetActiveView();
I get memory leaks, but the program run anyway.
What I can't understand is that the program run under Vista 64 Home premium at home, but not run on an XP computer at office.
I compile it with Net Framework 2.0.
Does it has another way to access the view or document that does not crash my application ?
Thanks,
Claude
|
|
|
|
|
I am currently writing an application using C++ and MFC. I am in the process of trying to add a tool bar to my application. The class I am using to do this is CToolBarCtrl. The tool bar will have several buttons on it but all these buttons must be represented ( at least as I understand it )
by a single bitmap. I am finding it very difficult to create this bitmap and have it look good. I am using the bitmap editor that came with Visual Studio. Part of the problem is that I cannot get things
lined up right. Also, once a get a letter onto the bitmap, I do not seem to be able to move it. This
is often necessary since I do not always but it in the right place to start with.
I am wondering if I could create one bitmap for each button and then put all the bitmaps together to come up with one large bitmap.
I am hoping that somebody out there will have a suggestion for me.
Thanks
Bob
|
|
|
|
|
Of course it can be moved.
Mark the selection using the rectangle selection tool and drag it with the mouse.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
The built-in bitmap editor is pretty limited and hard to work with. Try downloading Gimp or Paint.net.
Both are free, and much better for this kind of work.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Thanks for the responses. They were helpfully and I am now using GIMP. I believe it works better
than the Microsoft tool.
Bob
|
|
|
|
|
I was just wondering how to use the windows 7 sdk with qt?
thanks
|
|
|
|
|
Have you tried installing them both and...well, just using them?
It should just be a case of setting suitable include and library paths for the compiler toolchain, I would have thought?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
|
|
Well, the example you point at is for VC6, not VS2008 (which I guess is what you mean - there's no VC++2009) - and ATL has changed quite a lot since VC6.
You might try this more up to date example[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You must be a mind reader!!
Yes, it's 2008 (I was in a hurry and saw v 9 in Help->About)
Thanks a lot!!
I will give that example a try!
|
|
|
|
|
Dang it!
I opened the *.sln, Visual Studio did the conversion.
When I click build it does so in <1 second and says:
1>------ Skipped Rebuild All: Project: ATLCon ------
1>
========== Rebuild All: 0 succeeded, 0 failed, 1 skipped ==========
No output files are created.
If I open any of the *.cpp files and attempt to compile them individually I get a popup message saying The operation could not be completed. Unspecified Error. ...
I tried the attribute and non-attribute versions.
One of the comments in the conversion log of the non-attributes version says "ATL Server support has been removed from this version of Visual Studio. In case your ATL Project uses any ATL Server functionality, your project may not build. Please consult the MSDN documentation for a list of alternatives." so... Is ATL going away or somthing...?
|
|
|
|
|
|
Bummer... the atlcon samples that come with vs 2008 msdn install don't work either
C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033\AllVCLanguageSamples\C++\ATL\General\AtlCon
|
|
|
|
|
I'll see if I can create a new project with the ATL & MFC support options selected and add the source files to it.
Perhaps that will work...
|
|
|
|
|
Worked for me - but I did notice that the default configuration was "Debug Itanium" - I suspect that a) you don't have an Itanium chip in your PC, and b) you don't have the Itanium cross-compilers installed, so if that's the configuration you've got, try the Win32 configuration
I couldn't try it with an Adobe Reader control - I don't have Adobe Reader installed on my Windows VM on my Mac - OS X's Preview app does the job of reading PDFs better and more quickly
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
DOH!
I didn't see the "Itanium" setting.
I switched it to "win32" and it compiles and runs!
Thanks for your help!
I'm going to take a closer look at this to see if I can figure out how to get this to work in a win32 HWND now.
Again, thanks for your help!
|
|
|
|
|
Sorry - thought I'd pointed you at a VS2008 sample
Not sure why the sample requires ATL Server - but it was open-sourced and can be downloaded on CodePlex[^]. It was probably for some utility class that did actually get moved to ATL.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am able to get the ActiveX control to load now.
The thing that made this work was using
hr = AtlAxCreateControl( OLESTR( "c:\\test.pdf" ), pThreadParam->hwnd, NULL, &pUnk ); instead of using ::CreateWindow(...) or trying to use AtlAxWindow().
HOWEVER (darn it!) when I close the application window I get an access violation in the message loop:
while( 1 )
{
rv = GetMessage(&msg, NULL, NULL, NULL) ;
rv = TranslateMessage(&msg);
rv = DispatchMessage(&msg);
}
It is erroring in the call to "GetMessage(...)".
I thought it might be that I need to send a WM_CLOSE message before the main window closes, but that doesn't help.
If I send WM_CLOSE it seems to cause an access violation in a different thread of the main application.
I tried breaking out of the message loop if WM_CLOSE (or some other event) is detected, but that just caused the app to hang (as I would expect).
Is there any way to unload the ActiveX control from the win32 cleanly?
I'm sure there is a way, I'm just not seeing it.
I can send source code if that would be useful.
I which I could attach it instead of inlining it though.
|
|
|
|
|
Did you ever Release that IUnknown pointer you got back in pUnk? If not, the control will likely think it's meant to stick around, as its reference count never gets to zero. That could cause issues.
snacker2 wrote: I get an access violation in the message loop
Where exactly (look at the call-stack)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I was saving the reference in memory and calling release just before the window is closed.
But now...
I changed it to call Release().
Here is how I am creating the control (changed to use a url):
VOID CreateControl( HWND hwnd )
{
HRESULT hr = CoInitialize( NULL );
printf( "CoInitialize(NULL) -> hr=[0x%x]\n", hr );
printf( "Create AtlAxWin Begin...[0x%x]\n", hwnd );
BOOL rslt = AtlAxWinInit();
printf( " AtlAxWinInit() --> %d\n", rslt );
IUnknown *pUnk = NULL;
hr = AtlAxCreateControl( OLESTR( "http://www.microsoft.com" ), hwnd, NULL, &pUnk );
printf( "AtlAxCreateControl(...) -> hr=[0x%x] : pUnk=[0x%x]\n", hr, pUnk );
ULONG relRslt = pUnk->Release();
printf( "Release() -> %d\n", relRslt );
}
Here is the output:
CoInitialize(NULL) -> hr=[0x0]
Create AtlAxWin Begin...[0x150dac]
AtlAxWinInit() --> 1
AtlAxCreateControl(...) -> hr=[0x0] : pUnk=[0x3233e30]
Release() -> 7
Although the "Release() " is returning 7, it appears to be working... ONLY if I send WM_CLOSE to the HWND prior to closing the window.
However, I don't think I want to close the HWND in all cases.
Is there a way to just remove or unload the control, so the HWND can be reused?
In fact if I use Adobe Reader via specifying c:\test.pdf it works until I shutdown the application.
At the end of the app I get an access violation:
> Multimedia.api!2d80acf5()
[Frames below may be incorrect and/or missing, no symbols loaded for Multimedia.api]
msvcr80.dll!04932bd9()
Multimedia.api!2d83e2a5()
Multimedia.api!2d802cc0()
Multimedia.api!2d80c885()
Multimedia.api!2d80123c()
Multimedia.api!2d8b3698()
Multimedia.api!2d80101d()
ntdll.dll!7c90118a()
ntdll.dll!7c923ada()
ntdll.dll!7c910435()
ntdll.dll!7c90eb99()
kernel32.dll!7c81cb26()
java.exe!004071b4()
java.exe!004072f3()
java.exe!00407319()
java.exe!004087cb()
kernel32.dll!7c817077()
java.exe!00410072()
java.exe!00410072()
java.exe!00410072()
java.exe!00410072()
I'm guessing the java vm doesn't know about the win32 HWND being "closed"... but that's just a guess?
|
|
|
|
|
However... perhaps I could create a child window which is just a child to the HWND passed in?
Perhaps that would prevent the jvm crashing at the end?
|
|
|
|
|