|
The second parameter of assign() is the number of characters to copy to the string, so all you need to do is pCurrent-pszPath . Pointer subtraction using pointers to T returns their difference as multiples of sizeof(T) , so dividing by sizeof(TCHAR) is wrong. (Assuming pCurrent and pszPath are TCHAR* of course.)
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thanks for the input. The same is working on win32 platform.
|
|
|
|
|
I declared an int variable to an edit box.when i am trying to enter
-ve value it prompts that "please enter an integer".it is not allowing me to enter -ve sign.how can i prevent this prompt msg.
E-Ramu
|
|
|
|
|
You might have set range from 0-MAXINT
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
i didn't set any range and i didn't set the number proprty in the edit box properties as true
-- modified at 2:15 Wednesday 2nd August, 2006
E-Ramu
|
|
|
|
|
I am not sure but i think u cannot enter a -ve valu in a edit box whcih have number value set.
Another way is that derive class from the CEit and make that class as the member variable of the edit control. Overide the WM_CHAR message. This message will come when user enters a character into the edit box.
In that funtion check the character entered. Call the Base class( CEdit 's ) funtion only if it is a permitted character.
nave
|
|
|
|
|
Ramu.e wrote: I declared an int variable to an edit box.
Why? You need to use a CEdit variable for edit controls.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
OK, so yesterday some of you helped me with the the function LogonUser(). Thanx. But i'm struggling my but off with the last parameter. The thing is the last parameter is a Token, and I have no idea how to get this token a value. I have read all the documentation there is, but I would like a example. Plz someone help.
Thanx
Regards
Programm3r
|
|
|
|
|
It's an out variable, which means you need no pass any values for it. You will get a pointer to a to a token that represents the specified user.
You can pass like
HANDLE hUser = NULL;
LogonUser(....,...,&hUser)
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
The last onr is an out parameter. I.e that varaible returnds some value from the function..
eg..
HANDLE hToken = 0;
LogonUser( ..., &htoken );
nave
|
|
|
|
|
|
Hi, everybody. I'm a little stuck. I have no experience with DLL's and I'm trying to make something with'em.
I'm programming a dll (that calls a windows dll) wich contains the functions I want to use in my app. It compiles fine. But when I build my program that uses my dll, I get the next linking stage error:
MyProgram.obj : error LNK2001: unresolved external symbol "public: unsigned short __thiscall CMyProgramApp::OpenFile(class CString)" (?OpenFile@MyProgramApp@@QAEGVCString@@@Z)
Little help?
Znx.
Did you checked your TCP/IP settings? Enabled cookies? D'you want this dog?
|
|
|
|
|
Hi,
OK, I could be wrong on this one but, in my dll experience, it's because it cant find a certain function. I think it is the function in the dll you wrote. I would say try including the dll into program thats calling the dll you wrote. Hope it works.
Regards
Programm3r
|
|
|
|
|
|
You application should link with that library. which means, in your Project Properties (Settings) give lib file of the DLL. e.g SampleDLL.lib
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
u have to specify the lib file of that dll.
for that take project settings->Link tab
In the object/Library edit box give the name of the lib file. then try compiling.
nave
|
|
|
|
|
I have the following piece of code.
char* strFile = new char[50] ;<br />
CString str( "Hello\nCoders" ) ;<br />
strFile = str.GetBuffer( str.GetLength() );<br />
std::ofstream myfile;<br />
myfile.open ("d:\\example.txt");<br />
myfile << strFile ;<br />
myfile.close() ;<br />
delete[] strFile ;
The program throws a Debug assertion error at delete[] strFile ; . The function throwing the Exception is _CrtIsValidHeapPointer(pUserData) .
I was of the impression that creation with new must be followed by cleanup with delete . Seems like I am wrong or I did something wrong in the above code. Can anyone explain?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Hakuna-Matada wrote: char* strFile = new char[50] ;
strFile = str.GetBuffer( str.GetLength() );
when the scope of the variable ends, the destructor of the CString variable will be called. as per the implemantation of CString if you call GeBuffer, you should call ReleaseBuffer before calling any other functoins in CString else it will throw a debug asertion. Here the destructor itself a "silent" function. Hope you clear
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
In addition to what sarath said
char* strFile = new char[50] ;
strFile = str.GetBuffer( str.GetLength() ); causes a memory leak.
char* strFile = 0;
strFile = str.GetBuffer( str.GetLength() );
this is enough. And dont call delete.
nave
|
|
|
|
|
In addition to Naveen said,
Use GetBuffer only if you are doing some modifications on the CString.
operator LCTSTR (const char*) has been overloaded in CString for reading purpose.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|
|
Hi. Thanks for your reply. Well now I have..
char* strFile = new char[50] ;<br />
CString str( "Hello\nCoders" ) ;<br />
strFile = str.GetBuffer( str.GetLength() );<br />
str.ReleaseBuffer() ;<br />
std::ofstream myfile;<br />
myfile.open ("d:\\example.txt");<br />
myfile << strFile ;<br />
myfile.close() ;<br />
delete[] strFile ;
but it still doesn't work. As you may have noticed, I used the ReleaseBuffer as you had suggested but to no avail. Am I doing something wrong?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
why you are using the same buffy code?
This will work fine...
CString str( "Hello\nCoders" ) ;
std::ofstream myfile;
myfile.open ("d:\\example.txt");
myfile << (LPCTSTR)str;
myfile.close() ;
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
Last modified: Wednesday, August 02, 2006 1:15:50 AM --
|
|
|
|
|
Thanks for your time. Now I understand.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Make sure you call ReleaseBuffer after a GetBuffer or GetBufferSetLength.
This works:
<br />
CString str( "Hello\nCoders" ) ;<br />
std::ofstream myfile;<br />
myfile.open ("c:\\example.txt");<br />
myfile << str.GetBuffer( str.GetLength() ) ;<br />
str.ReleaseBuffer();<br />
myfile.close() ;<br />
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Steve Echols wrote: myfile << str.GetBuffer( str.GetLength() ) ;
In this code, it's not doing any editing. So that we can simply use the string object like this
myfile << (LPCTSTR) str;
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
My Blog | Understanding State Pattern
|
|
|
|