|
Good cop/Bad Cop[^]
Who's which, I don't know
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi,
I have a custom develpoed ListControl which have combobox in it. I wrote the code to notify the ListControl about the SelectionChange in ComboBox by writing a Windows User Defined Message.
void CComboBoxExt::OnSelChangeCombo()
{
....
GetParent()->SendMessage(UWM_NOTIFYSELCHANGE,nRow,nCol);
}
Now in the Parent Control ( here ListControl ) I want the ListControl to send the message LVN_ITEMCHANGED which is the message sent by thewindows framework when an item in the ListControl is changed, so the end user doent need to handle a seperate my own created message.
ON_MESSAGE(UWM_NOTIFYSELCHANGE,OnChildSelNotify)
void CListCtrlEx::OnChildSelNotify(int nRow,int nCol)
{
GetParent()->(LVN_ITEMCHANGED,);
}
My query is which structure should I send as the paarmeter ? The Handler function for LVN_ITEMCHANGED takes pointer to NMRHDRSTRUCTURE. Any help will be appreciated.
Thanks
Vikas
With Reagards
Vikas
|
|
|
|
|
char* t1 = "C:\\a.txt";
char* t2 = "C:\\b.txt";
char* t3 = "c:\\c.txt";
(VC++6.0)please guide I copy content of 2 a and b to c ???. thanks very much
I coded ERROR. open binary ==> it will read \r\n ==>error
e.g:
file a.txt
ABCDED
file b.txt
DDDDDDDDD
file c.txt. ==>>
ABCDED
DDDDDDDDD
content coded
bool copyFile (const char SRC[], const char INPUT2[], const char DEST[])
{
std::ifstream src; // the source file
std::ifstream input2;
std::ofstream dest; // the destination file
src.open (SRC, std::ios::binary); // open in binary to prevent jargon at the end of the buffer
input2.open(INPUT2, std::ios::binary);
dest.open (DEST);//, std::ios::binary); // same again, binary
if (!src.is_open() || !dest.is_open())
return false; // could not be copied
dest << src.rdbuf (); // copy the content
dest << input2.rdbuf();
dest.close (); // close destination file
src.close (); // close source file
return true; // file copied successfully
}
int main(int argc, char* argv[])
{
if (!copyFile ("C:\\n\\po7.txt", "C:\\n\\po8.txt", "C:\\npo8888.txt"))
std::cout << "File could not be copied successfully";
else
std::cout << "File copied successfully!";
std::cin.get (); // pause for input
return 0;
}
|
|
|
|
|
Not quite sure what your question is.... I've tried your code, and it does indeed copy the contents of a.txt and b.txt to c.txt
If I have \r\n in the input file, it is copied. If I do not have it, it's not copied. The code functions as it seems it should. What were you expecting, may I ask?
Also, have you tried looking at the text files with a hex-editor? Some text editors automatically insert \r\n at the end of the file when you save it, even if you didn't want them there. E.g Code::Blocks editor.
Also, if you put the line
using namespace std;
up in the top of your code somewhere, you can avoid having to type std:: all over the place.
Here's the code I tried.
#include <iostream>
#include <fstream>
using namespace std;
bool copyFile (const char SRC[], const char INPUT2[], const char DEST[])
{
ifstream src;
ifstream input2;
ofstream dest;
src.open (SRC, ios::binary);
input2.open(INPUT2, ios::binary);
dest.open (DEST);
if (!src.is_open() || !dest.is_open())
return false;
dest << src.rdbuf ();
dest << input2.rdbuf();
dest.close ();
src.close ();
return true;
}
int main(int argc, char* argv[])
{
if (!copyFile ("a.txt", "b.txt", "c.txt"))
cout << "File could not be copied successfully";
else
cout << "File copied successfully!";
cin.get ();
return 0;
}
|
|
|
|
|
Hi
How can i convert
const std::string& sMyString
to a CString ?
Can anyone help
thanks
Simon
|
|
|
|
|
what about reading the docs first ?
did you see the method std::string::c_str() ?
std::string s = "hello";
CString str = s.c_str();
|
|
|
|
|
Provided UNICODE is not defined...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
that's right.
otherwise, the following should do it :
CString str = CA2T(s.c_str());
|
|
|
|
|
Or simply use std::tstring[^], then it does not matter if UNICODE is defined or not.
|
|
|
|
|
I didn't know the std:: namespace had implemented such a container...
or is it MS that voluntarily pushed themselves into the std namespace (which is normally reserved to the C++ standard only) with such ?
(BTW, i don't have a compiler now, and lazy to search for more myself, so, just curious, how is it defined ? i'd bet for namespace std { typedef basic_string<TCHAR> tstring; } ... what it is actually ?)
|
|
|
|
|
toxcct wrote: Email
Follow the link and you will see.
|
|
|
|
|
don't mind for the mail, I just understood.
so YOU are pushing code into std, ha ?! lol
well, the coding looks clean enough. it's ok for this time. you can pass your way
|
|
|
|
|
If you have question about other converts see these link: here[^] and here[^].
|
|
|
|
|
Hello,
I am havin a problem with including file.
I made one file where I put all the file needed by other classes.
includes.h
#ifndef MY_CLASS1
#define MY_CLASS1
#include "myclass1.h"
#endif
#ifndef MY_CLASS2
#define MY_CLASS2
#include "myclass2.h"
#endif
...
and in my cpp file I just write #include "includes.h".
The problem comes up when some class inherit from other. I get the error that the identifier of some class is unknown, or that the class is redefined.
Another question: Is it possible to have as member of base class an object of a class inherited from that base class?
Thank you for your replys, Tomas
|
|
|
|
|
Why don't you use only once the include guards in your file ?
#ifndef _INCLUDES_H_
#define _INCLUDES_H_
#include "MyClass1.h"
#include "MyClass2.h"
Of course, you need to have include guards in the specific header files also.
Tomas(cz) wrote: Is it possible to have as member of base class an object of a class inherited from that base class?
No, unless it is a pointer to the object (and you use a forward declaration of the class).
|
|
|
|
|
If I were you I'd stick to 1 header per class and include what you need where you need it. trying to include everything through 1 header is never really going to work.
Tomas(cz) wrote: Is it possible to have as member of base class an object of a class inherited from that base class?
No, many people would say that's what pointers are for (except the Java Bunnies) Just add a base class pointer as a member of your base class and then later you can use it to point to instances of derived classes, how cool is that
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
I want that the left bottom be (0,0), and y increases upward.
Here are two ways, why the 1st not work?
1
Matrix matrix(1,0,0,-1,0,0);
g.SetTransform(&matrix);
g.TranslateTransform(0.f,REAL(drawing_rect.Height));
2
Matrix matrix(1,0,0,-1,0,drawing_rect.Height)
g.SetTransform(&matrix);
system
|
|
|
|
|
I'm sorry if this is a stupid question but my C knowledge is VERY small - almost zero!
I'm creating a C# wrapper around some C functions and in the header file there is
typedef long long int Samples; I get the typedef idea, but why more than one type-declaration?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Because in C, long long int is a type (64 bits integer). See here[^].
|
|
|
|
|
Ah, now I get it, long int in C == int in C#, long long int in C == long in C#. Thanks
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I suspect you'll find that it's defining a 64 bit integer - Ie reeeeeeeally long.
Try doing sizeof(Samples) - or whatever the C# equivalent it.
I've just tried it in VC++6, and get the following error:
error C2632: 'long' followed by 'long' is illegal
Anyone want to try it in a later compiler?
Iain.
|
|
|
|
|
It is C only, check my previous answer.
|
|
|
|
|
VC6 doesn't do long long but later e.g. VS2005 MS compilers do. You can use __int64 though even on VC6 which is equivalent.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Hi,
How to convert XML, formatted with XSLT, to PDF ?
Any information would be highly appreciated.
Regards,
Paresh.
|
|
|
|