Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   Using ActiveX from Win32/Atl (http://www.go4expert.com/forums/using-activex-win32-atl-t3151/)

DarkSun23 26Feb2007 03:56

Using ActiveX from Win32/Atl
 
Hey there!
I am trying to do something a bit difficult and need you help...

I have an MFC form containing a VB control, called the MS Flex Grid (C:\WINDOWS\system32\MSFLXGRD.OCX) ActiveX Control and some legacy code.

Unfortunately I am not allowed to change this code or use MFC, But I still want to access and manipulate the control using from a Win32 function (and since needed, using ATL as well).

I tried several attitudes, the first was obtaining a handle (HWND) to the control and passing messages (via SendMessage) to it in order to command it... Unfortunately it seems SendMessage only works for the basic Win32 controls (ListBox/Label etc.) and it let's me manipulate their basic functionality only, so it's no good....

Looking around I've noticed that a function called: GetDlgControl is mentioned in some places and might be of use, but I have found no such function. All I found was the ATL CWindow::GetDlgControl function, So I tried something like this:

_Module.Init(NULL, AfxGetInstanceHandle(), &LIBID_ATLLib);
CWnd *cwnd = GetDlgItem(IDC_MSFLEXGRID1);
HWND hWnd = *cwnd;
MSFlexGridLib::IMSFlexGridPtr pFlexGrid = NULL;
CWindow wnd(hWnd);
HRESULT hr = wnd.GetDlgControl(IDC_MSFLEXGRID1,
__uuidof(MSFlexGridLib::IMSFlexGrid),
(void**)&pFlexGrid);
But hr is equal E_FAIL (MSDN = "the function returns E_FAIL if the control specified by nID (first parameter) cannot be found"). But this -is- the right resource ID.

Then I tried something else instead:
_Module.Init(NULL, AfxGetInstanceHandle(), &LIBID_ATLLib);
HWND hWnd2 = (HWND)m_mfcFlexGridControl;
HWND hWnd = (HWND)GetDlgItem(IDC_MSFLEXGRID1);
MSFlexGridLib::IMSFlexGridPtr pFlexGrid = NULL;
CWindow wnd(hWnd2);
HRESULT hr = wnd.GetDlgControl(IDC_MSFLEXGRID1,
__uuidof(MSFlexGridLib::IMSFlexGrid),
(void**)&pFlexGrid);
But got the same result....

As it didn't work, I also tried several other combinations such as:
#import "C:\WINNT\System32\msflxgrd.ocx" raw_interfaces_only,
raw_native_types, no_namespace, named_guids
I even (with some despair...) tried in a loop all the IDs from 0 to 50000 in a loop....But Too no avail...

What am I missing here?
:confused:

Many thanks!


All times are GMT +5.5. The time now is 02:09.