|
|
[EDIT2] Nevermind, I just discovered Updatelayout() and realized how stupid my question was
Hello everyone, I'm a real newbie to programing both WTL and MFC so bare with me.
I'm trying to subclass a CButton to a CWindowContainer in a framewindow derived from
CMDIChildWindowImpl. But for some reason it won't show up. Am I trying to do something that isn't possible?
Thanks in advance,
Skandal
[EDIT] I don't know if it's obvious from my post that I'm using WTL.
|
|
|
|
|
Hi,
I am facing a peculiar problem with usage of maps in the following code
#include <iostream>
#include
#include <deque>
#include <string>
using namespace std;
typedef const string& CIR;
typedef enum { IEArgString, IEArgNumber, IEArgSpecial } IEArgType;
class IEArg {
public:
//* Element name and value and embedded datatype.
string name;
string value;
IEArgType dataType;
//* Default constructor given name and value.
IEArg(CIR n, CIR v) : name(n), value(v) { dataType = IEArgString; }
IEArg(CIR n, CIR v, IEArgType t) : name(n), value(v), dataType(t) { }
};
typedef map < IEArg,string > IEArgList;
// typedef map < string,IEArg > IEArgList;
inline CIR key(const IEArg& iea) { return iea.name; }
typedef deque < IEArg > IEOArgList;
main()
{
int days=10;
IEArgList al;
string where;
string nam="1235";
string val="12";
// Maps and multimaps deal with pairs
typedef pair < IEArg,string > entry;
// typedef pair < string,IEArg > entry;
entry p1(IEArg("1234","A"),"Time");
// entry p1("Time",IEArg("1234","A"));
entry p2(IEArg("4567","B"),"Transaction");
// entry p2("Transaction",IEArg("4567","B"));
entry p3(IEArg("5678","C"),"ResultCode");
// entry p3("ResultCode",IEArg("5678","C"));
// Insert values into the phonebook
al.insert(p1);
al.insert(p2);
al.insert(p3);
where = string("Userid='") + "SASI" + string("'");
cout<<"Value of where is "<<where<<endl;
if="" (days=""> 0) {
where += string(" AND ");
where += string("Time >= (CURRENT TIMESTAMP - ");
where += string(days);
where += string(" DAY)");
}
IEArgList::iterator iter;
for (iter = al.begin(); iter != al.end(); iter++) {
cout<<"values are:"<<(*iter).first.name<<":"<<(*iter).first.value<<":"<<(*iter).second<
|
|
|
|
|
If you had spent 2 minutes on reading the documentation for std::map , you would have seen that either you must provide a less than operator (operator< ) for IEArg , or provide a binary functor/predicate type as the third template parameter to std::map which knows how to compare two IEArg s.
--
Booohoo!
|
|
|
|
|
Honestly,i didnt get what you said as i am relatively new to STL. why do we need a less than operator.But then even with out it,it worked if the order of passed arguments is reverse(as in bold).Infact with the current code its failing in insert function.
Can you give a bit more clarification on this(with specific to code)?
Thanks
Sasi
|
|
|
|
|
std::string already has an operator< .
Using a map implies you want the collection to be ordered, in which case you have to provide an ordering criterion. If you don't want the collection ordered use a std::vector or other container.
What is the software supposed to do?
Paul
|
|
|
|
|
Infact i am trying to migrate the application using IBM open classes to standard c++/STL. Originally its written using IKeySet and i changed it to map as recommended.
The interesting thing with this peice of code is the way its working with reversal of argumenst for map.i am not able to compiel as its failing in insert. Please suggest me a way out!
|
|
|
|
|
Your question has been answered twice now.
Paul
|
|
|
|
|
Thanks a lot both of you guys!!
I overloaded the < operator and now i am able to compile it and its working!!
But i have anotehr small question to you.Is there a provision to pass only IEArg(key) by leaving string(value) to the insert function. If its the case,will it take any default value?? I asked this question as IKeySet's add method has a provision like that
|
|
|
|
|
is there any autodeletion of classes in WTL?
|
|
|
|
|
Asking such questions, followed by such conditional statements, kind of sucks.
--
Booohoo!
|
|
|
|
|
it was a question. unless you have the answer, dont post a follow-up.
thanks in advance,
yours sincerely Martin.
Bwaahaa.
|
|
|
|
|
Yo, Mr Retard Of The Year! If you had 2 working brain cells, you could lookup the answer in under 2 minutes, instead of having us deal with your attitude problems.
Furthermore, most of reading this forum aren't linux developers. That means you won't see us running to your rescue when you start dissing the technology. We'll just frown.
Now, act less like a retard and lookup OnFinalMessage() and utilize your knowledge in C++ and add auto deletion yourself.
--
Booohoo!
|
|
|
|
|
Jörgen Sigvardsson wrote:
Yo, Mr Retard Of The Year!
thanks for the award.
Jörgen Sigvardsson wrote:
If you had 2 working brain cells, you could lookup the answer in under 2 minutes, instead of having us deal with your attitude problems.
If i could have, i would have.
Jörgen Sigvardsson wrote:
Furthermore, most of reading this forum aren't linux developers.
This is a WTL question in the WTL part of the forum.
Jörgen Sigvardsson wrote:
Now, act less like a retard and lookup OnFinalMessage() and utilize your knowledge in C++ and add auto deletion yourself.
I don't want to mess around with the WTL headers.
|
|
|
|
|
If you want autodeletion of WTL common control wrappers (CButton et al), here's some code which will do what you want:
template <typename T>
class CSelfDeleteWindow : public CWindowImpl<CSelfDeleteWindow, T> {
typedef CSelfDeleteWindow<T> ThisClass;
public:
DECLARE_WND_SUPERCLASS(NULL, T::GetWndClassName())
BEGIN_MSG_MAP(ThisClass)
END_MSG_MAP()
CSelfDeleteWindow(T& wnd) {
ATLVERIFY(SubclassWindow(wnd));
wnd.Detach();
}
void OnFinalMessage(HWND hWnd) {
delete this;
}
}; Then use it like this:
CButton btn;
btn.Create(*this, CRect(0, 0, 100, 100), _T("Yo yo"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON);
new CSelfDeleteWindow<CButton>(btn); As you can see, no control data can be in the control which you are wrapping, since the original object is detached inside the constructor of CSelfDeleteWindow. This doesn't matter much in the common control case as you only get opaque handles to them anyway - nothing is lost.
In the case of non common control classes as defined in atlctrlx.h , all you need to do is add your own thin wrapper class. If you look at CBitmapButton , you'll see that it is only a very thin wrapper around CBitmapButtonImpl . In this case, provide your own CBitmapButton class, which overrides OnFinalMessage(HWND) and deletes this .
For everything else (stuff that you've written with the use of CWindowImpl somewhere in your inheritance hierarchy), you just have to override OnFinalMessage(HWND) and delete this .
--
Booohoo!
|
|
|
|
|
Jörgen Sigvardsson wrote:
For everything else (stuff that you've written with the use of CWindowImpl somewhere in your inheritance hierarchy), you just have to override OnFinalMessage(HWND) and delete this.
<br />
typedef CFrameWindowImpl<NoteWindow, ATL::CWindow, CMyWindowTraits> CMyFrameWindow;<br />
<br />
class NoteWindow : public CMyFrameWindow, <br />
publicCUpdateUI<NoteWindow>,<br />
public CMessageFilter, <br />
public CIdleHandler
that is my class inheritance. OnFinalMessage() causes an assert in WTL. that is the problem and it is by design, i need a way around it or i can't use WTL since it would cause memory leaks. these are supposed to be windows with you frequently open many of and close, and i don't want every object to be left in memory when the window is closed.
|
|
|
|
|
I assume you are using ATL3 (VC6). Have a look at this[^]. Basically you need to write your own window procedure to work around a bug in ATL3.
If you're using ATL7 there's something else going on which I'm unaware of. I successfully deleted this myself not too long ago.
--
Booohoo!
|
|
|
|
|
|
Dear All,
The sizeof keyword gives the amount of storage, in bytes, associated with a variable or a type.
Can any body suggest how to make our own function that operates like sizeof and gives the amount of storage in bytes.
Regards,
Rohit
|
|
|
|
|
|
What's wrong with:
template <typename T> size_t Sizeof() {
return sizeof T;
} For completeness I'd add
template <typename T> struct size_of : public std::generator<size_t> {
size_t operator()() {
return sizeof T;
}
}; and/or
template <typename T> struct size_of : public std::unary_function<size_t, T> {
size_t operator()(const T& v) {
return sizeof v;
}
};
--
Booohoo!
|
|
|
|
|
|
Hello All.
I'm have the next task:
I'm must to write an ActiveX component using C++ ATL.
This component must using SOAP client for working with WebService writed on C#.
For work with WebService from my component I must to use ASP.NET page SessionId.
This ID must be set as current SessionId(HINTERNET) handler for SOAP client.
But. C# SessionId it is string type. How I may convert C# SessionId to HINTERNET for using.
Thanks.
P.S. Sorry for my English.
|
|
|
|
|
Hi Dear...
I struck in a problem & I know you can help me..
I've a pro-merchant account in amazon..& I want to upload Inventory to amazon.. but getting problem..File Error..even from site upload...
Can you send me Execl file you used for that uploading...
+ if possible some coding snippet of uploading invenorty. I want to upload through coding.. send me at:
sumit_kapoor1980@hotmail.com
or chat with me at hotmail account or yahoo: sumit_kapoor1980@yahoo.com
I hope you will help me..
Thanks
Have a Nice Life..
Sumit Kapoor.
---Sumit Kapoor---
|
|
|
|
|
Is it just me, or is anyone else getting irritated by this...
Steve S
Developer for hire
|
|
|
|