|
In the background dialog, On top of the background dialog there is a CToolbarCtrl with many buttons. When click each button there to show associated dialog(all without title bar styles) embeded in the background dialog.
|
|
|
|
|
Take CArray for example, it has two member functions as below:
TYPE& GetAt(
INT_PTR nIndex
);
const TYPE& GetAt(
INT_PTR nIndex
) const;
When do a function call, does the return value type determines which one to call?
Is it a standard of C++?
system
modified on Wednesday, September 3, 2008 11:43 PM
|
|
|
|
|
That's an overloaded function, not an override.
C++ doesn't allow overloads that only differ by return
type, but it does allow overloads that differ by const.
Which one gets used depends on the context of the call.
For example, if you have a const reference/pointer to an
array and you call GetAt(), it will use the const function
overload, which wil return a const reference. Since the returned
reference is constant, you can't modify the object or call any methods
that modify the object, which preserves the const state of the array
referenced or pointed to by the original const array reference/pointer.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I have the following Code Fragment:-
SHFILEOPSTRUCT fs;<br />
::memset(&fs, 0, sizeof(SHFILEOPSTRUCT));<br />
<br />
CString From=m_sDBDir+"Global\\gf000.gni";<br />
<br />
FILE* F=fopen(From,"rb");<br />
char Buf[1024];<br />
VERIFY(fread(Buf,1,512,F));<br />
fclose(F);<br />
ASSERT(F);<br />
<br />
fs.pFrom =(LPCSTR) From;<br />
fs.pTo = "C:\\gf000.gni";
fs.wFunc = FO_COPY;<br />
<br />
<br />
UINT Result= ::SHFileOperation(&fs);
The Section <file*> is included that the Source File exists and is readible. This works perfectly and shows that all is well in the garden.
However I get ErrCode 402 :'Cannot Copy File: Cannot read from the source file or disk', even with more trivial file specs.
Anyone any idea what's wrong ?
Thanks,
Bram van Kampen
|
|
|
|
|
|
Hi,
That's excelent!! Tried it, got it in one. I had left HWND NULL (because I'm not using ANY of the User Interfaces in my App.) Anyways most Wnd Api's requiring HWND default to the topwindow if you use NULL. Not Thisone, it choked on it! The Error Message our Bill gave was of no help at all. In future I'll use this handy class.
Thanks
Bram van Kampen
|
|
|
|
|
In the OnOk() of the dialog class
I have removed
CDialog::OnOK();
so that the dialog remains
I wish to clear the contents of the edit box after the ok button is selected
but the dialog remains with the previous text entered.
How do I clear this, and also on the off chance, how do I
initialize this box with another message, at any time.
has anybody and idea?
Thanks Simon
|
|
|
|
|
Did you call 'UpdateData(FALSE) after you cleared the CString that holds the Edit Control's value?
Regards
Bram van Kampen
|
|
|
|
|
That seemed to have done the trick thanks
|
|
|
|
|
is there an x64 version of HTMLHELP.LIB ?
i'm trying to migrate a project to x64 and i'm getting an unresolved external on HtemlHelpA.
::HtmlHelpA(NULL, path, HH_DISPLAY_TOPIC, 0);
the function is defined in htmlhelp.h, but it doesn't seem to be in the .LIB .
|
|
|
|
|
Isn't this a repost?
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
|
I am working on a StringPool class. I'm trying to find the fastest way to look up a wchar_t* in an associative container. The current way I do this is to hash the string, and look up the hash value in the container. If it's not there, then add a new entry for it.
the code looks something like this:
size_t StringPool::find( const wchar_t* str, size_t length )
{
size_t result = NoEntry;
size_t hashID = hash(str,length);
StringMapRangeT found = stringMap_.equal_range( hashID );
StringMapIter current = found.first;
size_t rangeCount = 0;
while ( current != found.second ) {
rangeCount ++;
++current;
}
current = found.first;
if ( rangeCount == 1 ) {
size_t idx = current->second;
if ( idx < stringEntries_.size() ) {
const StrEntry& entry = stringEntries_[idx];
if ( entry.length == length ) {
result = idx;
}
}
}
else {
while ( current != found.second ) {
size_t idx = current->second;
if ( idx < stringEntries_.size() ) {
const StrEntry& entry = stringEntries_[idx];
if ( entry.length == length ) {
if ( 0 == ::wmemcmp( entry.str, str, length ) ) {
result = idx;
break;
}
}
}
++current ;
}
}
return result;
}
where StrEntry is just a struct that holds info about a string instance, like the string pointer, the length, etc.
stringMap_ is a multimap defined like so: std::multimap<size_t,size_t>
The multimap is the slowest (as far as I can tell) element here. Is there a better container to use? This is particularly true when a new string is added, and I first see if it exists or not (which is where the above code is called), and if not, then the hash id is inserted into the stringMap_. The insert is (not surprisingly) kind of expensive, so I'm wondering if there's a better approach or container to use.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Sorry, I didn't look in detail at your code, but maybe a Trie[^] structure is what you need here.
|
|
|
|
|
I'm struggling with some USB devices that work like a serial devices.
The driver used is UsbSer.sys.
So I register for device notifications and in OnDeviceChange() I get the "filename" for the device so I can open it with ::CreateFile() .
I now need a way to get the vendor and product ids from the device, preferably by using ::DeviceIoControl() or the Setup API.
Actually it's a composite device so it registers as a few different devices.
This means I can access it using different drivers, using different "filenames", but it should be used as a serial device. Even if I got the vendor id by using another device class I haven't found a way to map that device to the serial driver for the same device.
Is there some I/O control code or a neat method using the setup API I've overlooked, I would be most grateful to be pointed in the right direction.
Previously the "filename" has been parsed since it seemed to be built using the vendor and product ids, but this method breaks when the device presents itself as a composite device. So I assume using the registry is not the way to do it.
Ideas anyone?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hey all,
I've got this really annoying problem I just can't solve - I'm trying to print the elements of my array of strings, but I can't make it, I've tried several different ways.
Here's my code, which won't compile:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
string a[]={"a", "b", "c", "d", "e"};
cout << a[3];
return 0;
}</iostream>
I've been googling around for quite a while now and this code looks so right to me.
And one other thing; how can i create a string from several elements of this array?
Thx
/Joplinazz
|
|
|
|
|
why doesn't it compile ?
any compiler/linker errors ?
|
|
|
|
|
Well, here's the huge description of the error I'm getting:
c:\andreas\programmering\cpp\arraytesting\arraytesting\arraytesting.cpp(11) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
c:\program\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits xmlns:std="#unknown"><char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(785): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(909): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(916): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(923): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(930): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits><char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(170): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(176): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(183): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(190): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(210): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(243): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(263): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(288): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(308): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(328): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(349): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(369): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(390): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(410): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(430): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(450): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program\microsoft visual studio 9.0\vc\include\ostream(470): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
while trying to match the argument list '(std::ostream, std::string)'
Build log was saved at "file://c:\Andreas\Programmering\Cpp\ArrayTesting\ArrayTesting\Debug\BuildLog.htm"
ArrayTesting - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
</char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></std::char_traits></char></char></char></char>
I'm using Visual C++ 2008.
/Joplinazz
|
|
|
|
|
Damn, only few errors would have suffice !!!
moreover, your lines are too long to fix the <pre> tag...
did you correctly included the header needed ?
#include <string>
#include <iostream>
also, try to use std::string::c_str() to print the string out:
cout << (a[3]).c_str();
|
|
|
|
|
Haha, yeah you're right..
Thanks a lot for your help, the headers were the problem.
I didn't use #include <string> - Strange error(to me, hehe).
/Joplinazz
|
|
|
|
|
Well, looks good to me.
I suppose you have included iostream. It doesn't show since you haven't used the small < and > wonders below the text input frame when you posted your message.
Joplinazz wrote: And one other thing; how can i create a string from several elements of this array?
Try this:
#include <sstream>
int main()
{
std::string Strings[] = { "a", "b", "c" };
std::ostringstream stm;
stm << Strings[2] << Strings[0] << Strings[1] << std::endl;
std::cout << stm.str().c_str();
} You'll get "cab" written to cout.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks Roger, I managed to make it work this way:
myString = a[0] + a[1];
/Joplinazz
|
|
|
|
|
How do I create a UI thread capable of showing CDialog? I'm currently using AfxBeginThread for my working thread but also want to be able to display things like CDialog.DoModal from inside the worker thread. Do I have to make it a UI thread? How do I go about it?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|