|
Hi
Thanks for answer.
I used retval - it works.
Slava
|
|
|
|
|
Hi guys,
Ok this is the dilemma I^m facing right now:
I`ve got this template class in which I want to have a static member variable which is shared by all objects of that class no matter what the template parameters were. So I figured I need to create a dummy class with that static parameter and use that.
The way in which to use that now is the question there are 2 options (as far as I can see).
1) I derive the template class from that dummy class
2) I put a member var of that dummy class in the template class.
eg:
class CDummy
{
static int m_nAnInteger;
};
//option nr 1
template<class TParam> class CATemplate: public TParam, public CDummy
{
...
};
//option nr 2
template<class TParam> class CATemplate: public TParam
{
CDummy theDummyObj;
...
};
In the one case I can refer to m_nAnInteger dircty in the other I have to refer to it through the object. In the one case I am dealing with multiple inheretance however and in the other not. So if anybody can tell me which would be the best solution feel free.
Greetz,
Davy
|
|
|
|
|
I'm not normally a great friend of the is_a vs. has_a terminology, but here I find it works and provides good guideance:
Is CATemplate a CDummy? No, it has a CDummy. Thus, composition (your option nr 2) is the answer.
Bernd
|
|
|
|
|
I am trying to figure out a way to create a simple toolbar for IE, or MOZILLA or both..
All I am looking for is to hyperlink to 2 different websites. I am trying to get 2 Main headings for each site, and a drop down list under each for different pages on that site, can anyone help, I am a 26 y/o NEWBEE to programming.
I am hoping to get it too look like this:
Main Topics as if this was the toolbar and drop down menus
CSRA Light Flyers Trenton Flyers
Home Home
Pictures News
News Pictures
Thanks!!
Eric Marenyi
|
|
|
|
|
Hi All,
Does anyone has any idea if ATL7.0 has introduced some better ways of handling errors in COM components ?
Regards,
ARun.
|
|
|
|
|
How do we use REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) to reflect messages in WTL. A sample for the same will be greatly appreciated. Thanks in advance for the help
|
|
|
|
|
|
How do we reflect messages using REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) in WTL. A sample will be very much appreciated.
|
|
|
|
|
Hi there,
I`m relatively new in the 'template bussiness', so I have a question about what you might consider the most obvious thing concerning templates. If so, I hope I get an answer fast...
If there is a static member variable in a template class, will there be only one such variable for each instance of the template class independent of template parameters, or will every template object with the same template parameters share a static member var? (hope I made the question clear.? )
Greetz,
Davy
|
|
|
|
|
Each instantiation generates its own static variable, i.e. your second alternative is the right one. Short example:
#include <iostream>
using namespace std;
template<typename T>
struct foo
{
static int bar;
};
template<typename T>
int foo<T>::bar=0;
int main()
{
foo<int>::bar=1;
foo<unsigned>::bar=2;
cout<<foo<int>::bar<<endl;
cout<<foo<unsigned>::bar<<endl;
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply.
Will need to keep that in mind, because I wanted a static for all objects of the template class regardless the template parameter. I will just need to create a dummy class or so...
|
|
|
|
|
The standard way to achieve this is to derive your template class from a common non-template base:
class whatever_base
{
public:
static int foo;
};
template<typename T>
class whatever:public whatever_base
{
...
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Why public inheritance for this? I would use protected inheritance.
|
|
|
|
|
Oh, yep, well maybe, I guess it depends on the usage you want to give to the common static var.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
HI All,
i would like to know how to extract the names of controls like editbox, combobox from running VB/Delphi applications.
Is it possible to get the contents (grid cell values) of the grid(Like DBGrid or MSFlexiGrid) which exists in some running applications.
i would like to know how to find out the exposed methods of that grid.
Thanks in advance
Naveen S G
|
|
|
|
|
Hi 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:
<br />
class CTargetDialog : public CAxDialogImpl<CTargetDialog>,
public CWinDataExchange<CTargetDialog>,<br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CTargetDialog><br />
{<br />
public:<br />
CTargetDialog(IApplicationPtr pApp);<br />
~CTargetDialog();<br />
<br />
enum { IDD = IDD_TARGETDIALOG };<br />
<br />
BEGIN_MSG_MAP(CTargetDialog)<br />
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)<br />
COMMAND_ID_HANDLER(IDOK, OnOK)<br />
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)<br />
COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_SELCHANGE, OnSelchangeCombo_target)<br />
COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_DROPDOWN, OnDropdownCombo_target)<br />
END_MSG_MAP()<br />
<br />
BEGIN_DDX_MAP(CTargetDialog)<br />
DDX_CONTROL(IDC_COMBO_TARGET, m_pComboBox)<br />
DDX_TEXT(IDC_COMBO_TARGET, m_szTargetLayer)<br />
END_DDX_MAP()<br />
<br />
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);<br />
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
LRESULT OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
LRESULT OnDropdownCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
HWND GetPicHandle();<br />
<br />
private:<br />
CComboBoxImpl m_pComboBox;<br />
CString m_szTargetLayer;<br />
IApplicationPtr m_ipApp;<br />
IMxApplicationPtr m_ipMxApp;<br />
IDocumentPtr m_ipDoc;<br />
IMxDocumentPtr m_ipMxDoc;<br />
IEditorPtr m_ipEditor;<br />
IMapPtr m_ipMap;<br />
};<br />
I have defined the CComboBoxImpl in my stdafx.h like
<br />
class CComboBoxImpl : public CWindowImpl<CComboBoxImpl, CComboBox><br />
{ DECLARE_EMPTY_MSG_MAP(); };<br />
So I have pretty much given up on trying to change the message_maps and the DDX stuff, as compiler gives error when I request
<br />
DoDataExhange(true);<br />
That being said and done, how do you get the value from a combo box?
I have tried the following but the itellisense definition of the object is different to what the compiler accepts. Instead of using DDX I have:
<br />
LRESULT CTargetDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
m_pComboBox.Attach(GetDlgItem(IDC_COMBO_TARGET));<br />
ATLASSERT(m_pComboBox.m_hWnd != NULL);<br />
<br />
return 1;
}<br />
<br />
LRESULT CTargetDialog::OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
CString pValueString; <br />
BSTR pBSTR<br />
int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, pBSTR);
this->m_pComboBox.GetLBText(0, pValueString);
<br />
AtlMessageBox(NULL, pValueString.AllocSysString(), _T("Selection"), MB_OK);<br />
return 0;<br />
}
Are the Dialogs meant to work in DLL the same message map way as in EXE? I know they are not in terms of the greater picture, but in terms of there own object entity.
your guidance would be greatly appreciated.
cheers
Bryce
|
|
|
|
|
|
Thanks for your help,
The compiler errors are:
For fetching the selected item in the combo box
<br />
CString pValueString;<br />
int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, pValueString);<br />
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....
<br />
DoDataExhange(true);<br />
|
|
|
|
|
The first error looks like the compiler is trying to generate a call to the GetDlgItemText() that takes a BSTR& . You probably need to add #define _WTL_USE_CSTRING before your WTL includes.
The second one is you probably forgot to inherit from CWinDataExchange<>
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Laugh it up, fuzzball.
|
|
|
|
|
Hi Mike,
Thanks fro the reply.
Here is my inheritance list for my dialog:
class CTargetDialog : public CAxDialogImpl<CTargetDialog>,<br />
public CWinDataExchange<CTargetDialog>,<br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CTargetDialog><br />
And here is is my listing for stdafx.h
<br />
#if !defined(AFX_STDAFX_H__63977A7A_D850_4BDE_A636_B409D3974963__INCLUDED_)<br />
#define AFX_STDAFX_H__63977A7A_D850_4BDE_A636_B409D3974963__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#define STRICT<br />
#ifndef _WIN32_WINNT<br />
#define _WIN32_WINNT 0x0400<br />
#endif<br />
<br />
#define _WTL_USE_CSTRING<br />
#define _ATL_APARTMENT_THREADED<br />
<br />
#include <atlbase.h><br />
#include <atlapp.h><br />
extern CAppModule _Module;<br />
#include <atlcom.h><br />
#include <atlhost.h><br />
#include <atlwin.h><br />
#include <atlctl.h><br />
<br />
#include <atlframe.h><br />
#include <atlcrack.h><br />
#include <atlmisc.h><br />
#include <atlctrls.h><br />
#include <atlctrlx.h><br />
#include <atlddx.h><br />
<br />
#include <exdisp.h><br />
#include <exdispid.h><br />
<br />
#pragma warning(push)<br />
#pragma warning(disable : 4146)<br />
#pragma warning(disable : 4192)<br />
#import "C:\arcgis\arcexe83\bin\esriCore.olb" \<br />
raw_interfaces_only, \<br />
raw_native_types, \<br />
no_namespace, \<br />
named_guids, \<br />
exclude("OLE_COLOR", "OLE_HANDLE")<br />
#pragma warning(pop)<br />
<br />
#include "C:\arcgis\arcexe83\ArcObjects Developer Kit\Kits\CATIDs\arccatids.h"<br />
<br />
<br />
#if _ATL_VER < 0x0700<br />
#undef BEGIN_MSG_MAP<br />
#define BEGIN_MSG_MAP(x) BEGIN_MSG_MAP_EX(x)<br />
#endif<br />
<br />
class CStaticImpl : public CWindowImpl<CStaticImpl, CStatic><br />
{ DECLARE_EMPTY_MSG_MAP() };<br />
<br />
class CComboBoxImpl : public CWindowImpl<CComboBoxImpl, CComboBox><br />
{ DECLARE_EMPTY_MSG_MAP(); };<br />
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
|
|
|
|
|
The 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>,
|
|
|
|
|
Ahhhh 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
<br />
<br />
#if !defined(AFX_ABOUTDLG_H__A290BA10_FE73_4A12_8FCA_FEBA7A47586B__INCLUDED_)<br />
#define AFX_ABOUTDLG_H__A290BA10_FE73_4A12_8FCA_FEBA7A47586B__INCLUDED_<br />
<br />
class CAboutDlg : public CAxDialogImpl<CAboutDlg>,<br />
public CWinDataExchange<CAboutDlg>,<br />
public CComObjectRootEx<<CComSingleThreadModel>,<br />
public CComCoClass<CAboutDlg><br />
{<br />
public:<br />
enum { IDD = IDD_ABOUTBOX };<br />
<br />
BEGIN_MSG_MAP(CAboutDlg)<br />
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)<br />
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)<br />
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)<br />
COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_SELCHANGE, OnSelchangeCombo_target)<br />
COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_DROPDOWN, OnDropdownCombo_target)<br />
END_MSG_MAP()<br />
<br />
<br />
LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& );<br />
LRESULT OnCloseCmd(WORD , WORD wID, HWND , BOOL& );<br />
LRESULT OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
LRESULT OnDropdownCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
<br />
private:<br />
CComboBoxImpl m_pComboBox;<br />
CString m_szTargetLayer;<br />
};<br />
<br />
#endif // !defined(AFX_ABOUTDLG_H__A290BA10_FE73_4A12_8FCA_FEBA7A47586B__INCLUDED_)<br />
aboutdlg.cpp
<br />
<br />
#include "stdafx.h"<br />
#include "resource.h"<br />
<br />
#include "aboutdlg.h"<br />
<br />
LRESULT CAboutDlg::OnInitDialog(UINT , WPARAM , LPARAM , BOOL& )<br />
{<br />
CenterWindow(GetParent());<br />
return TRUE;<br />
}<br />
<br />
LRESULT CAboutDlg::OnCloseCmd(WORD , WORD wID, HWND , BOOL& )<br />
{<br />
EndDialog(wID);<br />
return 0;<br />
}<br />
<br />
LRESULT CAboutDlg::OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
CString pValueString;<br />
int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, &pValueString);<br />
<br />
return 0;<br />
}<br />
LRESULT CAboutDlg::OnDropdownCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
HRESULT hr;<br />
return 0;<br />
}<br />
Then in your stdafx.h define the following
<br />
#define _WTL_USE_CSTRING<br />
#define _ATL_APARTMENT_THREADED<br />
<br />
<br />
#include <atlcom.h><br />
#include <atlhost.h><br />
#include <atlwin.h><br />
#include <atlctl.h><br />
<br />
#include <atlframe.h><br />
#include <atlcrack.h><br />
#include <atlmisc.h><br />
#include <atlctrls.h><br />
#include <atlctrlx.h><br />
#include <atldlgs.h><br />
#include <atlddx.h><br />
<br />
<br />
class CComboBoxImpl : public CWindowImpl<CComboBoxImpl, CComboBox><br />
{ DECLARE_EMPTY_MSG_MAP(); };<br />
Anyone got thoughts on why this would happen?
cheers
Bryce
|
|
|
|
|
|
I left it out deliberatly to test if I could use the GetDialogText(...) call. Which still fails.
<br />
LRESULT CAboutDlg::OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
DoDataExhange(true);
CString pValueString;<br />
int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, &pValueString);<br />
<br />
<br />
return 0;<br />
}<br />
</code<br />
<br />
The message map to test dataexchange is defined as<br />
<br />
<code><br />
BEGIN_DDX_MAP(CAboutDlg)<br />
DDX_CONTROL(IDC_COMBO_TARGET, m_pComboBox)<br />
DDX_TEXT(IDC_COMBO_TARGET, m_szTargetLayer)<br />
END_DDX_MAP()<br />
I was wondering if you had tested what I described in another post about changing the aboutdlg setting?
cheers
Bryce
|
|
|
|
|
Well, you misspelled the function - DoDataExchange.
I checked again and GetDlgItemText() is a CWindow function, so there is no overload that takes a CString obviously. Look at the code for DDX_Text in atlddx.h to see how to use it with a BSTR .
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|