|
|
Hi. I know how to convert strings to BSTR, COleVariant, and ect.. but how do you convert them back to regular ansi that the Windows API requires.
Thanks in advance.
Martin.
|
|
|
|
|
Well, refer to the ATL String Conversion Macros[^].
Basically you'd be using one of these: OLE2CA (which will make ole/bstr into ansi const char*), OLE2CW (same, but for unicode), or just OLE2CT (which converts depending on your settings for using ANSI / _UNICODE)
|
|
|
|
|
I want to learn ATL.
But when I want to insert a new ATL object using Menu Insert==>New ATL Object.A error was throwed out as "error Invoking ATL Object Wizard Component" .I can't solve the problem.
And I resetup VC++6.0 ,the error exist yet.
And I resetup the system(win2000) and VC++6.0.The error exist yet.
How can I do?
Don't look at me in that way!
|
|
|
|
|
Why does ostream_iterator not work for the second scoped code block in main below?
In VC6 you get an error something like:
"d:\program files\microsoft visual studio\vc98\include\iterator(203) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'const struct std::pair<int,int>' (or there is no acceptable conversion)"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct MyClass
{
MyClass(int f, int s)
: first(f), second(s) {}
int first;
int second;
};
ostream& operator<<(ostream& stream, const MyClass& m)
{
return stream << "First: " << m.first << ", Second: " << m.second;
}
typedef pair<int, int> MyClassPair;
ostream& operator<<(ostream& stream, const MyClassPair& m)
{
return stream << "First: " << m.first << ", Second: " << m.second;
}
int main(int argc, char* argv[])
{
{
vector<MyClass> coll;
for (int i = 1; i <= 10; i++)
{
MyClass m(i, i);
coll.push_back(m);
}
copy(coll.begin(), coll.end(),
ostream_iterator<MyClass>(cout,"\n"));
}
{
vector<MyClassPair> coll;
for (int i = 1; i <= 10; i++)
{
MyClassPair m(i, i);
coll.push_back(m);
}
copy(coll.begin(), coll.end(),
ostream_iterator<MyClassPair>(cout,"\n"));
}
return 0;
}
Kevin
|
|
|
|
|
This seems like a bug to me. Try supressing using namespace std; and prefixing with std:: as necessary to see the effect.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, that does it. This problem seems to have come up a number of times in the C++ newsgroups, though none offered this solution. This behaviour seems to occur in VC5/6 and in at least VC7 Beta 2.
Kevin
|
|
|
|
|
Optionally, try defining the second overload as
ostream& operator<<(ostream& stream, const pair<int,int>& m) If either this or the former rewriting gets a clean build, then you've hit a compiler bug.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Dear Friends,
I have one Media Player .exe and 3 .dll and one .vg2 file. I have code also to run a media player.I have to customize the product.
After executing the file first control winow opens from which can select a .vg2 file and it displays.But it displays in a particular size and I have to display it in a maximize mode as default.
So kindly help me to make the necessary changes in the code to solve the problem.
It is very urgent so kinly reply me accordingly ASAP.
Thanking you in adavnce.
Your Friend
|
|
|
|
|
with the following snippet:
<br />
struct A<br />
{<br />
BSTR bstrA;<br />
BSTR bstrB;<br />
};<br />
<br />
struct B<br />
{<br />
int countA;<br />
[size_is(countA) A *a;<br />
};<br />
<br />
__interface IService<br />
{<br />
HRESULT AllocateSomeBs([out] int *countB, [out, retval, size_is(, countB)] B **bs);<br />
};<br />
The above will compile, but the WSDL generation fails....if I eliminate the comma in the size_is attribute, the code will compile and the WSDL generation will succeed. According the documentation the difference between having a comma and not having a comma in the size_is attribute is as follows:
With a comma: the pointer is a pointer to a pointer to an array of B
W/o a comma: the pointer is a pointer to an array of pointers to B
The documentation for the soap types says that size_is works as documented for MIDL but I'm not seeing this in reality...anyone know anything more about this?
|
|
|
|
|
I think that you simply lost the * symbol before the array's counter.
HRESULT AllocateSomeBs([out] int *countB, [out, retval, size_is(, * countB)] B **bs);
With best wishes,
Vita
|
|
|
|
|
Hi all, this is kind of a tricky question, so let me give you some background on my app.
I have an SDI app with a view based on CListViewCtrl. The list is set to operate on "virtual mode", (via LVS_OWNERDATA style on creation), so it asks for it´s items text instead of storing them itself.
However, if i want it to work properly i MUST add this to the view´s parent(CMainFrame) message map:
CHAIN_MSG_MAP_MEMBER(m_view)
If i dont add this TO THE PARENT (CMainFrame), the view NEVER recives the LVN_GETDISPINFO notification!, this is because the view(wich is a superclassed listview) by default, like most common controls, sends its notifications to its parent, (CMainframe in this case).
So the question is: is there a more "proper" way of reflecting the notification messages back to the view? or is there a way to specify that the control (listview) will handle it´s messages itself? (ibe tried setting the WS_EX_NOPARENTNOTIFY style but it wont work).
Thanks!
|
|
|
|
|
The Proper Way is to reflect the notifications, not chain them. In the frame's msg map:
BEGIN_MSG_MAP(CMainFrame)
....
REFLECT_NOTIFICATIONS()
END_MSG_MAP() That makes any unhandled WM_COMMAND and WM_NOTIFY messages get sent back to the control that generated the message. Then in the list ctrl class, add two entries:
BEGIN_MSG_MAP(CYourListView)
....
REFLECTED_NOTIFY_CODE_HANLDER(LVN_GETDISPINFO, OnGetDispInfo)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP() DEFAULT_REFLECTION_HANDLER() should go at the end, and makes sure that unhandled reflected messages get sent on to DefWindowProc() . There is also a REFLECTED_NOTIFY_CODE_HANLDER_EX() macro if you are using the enhanced message map macros in atlcrack.h.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Outstanding!, the more i learn about WTL, the more i love it!
Thanks Mike!
|
|
|
|
|
I need just to have an ie control window in my dialogbox.... something like the popup who appear when you login into messenger chat....
I have a simplest win32 console application, without MFC.
I maked CreateDialog, to open a dialog box window, from a dialog resource.
In that dialog i put an dll control of Microsoft Web Browser Object, from controls.
How to connect to that object and tell him Navigate2 ?
(with mfc is very simple is automatticaly link a m_spBrowser variable....)
Adrian Bacaianu
|
|
|
|
|
Intro:
I have a simple VB application that lives in the sys tray. It basically allows me to right click and select from a list of projects I am currently working on so that I accurately keep track of what time I spend on the job and what I spend reading CodeProject.
Problem:
Whne explorer.exe is reloaded (i.e. because IE/windows explorer hung and needed to be killed) The icon for my application does not get reloaded into the systray.
How can I solve this?
TIA
|
|
|
|
|
> have a simple VB application that lives in the sys tray.
What any of this have to do with WTL/ATL/STL....
[rant start]
VB is brain dead, defective framework, designed for masses, who can not spend couple of month learning something better.
[rant end]
Anyway you need to m_mTaskbarRestart = RegisterWindowMessage(_T("TaskbarCreated"));
and when you got it recreate your icon.
Two lines in C++, but I have no clue about VB.
Brian
|
|
|
|
|
i'm using the copy method of the basic_string<tchar>. i'm a little confused about the first parameter. could someone please post a simple example of copying from one basic_string<tchar> to another?
thanks
melinda
|
|
|
|
|
std::string str="hello heaven";
char buffer[1000];
str.copy(buffer,4);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
would it work the same way if i were copying from one basic_string<TCHAR> to another basic_string<TCHAR>? in that case i'm not actually using the string.
melinda
|
|
|
|
|
Er, I do not understand completely your question. copy will work the same for basic_string<TCHAR> s, except that what it copies are TCHAR s instead of char s. copy does ont have anything to do with copying from one basic_string to another.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks...i get it now
|
|
|
|
|
Hi all,
When I compile this very simple program I get some warnings... but I don't know why? Here is this program:
int i = 0;
std::vector<std::string> str_vect1;
std::vector<std::string> str_vect2;
std::vector<std::string>::iterator it1;
std::vector<std::string>::iterator it2;
str_vect1.resize(5);
for(it1 = str_vect1.begin(), i = 0; it1 != str_vect1.end(); it1++, i++)
{
cout << "str_vect1[" << i << "] = ";
cin >> *it1;
}
str_vect2.resize(str_vect1.size());
for(it1 = str_vect1.begin(), it2 = str_vect2.begin(); it1 != str_vect1.end(); it1++, it2++)
{
*it2 = *it1;
}
for(it2 = str_vect2.begin(), i = 0; it2 != str_vect2.end(); it2++, i++)
{
cout << "str_vect2[" << i << "] = " << *it2 << endl;;
}
I don't understand these warnings...
Compiling...
DebugApp.cpp
C:\KINDT\My Projects VC++\Chameleon Project\GENERIC SELDES DRIVER\DebugApp\DebugApp.cpp(87) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,std::basic_string<char,std::char_traits<
char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const *,int>' : identifier was truncated to '255' characters in the debug
information
C:\KINDT\My Projects VC++\Chameleon Project\GENERIC SELDES DRIVER\DebugApp\DebugApp.cpp(87) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,std::basic_string<char,std::char_traits<char>,
std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > *,int>' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\vector(39) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >
>::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >
>::~vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >' : identifier was truncated to '255' characters in the debug information
Linking...
DebugApp.exe - 0 error(s), 4 warning(s)
Thanks for all who can help me...
Hello World!!!
from Raphaël
|
|
|
|
|
Don't worry about it, it's a confirmed (and harmless) bug in MSVC++ 6.0. To get rid of it, insert the following line at the beginning of your .cpp :
#pragma warning(disable:4786) Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot for your reply...
Hello World!!!
from Raphaël
|
|
|
|
|