Hi All, I have been going through one of my older projects and updating it from WTL 7.0 to 7.1 and am getting error which I have no idea how to fix. I have search through the forum and have found no-one else has had this problem... or the problem is so easy that I cannot see the solution. All I have done is changed the path to my wtl 7.0 include to now point to the 7.1 includes. I then rebuild my app and get the following error C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(396) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(397) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(595) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(599) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(600) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(603) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlapp.h(844) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atluser.h(39) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atluser.h(39) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atluser.h(57) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atluser.h(82) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atluser.h(205) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atluser.h(490) : see reference to class template instantiation 'WTL::CMenuT' being compiled C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlgdi.h(78) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlgdi.h(86) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlgdi.h(88) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlgdi.h(528) : error C2872: 'ATL' : ambiguous symbol C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\WTL71\INCLUDE\atlgdi.h(682) : see reference to clas
bryces
Posts
-
error C2872: 'ATL' : ambiguous symbol in conversion from wtl7.0 to 7.1 -
GetUserName() fails in ATL COM objectHi Michael, Thanks, you are indeed correct. below is what is needed to be done:
LPTSTR username; DWORD cchBuff = 1024; TCHAR tchBuffer[1024]; username = tchBuffer; //this is what I was missing... BOOL result = GetUserName(username, &cchBuff);
cheers Bryce -
GetUserName() fails in ATL COM objectHi All, Does anyone know why I would get a first chance exception occur when I try to get the current Username in a COM object I have? the error message is as follows: First-chance exception in app.exe (SECUR32.DLL): 0xC0000005: Access Violation. The program 'C:\app.exe' has exited with code 0 (0x0). when all I am trying to do is LPTSTR username; DWORD cchBuff = 1024; BOOL result = GetUserName(username, &cchBuff); thanks for your help cheers Bryce
-
CCheckListBox and CListBoxImplThanks for your help. I can get it to compile now! I did change it a little bit so that DDX can work. in stdafx.h define like below
class CListViewCtrlImpl : public CWindowImpl<CListViewCtrlImpl, CListViewCtrl> { DECLARE_EMPTY_MSG_MAP(); };
then in your class you use CListViewCtrlImpl instead of CListViewCtrl. What method did you use to add elements to the List? I simple demo app would be handy. please send thanks cheers Bryce -
CCheckListBox and CListBoxImplHi, Thanks for your reply. I thought there may have been another version of the CheckListBox for WTL... oh well... How have you defined what your ClistViewControl object is? The supplied code will not compile as there is no definition of ClistViewControl. I tried to convert it to CListViewControlImpl m_ListView; with below in stdafx.h
class CListViewControlImpl : public CWindowImpl { DECLARE_EMPTY_MSG_MAP(); };
Can you please supply your definition on your ClistViewControl. Thanks Bryce -
CCheckListBox and CListBoxImplHi All, I was wondering if anyone has done any development in WTL with the CCheckListBox? I have a ListBox but want to give the functionality (and feedback to user) that they have selected multiple items. I have tried using the macro's described in MSDN but have had no luck.
ListView_SetExtendedListViewStyle(this->m_ipCheckList.m_hWnd, LVS_EX_CHECKBOXES);
When I mean no luck, I mean that the above call has no effect on my ListBox (no check box appears next to it). Any thoughts on what I would have to do to get something like the above going? thanks Bryce -
Problem with Custom COM object in implementation of InterfaceHi, I Have a custom com object which I want to use as a class member for an implemantation of another COM interface. This is what I have done and the trouble I am having: I place the COM object (my own one) as a class member in my class that Implements IExtension. (since all my other objects get a reference to the IExtension to see if it is active or not). I have created two functions which preform operations on the Custom COM object. This is where I come unstuck. I figured I had to QueryInterface to my own implementation of IExtension which has the methods defined. I don't know how to call my custom functions as I get compilation errors saying: error C2039: 'GetTargetName' : is not a member of '_NoAddRefReleaseOnCComPtr<struct IMyExtension>' Error executing cl.exe. I have no idea why this is happening and cannot work out why. If I have defined my extensions and objects as follows.... The only thing I can think of is that I am breaking one of the RULES of COM. I cannot see which one. Do I have to explicitly define the QI, AddRef, Release methods in my class? From all the example on here... I didn't think I did... here is a reference to an example: http://www.codeproject.com/com/hellocom.asp[^] your help would be greatly appreciated. cheers Bryce
///////////////////////////////////////////////////////////////////////////// // CMyExtension class ATL_NO_VTABLE CMyExtension : public CComObjectRootEx, public CComCoClass, public ISupportErrorInfo, public IMyExtension, public IExtension, public IExtensionConfig { public: CMyExtension() { //Get the below two constants from the _i.c const CLSID CLSID_TargetLayer = {0x2CEBA738,0x0533,0x4F68,{0xB1,0xC5,0x88,0xB3,0xD9,0x5B,0xA3,0xE3}}; const IID IID_ITargetLayer = {0xD149DEA4,0xBB32,0x4D9A,{0x88,0xC7,0xA2,0x61,0x43,0x7D,0xC8,0xBA}}; //create the com HRESULT hr = CoCreateInstance(CLSID_TargetLayer, NULL, CLSCTX_INPROC_SERVER,IID_ITargetLayer, (LPVOID*) &m_ipTargetLayer); if (SUCCEEDED(hr)) { } } DECLARE_REGISTRY_RESOURCEID(IDR_MYEXTENSION) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(CMyExtension) COM_INTERFACE_ENTRY(IHistoryExtension)
-
DDX DLL and CComboBoxImpl in WTLThankyou ohhhhh so much. Works now! cheers Bryce
-
DDX DLL and CComboBoxImpl in WTLI left it out deliberatly to test if I could use the GetDialogText(...) call. Which still fails.
LRESULT CAboutDlg::OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { DoDataExhange(true); //gives>error C2065: 'DoDataExhange' : undeclared identifier CString pValueString; //error C2664: 'int __thiscall ATL::CWindow::GetDlgItemTextA(int,unsigned short *& ) const' : cannot //convert parameter 2 from 'class WTL::CString *' to 'unsigned short *& ' //A reference that is not to 'const' cannot be bound to a non-lvalue int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, &pValueString); //works, but how can you find out which was selected //this->m_pComboBox.GetLBText(wNotifyCode, pValueString); //AtlMessageBox(NULL, pValueString.AllocSysString(), _T("Selection"), MB_OK); return 0; }
BEGIN_DDX_MAP(CAboutDlg) //DDX_CONTROL(IDC_STATIC_PIC, m_pPic) DDX_CONTROL(IDC_COMBO_TARGET, m_pComboBox) DDX_TEXT(IDC_COMBO_TARGET, m_szTargetLayer) END_DDX_MAP() I was wondering if you had tested what I described in another post about changing the aboutdlg setting? cheers Bryce -
DDX DLL and CComboBoxImpl in WTLAhhhh found out something interesting. if you try to change the About dialog in a WTL wizard created application, which is dialog based.... the compiler bombs as well. so if you do the following: Add a combo box to the about dialog and label it IDC_COMBO_TARGET aboutdlg.h
// aboutdlg.h : interface of the CAboutDlg class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_ABOUTDLG_H__A290BA10_FE73_4A12_8FCA_FEBA7A47586B__INCLUDED_) #define AFX_ABOUTDLG_H__A290BA10_FE73_4A12_8FCA_FEBA7A47586B__INCLUDED_ class CAboutDlg : public CAxDialogImpl<CAboutDlg>, public CWinDataExchange<CAboutDlg>, public CComObjectRootEx< aboutdlg.cpp `// aboutdlg.cpp : implementation of the CAboutDlg class // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "resource.h" #include "aboutdlg.h" LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { CenterWindow(GetParent()); return TRUE; } LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND`
-
DDX DLL and CComboBoxImpl in WTLThe inheritance list for the dialogs is like the following... the <CTargetDialog>, were all removed class CTargetDialog : public CAxDialogImpl<CTargetDialog>, public CWinDataExchange<CTargetDialog>, public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CTargetDialog>,
-
DDX DLL and CComboBoxImpl in WTLHi Mike, Thanks fro the reply. Here is my inheritance list for my dialog:
class CTargetDialog : public CAxDialogImpl, public CWinDataExchange, public CComObjectRootEx, public CComCoClass
And here is is my listing for stdafx.h#if !defined(AFX_STDAFX_H__63977A7A_D850_4BDE_A636_B409D3974963__INCLUDED_) #define AFX_STDAFX_H__63977A7A_D850_4BDE_A636_B409D3974963__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define STRICT #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif #define _WTL_USE_CSTRING #define _ATL_APARTMENT_THREADED #include #include extern CAppModule _Module; #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(push) #pragma warning(disable : 4146) #pragma warning(disable : 4192) #import "C:\arcgis\arcexe83\bin\esriCore.olb" \ raw_interfaces_only, \ raw_native_types, \ no_namespace, \ named_guids, \ exclude("OLE_COLOR", "OLE_HANDLE") #pragma warning(pop) #include "C:\arcgis\arcexe83\ArcObjects Developer Kit\Kits\CATIDs\arccatids.h" #if _ATL_VER < 0x0700 #undef BEGIN_MSG_MAP #define BEGIN_MSG_MAP(x) BEGIN_MSG_MAP_EX(x) #endif class CStaticImpl : public CWindowImpl { DECLARE_EMPTY_MSG_MAP() }; class CComboBoxImpl : public CWindowImpl { DECLARE_EMPTY_MSG_MAP(); };
I have had to reorganize my header files list in the Tools>Options>Directories otherwise I get a redefinition of ISegment error. I have placed the path of the widowsSDK at the bottom of the list and the path to the WTL libraries at the top of the list. I doubt this is the source of my problems though. cheers Bryce -
DDX DLL and CComboBoxImpl in WTLThanks for your help, The compiler errors are: For fetching the selected item in the combo box
CString pValueString; int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, pValueString);
error C2664: 'int __thiscall ATL::CWindow::GetDlgItemTextW(int,unsigned short *& ) const' : cannot convert parameter 2 from 'class WTL::CString' to 'unsigned short *& ' A reference that is not to 'const' cannot be bound to a non-lvalue And for OnInit....DoDataExhange(true);
-
DDX DLL and CComboBoxImpl in WTLHi All, I seem to be having the most stupid problem (well I am the stupid one) with retrieving the selected value out of a ComboBox. Background info: All my development is within an ATL Com based DLL. I have extended its functionality by including the WTL libraries in the stdafx.h header. The DLL is a set of tools and dlgs that are loaded into the calling application. I have read Michael Dunns intro to WTL articles and found them encouraging... hence trying to use them in my project. However I seem to be having trouble implementing the msg maps and ddx maps etc in the dialogs as they seem to crash the calling application. For the calling application and DLL to work, the dialogs must be of type
CAxDialogImpl
. I have one Dialog that I have managed to use WTL message maps in and it works ok. However other time it doesn't. I cannot get the DDX map to map the values from my ComboBox to my class members:class CTargetDialog : public CAxDialogImpl,//public CUpdateUI, //public CMessageFilter, public CIdleHandler, public CWinDataExchange, public CComObjectRootEx, public CComCoClass { public: CTargetDialog(IApplicationPtr pApp); ~CTargetDialog(); enum { IDD = IDD_TARGETDIALOG }; BEGIN_MSG_MAP(CTargetDialog) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_ID_HANDLER(IDOK, OnOK) COMMAND_ID_HANDLER(IDCANCEL, OnCancel) COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_SELCHANGE, OnSelchangeCombo_target) COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_DROPDOWN, OnDropdownCombo_target) END_MSG_MAP() BEGIN_DDX_MAP(CTargetDialog) DDX_CONTROL(IDC_COMBO_TARGET, m_pComboBox) DDX_TEXT(IDC_COMBO_TARGET, m_szTargetLayer) END_DDX_MAP() // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnDropdownCombo_target(WORD wNotifyCode, WORD wID, HWND hWnd
-
ATL/WTL DLL and the CMessageLoop* pLoopHi All, After reading Michael Dunns WTL articles I want to convert my ATL/MFC COM Dlls to ATL/WTL ones. Building the DLL from base setting I have built a standard ATL project and then added the required WTL #includes as per the examples in Michaels articles. I have changes the CComModule to CAppModule and compiled. Everything works a treat! I am little bit confused though an where to exactly define/create my CMessageLoop object. Should I do this in the DLLMain function?
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { if (dwReason == DLL_PROCESS_ATTACH) { _Module.Init(ObjectMap, hInstance, &LIBID_WTLHISTORYLib); DisableThreadLibraryCalls(hInstance); **// register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this);** } else if (dwReason == DLL_PROCESS_DETACH) _Module.Term(); return TRUE; // ok }
What the DLL is to do is: Have however many classes required, each implementing whatever COM interfaces that they need too Do there thing and return back to Calling Application. Am I in the right ballpark or because it is a DLL each COM implemented class has its own map... like below// CMyReport class ATL_NO_VTABLE CMyReport: public CComObjectRootEx, public CComCoClass, public ISupportErrorInfo, public IHistoryReport, public ICommand { public: CMyReport(); ~CMyReport(); DECLARE_REGISTRY_RESOURCEID(IDR_MYREPORT) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(CMyReport) COM_INTERFACE_ENTRY(IMyReport) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY(ICommand) END_COM_MAP() BEGIN_CATEGORY_MAP(CMyReport) IMPLEMENTED_CATEGORY( __uuidof(CATID_MxCommands)) END_CATEGORY_MAP() // IMakeHistory public: // ICommand STDMETHOD(get_Enabled)(VARIANT_BOOL * Enabled); STDMETHOD(get_Checked)(VARIANT_BOOL * Checked); STDMETHOD(get_Name)(BSTR * Name); STDMETHOD(get_Caption)(BSTR * Caption); STDMETHOD(get_Tooltip)(BSTR * Tooltip); STDMETHOD(get_Message)(BSTR * Message); STDMETHOD(get_HelpFile)(BSTR * HelpFile); STDMETHOD(get_HelpContextID)(LONG * helpID); STDMETHOD(get_Bitmap)(OLE_HANDLE * Bitmap); STDMETHOD(get_Category)(BSTR * categoryName); STDMETHOD(OnCreate)(IDispatch * hook); STDME
-
Controlling the MediaPlayer ocx controlHi Abhishek, Yep looking at the VB object browser was a good idea. I have foudn one reason why it was not possible working.... I forgot to import the ocx object definition for the MediaPlayer (msdxm.ocx). However, when I define the IMediaPlayer the compiler doesn't have a clue about what to do. C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : error C2065: 'IMediaPlayer' : undeclared identifier C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : error C2065: 'mediaplayer' : undeclared identifier C:\DEVELOPMENT\VideoTool\SelectedWin.cpp(18) : warning C4552: '*' : operator has no effect; expected operator with side-effect I getting pretty frustrated why it seems so complex to something that should be simple. I am relatively new to ATL MFC etc.... but this should be a walk in the park. thanks for your help cheers Bryce
-
Controlling the MediaPlayer ocx controlHi Michael, Thanks for the pointer to your articles! nice to read the background info on why certain things have to be done. The WTL example that you posted was with a com server (.exe). Does having my extension with activex control change many things if it is in a DLL? Cheers Bryce
-
Controlling the MediaPlayer ocx controlHi Abhishek, Thankyou for your help. I have done what you said above, but need a little more guidance. When you say at the end "Using this pointer query for other media control interfaces..and enjoy coding"... what is the other media control interfaces? What interfaces/objects should I be aiming to query too...? I want to be able to do something like.... HWND hwn=GetDlgItem(IDC_MEDIACONTROL1) CWnd * wnd=new CWnd(); wnd->Attach(hwn); IUnknownPtr pUnknown; pUnknown = GetControlUnknown(); //....... //Query interface to some type of MediaPlayer object IMediaPlayerPtr pMyPretendMediaPlayerObject; //any ideas on the correct interface? pMyPretendMediaPlayerObject->Open("The path to the file I want"); pMyPretendMediaPlayerObject->Play(); //....... Does the logic for this seem ok.... or could you point me to somewhere I could read up on this. thanks for your help cheers Bryce
-
Controlling the MediaPlayer ocx controlHi All, I am in the process of developing an ATL/COM extension for an application in which I have embedded the Windows Media Player ocx COM Control into an ATLDialog object. How do I get control of this object so that I can change the video being displayed? I guess if it was a CDialog I could use the appwizard to map the control to member variable. How do I do this for an ATL Dialog? Do I get the handle and then ...... You help would be greatly appreciated cheers Bryce
-
ATL Edit field validation?Hi Steve, Thanks for your help! You hit the nail on the head with your reply... exactly the problem. Will remember that one from now on. Another quick question if you can be bothered answering: Is it the programmers responsability to do the SysFreeString if they have called SysAllocString, or will be taken care of by the compiler? (Am relatively new to the ATL/COM system, and have had the luxury of the automatic garbage collection in java) Is there a general rule for COM objects for when they should be ->Release() or ->Detach(). It seems that if I call CoCreateInstance, then I need to call ->Release() otherwise if I have a smartpointer where I define it in a local scope, then I can only call ->Detach() or it is destroyed when scope is lost. Thanks once again cheers Bryce