|
George2 wrote:
copy constructor will be
called first and then copy constructor will invoke the
assignment operator
Yes. That is the way it is intended. There is only one place I have to update if I add another member variable.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
I know that the system will supply me a default copy ctor.
It copies member-wise. My question is, if I supplied my
own version of copy ctor. Must I supply the assignment
operator? Why? How can I decide the case?
regards,
George
|
|
|
|
|
George2 wrote:
if I supplied my
own version of copy ctor. Must I supply the assignment
operator?
I am not totally sure if you must, but I am sure that you absolutly should! How do you guarantee consistence, between construction and assignment when you have written only one of them?
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, jhwurmbach buddy!
George
|
|
|
|
|
NewElement::NewElement(const NewElement& rhs)
{
*this = rhs;
} This is not, IMHO, good practice. It works for sure, but you are incurring the innecesary overhead of default constructing your object prior to assignment. For small classes this could be negligible, not so if the default constructor is heavier.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, Joaquín buddy!
Hmmmm... I do not understand what you mean. But I think
you are correct.
So, can you show me an example?
regards,
George
|
|
|
|
|
You say that you would have sparate code in the copy c'tor and the assignment operator?
For me, this looks dangerous:
NewElement::NewElement(const NewElement& rhs)
: m_One(rhs.m_One), m_Two(rhs.m_Two), m_Three(rhs.m_Three)
{
}
NewElement& NewElement::operator=(const NewElement& rhs)
{
if (this != &rhs)
{
m_One=rhs.m_One;
m_Two=rhs.m_Two;
m_Three=rhs.m_Three;
}
return *this;
} If I had to insert NewElement::m_twoA, I would need to update the copy c'tor and the assignment-operator. Two places to edit for one functionality change - sounds ugly.
I'd say do optimisation only where you have proven (that is profiled) benefit. Everywhere else clarity is the way to go.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Quick question -
If I am writing a project using only the Win API,
is it possible to use classwizard in conjunction with
this project?
Currently if I try to run classwizard, it informs me that the database
does not exist and prompts me to build it - I have tried this, but
it seems to fail.
Should this be possible?
Thanks.
|
|
|
|
|
There's no help files in my project. And I want to make the help button invisible,or get rid of it.
How can I do?
Thanks.
Hi guys. I'm a very fat man. Do you like fat men?
|
|
|
|
|
in the constructor of the property page and for each property page inserted:
this->m_PropertyPageInsideThePropertySheet.m_psp.dwFlags &= ~PSP_HASHELP; and also:
this->m_psh.dwFlags &= ~PSH_HASHELP;
this should do the trick...
hope this helps...
|
|
|
|
|
See the MSDN article Q141039. It's about the Apply button but it does mention that any of the buttons can be hidden in the same fashion.
You can deactivate the Help button capability by modifying m_psh in the property sheet object as follows:
mySheet.m_psh.dwFlags &= ~(PSH_HASHELP);
|
|
|
|
|
Hello
I am porting a huge source from unix to win32, and I need to build dll from the source, is there a way to ask linker to export all funtions and classes without going into the code and put the __declspec(dllexport) to every functions and cleases? I am using VC7
psksvp
|
|
|
|
|
:(No but I do have a suggetion.
In sted of using __declspec(dllexport) use a .def file that way you will not have to modify the code. You will still have to enter all the function names in the EXPORT section.
You might also try a document generator like Doxygen, you should be able generate .html documents then (1)find the list of functions (2)strip the HTML code (3)cut and copy to .def file (4)ether add the ordinal values (foo @1) manualy or write a small program to do it for you (my personal choice).
My second choice would be to write a small program that takes a list of header files (or allows you to select a list) and parse them to generate a list of function names (or generate a .def file).
May the code gods be with you!
|
|
|
|
|
Also, there is one thing worth mentioning..
When exporting from a DLL, you should use both __declspec(dllexport) calling convention and the .def file. When you use both, you can use the DLL with run-time linking (LoadLibrary() and GetProcAddress()). If you use only __declspec, it doesn't work for some strange reason. Might be a bug, but using both makes sure.
Also, an interesting thing in exporting classes is that you can export a function from the DLL, which returns a class generated during the CRTStartup (DllMain) of the DLL. This way, you can generate COM-like objects, which are external, and for which you only need to provide the header files. When the DLL is loaded (LoadLibrary), get the address of the function returning the class address, and take it to a local pointer in your program. Then you can utilize the class within the DLL without creating a local copy.
Most interesting thing to do with this is to create classes, which generate windows and window procedures. I myself made two small DLLs, one which creates a main window, and one which provides support for left and right mouse clicks within this window. Then in the main application, I just loaded these DLLs and utilized them. Useless, but interesting
-Celorfie
|
|
|
|
|
Is there a way to send a BN_CLICKED notice to an edit box.
Thanks
|
|
|
|
|
I do not recommend it.
But one of the following should work.
SendDlgItemMessage(ID_EDITBOX,WM_COMMAND,(WPARAM)MAKELONG(ID_EDITBOX,BN_CLICKED),(LPARAM)GetDlgItem(ID_EDITBOX).GetSafeHwnd());
or
::SendDlgItemMessage(hWnd,ID_EDITBOX,WM_COMMAND,(WPARAM)MAKELONG(ID_EDITBOX,BN_CLICKED),(LPARAM)::GetDlgItem(ID_EDITBOX));
Trust in the code Luke. Yea right!
|
|
|
|
|
Check NM_DBLCLK. I came across this message a while back but I never had to use it. It's worth trying it.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi there,
Can anyone please provide some insight to the below problem?
I am calling:
const hostent* HostInfo =
::gethostbyaddr((const char*)(&binaryIp), sizeof(binaryIp), AF_INET);
binary ip is the correct local ip of a machine on our network. Instead of returning the machine's name, HostInfo->h_name takes on the "xxx.com" name of our company! Any ideas why this is happening?
Thanks!
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
My guess is that it has to do with the name resolution service order that the Win32 API uses to resolve the IP address. What appears to be happening is that gethostbyaddr() is querying DNS for the hostname and not using a local /etc/hosts file or, as a last resort, the NetBIOS name service over port 137. The DNS resolved name is a FQDN and will be composed of the hostname.domain.suffix. Actually, though, the gethostbyaddr() API has been deprecated in favor of the getnameinfo() API. Note that getnameinfo() is not capable of returning NetBIOS names, however.
Regards,
--bill
|
|
|
|
|
Thanks Bill. So am I doing something wrong? What is the correct way to get the name of a local machine given its local ip address?
I will try using getnameinfo() to see if this fixes anything...
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Actually, getnameinfo() is only supported in Windows Xp, which is no good because we need to support Windows 2000 as well
Any other ideas?
Thanks,
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
This isn't a VC++ question, but I wasn't sure where to ask it. Anyway, what are the different options available for distributing software to locked down PC's? Thanks
|
|
|
|
|
How can I accomplish this?
I've tried adding the stupid functions manually, because classwizard doesn't appear to support this with CListCtrl???
I've checked LVS_ONWERDRAWFIXED or whatever in the dialog properties and still DrawItem() isn't being called...???? I'm so confused...
Any ideas???
BTW-I don't want to use Custom Draw....
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|
|
call RedrawWindow function
|
|
|
|
|
I have the following code (with the correct header and library files included):
PlaySound("C://Windows/Song.wav", NULL, SND_LOOP); </code>
I have no errors, but it's not doing anything. It is returning false, but so it's obviously something that I'm doing code wise.
Also, I've messed with how to spell out the location of the wave by using both foward and back slashes, neither worked.
Any ideas?
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|