Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
The class name of the control I'm referring as viewed by spy++ is TBEGUIFileViewer. I can reference to the object by simply using FromHandle(/*Handle provided by spy++*/).....but I can't use CWnd's function SetWindowText(), etc. I've found this code on msdn which is somewhat related (I'm not sure) but seems hanging....This is the code: (http://msdn.microsoft.com/en-us/library/6fde5b3k(VS.80).aspx[^])
<br />
   // IDC_MSACALCTRL1 is the ID of the Calendar control OCX embedded <br />
   // on this dialog<br />
   CWnd *pWndCal = GetDlgItem(IDC_MSACALCTRL1);<br />
<br />
   // Use the IUnknown of the control<br />
   LPUNKNOWN pUnk = pWndCal->GetControlUnknown();<br />
<br />
   // From there get the IDispatch interface of control<br />
   LPDISPATCH pDisp = NULL;<br />
   pUnk->QueryInterface(IID_IDispatch, (LPVOID*)&pDisp);<br />
<br />
   // use IDispatch method to invoke the control's functionality<br />
<br />
   return TRUE;  // return TRUE unless you set the focus to a control<br />


What am I going do with LPDISPATCH/IDispatch after? And how am I going access the control? Please help.....Thanks
Posted

1 solution

It's only going to have an IDispatch if it's an ActiveX control - if it's an ordinary control then you're not going to be able to control it through IDispatch.

The problem you've got isn't that easily solved. As you don't know the interface you're going to have to work out what is does. If you feel perverse enough you could start sending messages to the control and see what it does. That's not likely to be that effective if it has any custom messages, commands or notifications. The sheer number of possibilities is likely to be a bit heavy.

Personally I'd try and find the original developer and ask them to describe the control's interface. If you can't then write your own with similar functionality. It's likely to be easier than trying to reverse engineer the control's interface.

Cheers,

Ash
 
Share this answer
 
Comments
this_is_my_alias 7-Sep-10 9:34am    
I followed your suggestion, sending messages. I even tried to get its runtime class and found out that its still just derived from CWnd. But I really can't set or get window text even if I use SendMessage. The application I'm talking about is BareTail Log Viewer. Anyways, how do you know if its an ActiveX control/not?
Aescleal 7-Sep-10 14:17pm    
I'm confused, why would you expect it to be an MFC window? They usually have window class names starting with Afx - the one you're trying to do something with looks like it's a custom control which might have been written in C for all you know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900