|
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!
|
|
|
|
|
Will,
There's nothing technically wrong with your code. MyClass contains a public vector vPtrOC, which is a vector or pointers to otherClass objects. These objects in turn contain a public vector vOC_str each.
Nothing wrong here; myClass can access all otherClass items pointed to be the vPtrOC vector, and for each of these access the darn string vector.
I suspect there is an error in your approach; obviously you suffer from some problem, but neither problem nor reason is evendent in your code snippet.
Besides, you might want to consider your programming style. Public data members, vectors of pointers to objects under (presumably) foreign memory management, unconviencing naming policy, that is all the stuff progammers' hell is made from - including your own, if you revisit that code in a few months.
I recommend Bruce Eckel.
Bernd
|
|
|
|
|
Thanks for replying.
Sometimes it is difficult to pose a question, as it is to answer it, and perhaps I may not have written the question in as clear a manner for others to understand.
I was not implying that the sample code the question showed, is illegal code. It is not illegal code, therefore I know I am able (by the rules of C++) to access the vector of strings from MyClass. The question sought to discern an optimal way someone might go about doing it. In all honesty, I have been able to access the vector in question; it's just that my way seemed more awkward than optimal, and wanted to obtain a more efficient style.
I think I'll settle on the 'for_each()' algorithm.
William
Fortes in fide et opere!
|
|
|
|
|
Will,
Don't settle for the for_each algorithm. Settle for Bruce Eckel's "Thinking in C++".
It is the most reasonable book on C++ programming I ever came across (and there were many), and he doesn't waste time explaining the zeroes and the ones. And: it's free (mind you reading 1500 pages on the screen can be hard work).
Bernd
|
|
|
|
|
Let me see if I have this right: I asked an STL question, and the answer you are offering me, is for me to go read a book (or at least those portions of the book that pertain to my question).
Other than me having acknowledged that I have already found a way for doing what I wanted (albeit an awkward way), the emphasis behind the question was more on finding a better way of accomplishing it.
If every time I want to check to see if somebody may have found a better way of doing something (realizing I have to contend with certain limitations in life: "time" being one of them, and the fact I will not know everything in this world ), that I would be better off to go read portions of a book (or several books), then why ask questions in the first place? Why ask ANY question, any at all? Might as well, we keep reading portions of a whole bunch of books every time we have a question, and remove the alternative of interfacing with peers and a place like CodeProject!!!
The whole reason why a place like CodeProject exist, is for developers to have a meeting place where they can gather and meet with their peers (in cyber space) to bring and trade solutions, ideas, tips, questions and everything else relating to technical matters (and some).
If the CodeProject Community were to (individually) go off reading portions of books every time someone needed to find out something, there wouldn't be a need for a place like CodeProject!!
William
Fortes in fide et opere!
|
|
|
|
|
Your response is completely out of order. I certainly regret having upset you so much, though.
I did not misunderstand your question. My answer is "read this book" - Bruce collected a lot of useful advise that does relate to your question, and I see no reason why I should re-type his 1500 well-written pages here.
You don't seem to cope with frank advise, and mistake it for insult. If that's the way you read it, then so be it.
So, returning to your question:
a) you should not expose public data members
b) you should implement suitable verbs where possible, and accessors/mutators where needed
c) you should re-consider your naming policy
d) you should re-consider your referencing stratey (consider using references or smart pointers)
These are a lot of architectural weaknesses for an 8-liner, don't you think?
I think I might have mentioned a good book that details this much better than I could...
Bernd <grin>
|
|
|
|
|
First of all, I am not upset! I took your response and analyzed it for what it portrayed.
I am well aware that certain data should NOT be public. It makes good sense to me (for simplicity and ease of development) to make data public at first, and then when the program is working well, to go back and clean things up before releasing it to production. (It's my style, and it works well for me. Getting a program to work first is more important to me, followed by cleaning up and complying with conventions.)
"for_each()" is an STL algorithm. I had nothing to do with it being that name, and as far as having a "naming policy" goes, that is rather subjective, though I try to make mine as descriptive as possible (for what I'm doing).
With regards to whether a smart pointer is more suitable for what I'm doing, I believe it's a judgement call on my side. I am not overly eager to show people how things can be done by using esoteric tools as smart pointers. There is a time and a place for everything, and smart pointers will be the tool of the day when the time and the place call for it. Right now for what I'm doing, I believe it can be accomplished without the need for smart pointers.
On the matter of using "references", I mostly use them for passing data as parameters. Other than that, I prefer to deal with pointers. (Again it's my style, and may you live happily with yours.)
For a miniscule piece of code that was posted, I am amazed that you have taken to reading so much from it, with total absence to the remaining portion of the program relative to the tiny role this piece plays.
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
It makes good sense to me (for simplicity and ease of development) to make data public at first, and then when the program is working well, to go back and clean things up before releasing it to production. (It's my style, and it works well for me.
Biiiig mistake. This works while you have are studying. When you do programming for a living - the moment it runs, it will not be changed anymore. There are deadlines to meet, there are testing issues involved. How many bugs do you introduce when you "clean up" your code?
Do it right from the beginning. It saves your job. Believe me. And better get familiar to it before your boss asks you to do it.
Finally moved to Brazil
|
|
|
|
|