|
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
|
|
|
|
|
Thankyou ohhhhh so much. Works now!
cheers
Bryce
|
|
|
|
|
I write an ATL control to implement the OnUnLoad event of the html.
I set the OnUnload handle through IHTMLBodyElement. But it did not work.
Source code as follow:
//definition of IDHTMLTest2 in IDL
interface IDHTMLTest2 : IDispatch
{
[id(1), helpstring("method ShowMsg")] HRESULT ShowMsg();
};
//selection of the source code
CComPtr<iolecontainer>spIE;
m_spClientSite->GetContainer(&spIE);
CComQIPtr<ihtmldocument2, &iid_ihtmldocument2="">spDoc(spIE);
if (spDoc){
CComPtr<ihtmlelement> spElement;
spDoc->get_body(&spElement);
CComQIPtr<ihtmlbodyelement> spBody(spElement);
IDispatch* pShowMsg;
QueryInterface(IID_IDHTMLTest2,(void**)&pShowMsg);
VARIANT v;
v.vt=VT_DISPATCH;
v.pdispVal=pShowMsg;
//this event can't be invoke ,when close the ie-window
spBody->put_onunload(v);
//this invoke works well
((IDHTMLTest2*)pShowMsg)->ShowMsg();
//code below can works well
// v.vt=VT_BSTR;
// v.bstrVal = L"#DA70D6";
// spBody->put_bgColor(v);
}
Thank you for your advanced help.
Regards.
|
|
|
|
|
In my application, I'm using template controls to change the font and colors of any of my MFC controls.
As I need some messages, I have a message map like that.
BEGIN_TEMPLATE_MESSAGE_MAP(class BASE_TYPE, CColorCtrl<base_type>, BASE_TYPE)
//BEGIN_MESSAGE_MAP(class BASE_TYPE, CColorCtrl<base_type>, BASE_TYPE)
//{{AFX_MSG_MAP(CColorCtrl)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_CTLCOLOR()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_TEMPLATE_MESSAGE_MAP()
The BEGIN_TEMPLATE_MESSAGE_MAP macro is defined here.
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
template <thetemplargs> \
const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \
{ return &baseClass::messageMap; } \
template <thetemplargs> \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
template <thetemplargs> \
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
{ &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \
template <thetemplargs> \
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
{ \
My pb is I get an error message saying that "_GetBaseMessageMap" is not a member of CColorCtrl<base_type>.
The code was working with Visual Studio 6.0, but does no longer work with Visual Studio .Net
How can I port it to .Net?
|
|
|
|
|
Hi, did you solve the problem with _GetBaseMessageMap in VC7? I ran into the same.
|
|
|
|
|
Hi guys,
I got the following problem.
I need a list control and an edit control to have some common behaviour. More specific when a certain predefined message is send to an object of this list or edit control they both have to have the same functionality, (activate a device)...
Because I don^t want duplicity and write a class with the special behaviour for the edit control and another for the list control I thought about using a template which is derived from the template class parameter. I don^t know if this is possible however or if there are better ways to solve it
So as a first thought I figured something in the likes:
template<class CWndCtrl> class CStartDeviceCtrl: public CWndCtrl
{ ... };
The objects I need would then be
eg:
CStartDeviceCtrl<cedit> m_edtControl;
Lots of you probably immediatly see the errors in this statement. I only saw that it didn^t compile. Is there a way to accomplish this, if so please give me a hint, or the outright solution .
Thanks for any help,
Davy
|
|
|
|
|
Concerning the above statement
those damn pointy brackets. Declaring an object of template class would be like:
CStartDeviceCtrl <CEdit> m_edtControl;
Still that doesn^t work offcourse, the template doesnt compile,
Anybody know how to fix it, or another way to get similar result.
Deriving a template from one of the template class parameters is allowed or possible????
|
|
|
|
|
Okay guys,
Found the solution to my problem. had a typo somewhere in my code..
It seems to work fine now...
Question related to this though:
I can^t declare a messagemap for the template class as I would do in a normal class. Is it a problem if don^t declare the messagemap( for normal classDECLARE_MESSAGE_MAP() in header and BEGIN_MESSAGE_MAP in implementation file). Anyway I capture the desired messages in the Pretranslate ...
Greetz,
Davy
|
|
|
|
|
I'm trying to get Drag and Drop to work with window less ActiveX controls. I've managed to get it to work with windowed ones, so I don't think I have any problems with the drag and drop protocols.
When I make the target control window less, the GetDropTarget method is never called! Hence, the drop site is never registered, and thus all I'll get is the "No drop site" cursor. Is there anything special I need to do in order to make ATL call this method for me?
--
Must I be the meat in an imbecill sandwich?
|
|
|
|
|
Hello
I´m programming a toolband object. I have a reflector window and a Toolbar ( I derived a class from CWindowWithReflector< MyClass, CtoolBarCtrl> with the ToolBar class also superclassed) and when i step into the code they are created in the right parent-child relationship. That is, the toolbar as a child of the reflector, and the reflector as a child of the IE rebar control. But when the band object is on the browser both the toolbar and the reflector are children of the rebar!!! And the toolbar is not assigned to any band...
Any idea of what´s happening or how can i trace where the change in the
relationship is occuring?
I tried with calls to SetParent all over the code but it didn´t work either.
Thanks
Gabriel
Old C programmers never die. They just cast into void
|
|
|
|
|
Here is the situation:
class MyClass
{
public:
vector<otherClass*> vPtrOC;
};
====================
class otherClass
{
public:
vector<string> *vOC_str;
}; How do I get to read the string vector in 'otherClass' from the vector in MyClass?
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
Make it public so other classes can access it, or provide an accessor function such as GetStringVector() that returns a reference to the vector.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
Thanks for replying.
That was my oversight not to have shown the vectors were already 'public'.
In any case, what month and year of the MSDN library might you find information on 'GetStringVector()'?
William
Fortes in fide et opere!
|
|
|
|
|