|
yeah I know, but I was looking for string, not CString.
but, I don't quite understand the difference between the two.
I know that CString is microsoft's string class, and it has more functionality, but what are the disadvantages of CString comparing to string?
|
|
|
|
|
|
i've checked the string class, and it also contains a replace member function, so essentially you can do the same thing that alok said for the CString class.
anyway here's more definitions for the string class: http://www.cppreference.com/cppstring/[^]
|
|
|
|
|
ng kok chuan wrote:
anyway here's more definitions for the string class: http://www.cppreference.com/cppstring/[^]
Looks Good Thanks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hey need some help here
here's my code (partial)
class CMyClass : public CDialog
{
public:
HANDLE thread_handle;
DWORD thread_id;
UINT ThreadFunc(LPVOID data);
// other things
}
then
thread_handle = AfxBeginThread(ThreadFunc,
// (LPVOID)1,THREAD_PRIORITY_NORMAL, 0,0,NULL);
no the problem is i get this error
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
why am i getting that error.. also when i use the api method CreateThread it also produces an error saying that CreateThread cannot convert parameter 3 from unsigned long (void*) to unsigned long (__stdcall)(void*) or something like that... I really need to get this thread running for my program....
|
|
|
|
|
The thread function has to be declared static . This is because the compiler needs to determine its address, which won't be known until runtime otherwise.
|
|
|
|
|
I'm just writing to back up that other answer. It's true you do need to delcare static. Sometimes though, that can be a problem becuase you want to access member variables and functions back in CMyClass. Here's a good way to get what you want here, I think:
class CMyClass : public CDialog
{
public:
HANDLE thread_handle;
DWORD thread_id;
static UINT ThreadStartFunc(LPVOID data);
UINT ThreadFunc();
} and then...
thread_handle = AfxBeginThread(ThreadStartFunc, (LPVOID)this); then later:
UINT CMyClass::ThreadStartFunc(LPVOID data)
{
ASSERT(data != NULL);
return ((CMyClass*)data)->ThreadFunc();
}
UINT CMyClass::ThreadFunc()
{
return 0;
} I don't know if that helps at all.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thanks.... it's working now... now i'm on to the final stage..
|
|
|
|
|
|
Joel Holdsworth wrote:
thread_handle = AfxBeginThread(ThreadStartFunc, (LPVOID)this);
Friend, you are breaking the cardinal rule of MFC, CWnd objects are not allowed to be passed between threads, it should only be used by the thread which created it. You will never be able to predict when the application bombs in your case. Please have a look into this link
q147578/[^]
suhredayan There is no spoon.
|
|
|
|
|
True... you're right! I wasn't thinking. I never create thyreads in window objects! I always have a dedicated class to administrate my worker or back-end or whatever.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Joel Holdsworth wrote:
I never create thyreads in window objects! I always have a dedicated class to administrate my worker or back-end or whatever.
Can't say anyhting without seing your administrator class
suhredayan There is no spoon.
|
|
|
|
|
This is covered in the FAQ:
http://www.codeproject.com/cpp/cppforumfaq.asp#cpp_callbacks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i'm writing a header file and i have the following code:
public:
...
private:
T arr[]; // when i compile it tells me that it is an illegal zero-sized array
what i dont understand is that i works fine on a linux compiler, so what does zero-sized array mean
alex
|
|
|
|
|
its not a bug.. you have to specify the size of an array or dynamically allocate it.. the size can't be unknown
|
|
|
|
|
it isn't safe for linux to allow that actually. imo what vc++ did is correct.
anyway if u want a zero-sized array, do u mean u're going to allocate memory to the array on the fly?
if so, u should declare it as a pointer. i.e.
T *ptr;
then u should use new and delete to alloc and free the memory respectively.
even better, use vectors as it does all the memory handling for u.
http://www.roguewave.com/support/docs/sourcepro/stdlibref/vector.html[^]
|
|
|
|
|
Hi there,
How can I copy a folder to a different location. I tried using the SHFileOperation but it did not work.
Thanks!
|
|
|
|
|
It's hard to say without posting your code.
A common problem is failing to append the extra NULL character to from and to buffers.
You can try this and see if it works for you:
http://www.thecodeproject.com/shell/cshellfileop.asp
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Post the code which is not working.
suhredayan There is no spoon.
|
|
|
|
|
i want that my application should start when the computer start like time in tray of taskbar.
ddd
|
|
|
|
|
I like adding a shortcut to C:\Documents and Settings\<CURRENT_USER>\Start Menu\Programs\Startup so that they can remove it easily with the start menu
or add a key to
hkey_local_machine\software\microsoft\windows\currentversion\run
|
|
|
|
|
Mark Petrik Sosa wrote:
hkey_local_machine\software\microsoft\windows\currentversion\run
Usually you may not have write permission to "hkey_local_machine", suggested way is to use hkey_current_user.
suhredayan There is no spoon.
|
|
|
|
|
Hi!
I have a listbox that I'm adding content to, and I'd like to have it automatically scroll to the bottom any time new content is added. How might I do this?
Thanks!
|
|
|
|
|
Nevermind, I figured it out.
For those who might ever wonder:
Just use SETCARETINDEX to the index = LB_GETCOUNT
Thanks!
|
|
|
|
|
Hi,
does anyone know, how to get rid of the border of an ComboBox?
I've tried to remove all styles wich are handling with borders, e.g. WS_BORDER, WS_EX_CLIENTEDGE, WS_EX_DLGMODALFRAME and so on, but there isn't any change.
Whith ohter controls, like an Edit, it works.
Overriding OnPaint, and drawing the whole ComboBox myself, is not very useful, althought I can paint it without a frame, I still can't use the whole area of the control (except the pusbutton of coarse) for text, because the boarders are still there, but invisible.
Any other ideas???
Thanks in advance
|
|
|
|