|
A CString for key and for the value too. Incidentally I added another question to my initial one..
|
|
|
|
|
if you're using a CString, then NULL is not an issue. you will just have an empty CString as a key in that case, not a NULL.
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
Except theres a complication: This map key and value eventually have to be converted to char* because thats the way Access takes them in as records.
|
|
|
|
|
Do you put CString's in your map? If so, NULL is automatically be converted to CString object with no contents. So no problem
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
ns wrote:
If I have an editbox with no entry, what will GetWindowText return in its argument?
Depends on which GetWindowText you use.
<br />
int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const;<br />
<br />
void GetWindowText( CString& rString ) const;<br />
If you use it with LPTSTR, the first character in the array will be set to '\0'. If you use CString, it will be a CString object with a "" in it
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
Thats great. But I forgot to add that eventually these friendly CStrings get converted into char*s because I have to put them into a database as rs->fields(key0)->Value = value0
where I strcopied my CStrings key and value over into the corsep key0 and value0. The database didnt like the empty string at all, and didnt put in the record...
Thank you for answering.
ns
|
|
|
|
|
Is it by any chance that this field shouldnt be NULL in the DB?
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I created that db field as nullable which in databasey according to docs means(for access) a blank string. SO it shouldnt be upset about that. I get no error msg, just that nothing gets added to the whole record if one fields value is left blank.
|
|
|
|
|
i had once the same prob in access, i didnt solve it, i just replaced a blank string with _ !
Microsofts
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I like that solution. So if getwindowtext gives me back a cstring "", I'll just replace it with _, and vice versa when retrieving it. Great idea!
Thanks,
ns
|
|
|
|
|
Asalam mualaekuum?
|
|
|
|
|
I'm tearing my hair out here through frustration because I know its probably the stupidest of problems but whatever way I try I can't get it fixed.
Basically I've taken a CString from the CFileDialogs GetPathName function, I'm needing to turn that into a char*, or more exact a PSTR but I think they're the same, but I keep getting Access Violations whichever way I try this. Just now my code is
<br />
char* szPath = new char[pathToExe.GetLength()+1];<br />
strcpy(szPath,(LPCTSTR)pathToExe);<br />
TRACE("szPath = %s\n",szPath);<br />
I've also tried using the CString.GetBuffer, without the (LPCTSTR), but no luck there either, how the damnation do I do this Please save my sanity and not laugh too hard at the newbie
Thanks fellas
carrie
|
|
|
|
|
Are you sure that the error is in these lines? It seems to be correct.
It may be because allocation of char* on the heap fails (just a guess).
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
d'oh, you're right, and thanks for the quick reply because you just made me set a breakpoint and saw that it wasn't that that was the problem. I'm trying to use the WinSpy32 code to make something of my own and didn't spot it doing something in the background.
Sorry to be an idiot, 4 years of a computing degree, 3 of them in C & C++ and I can't even do the basics sometimes Thanks again
|
|
|
|
|
carrie wrote:
Sorry to be an idiot, 4 years of a computing degree, 3 of them in C & C++ and I can't even do the basics sometimes
This happens sometimes. Once, in Linux, in a simuation program i was stuck with an error for a whole day. Then I started to blame the simulation program. But it turned out that I was trying to divide an integer by zero Now I blame linux, because instead of telling me that there is a divide by zero error, it just gave me that famous error report "segmentation fault". Nothing more
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
are you doing a Unicode build?
-c
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
Did you try this too? if you are compiling ASCII version, your code should work.
TCHAR* szPath = new TCHAR[pathToExe.GetLength()+1];
lstrcpy(szPath, pathToExe);
TRACE("szPath = %s\n",szPath);
VOTD: 23 "And this is his command: to believe in the name of his Son,
Jesus Christ, and to love one another as he commanded us." - 1 John 3:23 (NIV)
|
|
|
|
|
Your code sample will crash if used in a UNICODE build. new will allocate a certain number of bytes, not characters
TCHAR* szPath = new TCHAR[ (pathToExe.GetLength() + 1) * sizeof(TCHAR) ];
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hmmm... I was surprised by your comment since you are allocating twice memory than
necessary. sizeof(TCHAR)==1 for ASCII and 2 for _UNICODE build. I tried it with VS .NET and it works fine. It should work also with VS6.
BTW, I used lstrcpy in my example not strcpy !
VOTD: 23 "And this is his command: to believe in the name of his Son,
Jesus Christ, and to love one another as he commanded us." - 1 John 3:23 (NIV)
|
|
|
|
|
You are right, PJ lost his mind there for a moment. He is thinking malloc and not new.
Tim Smith
"Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution."
Hoare - 1980 ACM Turing Award Lecture
|
|
|
|
|
No, I did not loose my mind. But now that you point it out, and I think about it, I will admit that I was wrong. No excuse can be made for ignorance.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Try LockBuffer/UnlockBuffer for obtaining a non-const LPSTR
Concussus surgo.
When struck I rise.
|
|
|
|
|
damn you guys are megafast tonight So fast that when I was replying another 3 turned up :p Thats impressive, thanks to you all for your help, time to try to decipher some more code
|
|
|
|
|
This is probably elementary but I cant find anything suitable in the docs. All i want to do is put the text from the first item in the listbox, into an edit box. I wont be selecting the item, I just want the text from it.
Thanks,
ns
|
|
|
|
|
from msdn:
CString GetItemText(int nItem, int nSubItem );
Parameters:
nItem - The index of the item whose text is to be retrieved.
nSubItem - Specifies the subitem whose text is to be retrieved.
ex: CString strTemp = m_lbMyListBox.GetItemText(0,0);
-dz
|
|
|
|