|
You have made my day. One of the articles referenced on that page (MS KB 280512) gave me the solution straight away. I have been working around the problem for months. I can now sleep easier at night.
I have bought you a virtual drink.
TNX
|
|
|
|
|
I am new to WTL and was wondering if I could use a status bar in my applicatin. I've noticed that some of the examples (by Ed Gadziemski and Michael Dunn) use CreateSimpleStatusBar() which is only available if i derive my main form from CFrameWindowImpl. But my application is based on Dialogs and derives from CAxDialogImpl (I'm using ActiveX). Here i cannot call CreateSimpleStatusBar() and dont have the member variable m_hWndStatusBar which gets initialized by CreateSimpleStatusBar(). How do i use CMultiPaneStatusBarCtrl here? Any pointers will be helpful. Thankx in advance.
-Tareq
|
|
|
|
|
still no reply ... so replying to myself ... i've tried to manually create the statusbar using CreateWindowEx and CStatusBarCtrl but no hope. the function succeedes but there is no statusbar visible. i've also tried to use ShowWindow on the statusbar but no hope. No errors reported. Plz help meeee.
-Tareq
|
|
|
|
|
Sometimes it's easier to use the Win32 api...
eg.
<br />
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
hSTMode = ::CreateWindowEx(0L, STATUSCLASSNAME, _T("Full Auto"),<br />
WS_CHILD, 0, 0, 0, 0, m_hWnd, (HMENU)IDC_MODE_DISPLAY,<br />
_Module.GetResourceInstance(), NULL);<br />
}<br />
where hSTMode is an HWND and m_hWnd is the parent window (eg. CWindow)
This will create the window if you have a corresponding message handler. You then need to send SB_SETPARTS to hSTMode which will fill in the window with rects and stuff. See the MSDN documentation under common controls for an example.
Ryan
|
|
|
|
|
I know there is a way in windows to use a common control that displays only the directory. Does anyone know what it is called, or any code that may show me how to open and use this functionality? I tried searching MSDN and I can't find anything.
Thanks,
Leo T. Smith
|
|
|
|
|
Are you looking for the SHBrowseForFolder function? Hope this helps.
-Tareq
|
|
|
|
|
Hi
In my ActiveX component i try to use Width and Height property ATL wizard create ones in standart way .But when i use this component in VB and invoked this property they not called.
Why???
Tanks.
|
|
|
|
|
When I use map erase in "for", it will be error,
I do not know the reason,
who can tell me details, and how to correct it?
thanks a lot!
following is code:
#pragma warning(disable:4786)
#include <iostream>
#include <string>
#include
using namespace std ;
typedef map<string, int=""> STRING2INT;
void main()
{
STRING2INT MyMap;
STRING2INT::iterator MyIterator;
MyMap["January"] = 1;
MyMap["February"] = 2;
MyMap["March"] = 3;
MyMap["April"] = 4;
MyMap["May"] = 5;
MyMap["June"] = 6;
MyMap["July"] = 7;
MyMap["August"] = 8;
MyMap["September"] = 9;
MyMap["October"] = 10;
MyMap["November"] = 11;
MyMap["December"] = 12;
for (MyIterator = MyMap.begin(); MyIterator!=MyMap.end(); MyIterator++)
{
MyMap.erase(MyIterator);
}
cout << MyMap.size() << endl;
}
|
|
|
|
|
don't delete elements from a map while iterating through it, you'll probably end up accessing pairs that are deleted.
Er zit een korstje op mijn aars.
|
|
|
|
|
When you delete an element, any iterators pointing at that element become invalid. So after calling MyMap.erase(MyIterator) you can't use MyIterator again (like in the ++ expression) unless you reset it first.
--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.
|
|
|
|
|
Just to add to the previous comments, the following
for (MyIterator = MyMap.begin(); MyIterator!=MyMap.end(); )
{
MyMap.erase(MyIterator++);
} is correct.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
... and just one line more.
typedef map< char*, int > STRING2INT;
instead
typedef map STRING2INT; // it's never going to work
Miro
|
|
|
|
|
I didn't see the declaration of STRING2INT , as the original poster forgot to tick the "Do not treat <'s as HTML tags" checkbox
Now that you have revealed the definition of STRING2INT to the world, another subtler flaw comes to light. The type
map< char*, int > does not guarantee the behavior one would assume at first sight. Even worse, it can seem to work until less expected. The problem is that what's being used as a key are pointers to chars, and pointing to equivalent contents does not imply pointer equality. Consider:
typedef map< char*, int > STRING2INT;
STRING2INT m;
m["January"]=1;
cout<<m["January"]<<endl; No guarantee is made that the first pointer in #1 is the same as that in #2. Usually, this equality happens to work because the compiler is smart enough not to duplicate literals, but the following will fail for sure
m["January"]=1;
string str="January";
cout<<m[str.c_str()]<<endl; Of course, the simple solution is to define STRING2INT as a map< string, int > . Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, char* is difficult to manipulate, but char* also is a pointer to
null terminated string - the basic C/C++ strings primitive type (well know "C" string).
A little modification of "The problem is that what's being used as a key are pointers to chars". No the key are pointers to null terminated strings.
Now let's see the code.
typedef map<string, int > STRING2INT; // Thank's Mike
m["January"]=1;
string str="January";
// cout<<m[str.c_str()]<<endl; /* You can not do that.
The compilers are not enough smart */
const char* key = str.c_str(); // init that's ok
cout<<m[ key ]<<endl; // now is correct
some more ....
m["January"]=1;
// Bytes -> 012345678901 the next (12) byte is '\0'
// ||||||||||||
char somearr[] ="MonthJanuary";
char* psomearr = &somearr[5]; // lets take the address of the fifth byte
char** ppkey = &psomearr; // let's try indirect
cout<<m[ psomearr ]<<endl; // ok
cout<<m[ (*ppkey) ]<<endl; // also ok
Of course, I agree with you the simple solution is to define STRING2INT as a map< string, int >.
Best regards,
Miro
|
|
|
|
|
miropl wrote:
const char* key = str.c_str(); // init that's ok
cout<<m[ key="" ]<<endl;="" now="" is="" correct<="" i="">
That shouldn't even compile if the type of m is map<char*,int> , since key is a const char* and not a char* (as referenced in the template).
In fact, on VS.NET 2k3 and GCC 3.2.3, the following code:
#include <map>
#include <iostream>
using namespace std;
typedef map<const char*,int> mymap_t;
int main(int argc, char* argv[]) {
mymap_t m;
m["January"]=1;
string str="January";
const char* key = str.c_str();
cout << m[key] << endl;
return 0;
}
Prints out 0 instead of 1 .
The reason why is the crux of what Joaquín was saying -- it doesn't matter what the char* is pointing to (whether it's a zero-terminated C string or a big buffer of random char crud), the key is treated as a simple char pointer, and thus takes on pointer comparison semantics when used in the map .
Here's a simpler example of how things can go wrong with char* :
#include <conio.h>
#include <map>
#include <iostream>
using namespace std;
typedef map<char*,int> mymap_t;
int _tmain(int argc, _TCHAR* argv[]) {
mymap_t m;
m["January"]=1;
char *str = strdup( "January" );
cout << m[str] << endl;
free(str);
return 0;
}
- Mike
|
|
|
|
|
By the way, if you want to make the map empty then just call clear()
|
|
|
|
|
Yu Zhiquan wrote: for (MyIterator = MyMap.begin(); MyIterator!=MyMap.end(); MyIterator++)
{
MyMap.erase(MyIterator);
}
the moment u call MyMap.erase(MyIterator), the size is reduced and begin() has changed. so in your for loop, MyIterator++ is directing u to the "3rd" element.
u should use while loop to delete by check the size, not begin till end.
from,
-= aLbert =-
|
|
|
|
|
I developed an activeX and I managed to add it to a richeditctrl but the problem is that the activeX doesn't handel its messages that I alread add a handel for them so my question first any suggested solutions and is this a general problem arises with activeX or not
thanks in advance
|
|
|
|
|
Using both together, I cant overcome some problems with locales.
I am getting a C2668 in \vc98\include\xlocnum : 'sprintf' ambiguous call to overloaded function
When I dont include the regex, all compiles just fine. I just dont get it. HEEEEEEEEEEEEEEEEELP. please.
Finally moved to Brazil
|
|
|
|
|
I use VC6 and check "Add common controls manifest" in the WTL wizard.
But then I compile my apps they have classic windows style.
Manifest doesn't work!
Then I recompile samples from this site it doesn't work. Why? Bug in the wizard? In VC? I
don't understand. Please help me!
|
|
|
|
|
What OS are you running?
Steve S
|
|
|
|
|
|
this was happening to me long time ago when I had an old SDK that didn't define RT_MANIFEST in any header file. So that's your primal suspect; try getting the latest platform SDK
|
|
|
|
|
Hi All,
I am writing an ATL/COM extension for a mapping application. All is fine except I am struggling to get field validation on Edit boxes to work.
I open up a Modal ATL dialog and the user does there thing, but when it comes to the OnOk button event my code bombs when I try to get the text from the edit boxes
<br />
BSTR field1;<br />
BSTR field2;<br />
<br />
this->GetDlgItemText(IDC_WIZEDIT1, field1); <br />
<br />
this->GetDlgItemText(IDC_WIZEDIT2, field2);<br />
EndDialog(wID);<br />
<br />
The error when I try the above is:
Application Error-
The instruction at "0x0f074b68" referenced memory at "0x0f074b68". The memory could not be "read"
Which is not a very helpful message.
In short, is there a an easy way to validate resources on an ATL dialog?
thanks for your time in advance
cheers
Bryce
|
|
|
|
|
At the risk of stating the obvious, have you tried setting the BSTR variables to NULL first?
It's eminently possible that it contains a garbage value. This causes the code to attempt to SysFreeString it first, and it's likely that is tripping the error. The eip looks about right for being somewhere in the system, rather than in "your" code.
Steve S
|
|
|
|