|
Thanks you very much, i will try this.
Pvvr
|
|
|
|
|
and passing the application's HWND to GetWindowText() would retun you the window caption(title).
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
Hello everyone on forum,
Is it possible to convert a cstring to a char pointer
if yes then how
basically i have a cstring and i want to use one function which takes char * parameters now i want to pass the value that is in cstring to this function how can i do that
Thanx.
|
|
|
|
|
for this purpose you can use
strcpy(char *,CString)
It will help you.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
You can use the operator LPCTSTR ( ), like this:
CString cs = "Hello";
char * cp = (LPCTSTR) cs;
Operator LPCTSTR is built in the CString class, so it's safe to use.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
hello "kakan"
I used the method u specified but its giving the following error
C:\Program Files\Microsoft Visual Studio\MyProjects\interface\interfacedialog1.cpp(245) : error C2440: 'initializing' : cannot convert from 'const char *' to 'char *'
Thanx
|
|
|
|
|
Hello.
That's right, operator LPCTSTR returns a const char * (The 'C' stands for 'const')
The reason for returning a const char * is that the contents of what the const char * points to must be unaltered.
So if you call a function that acually changes the content of the CString, then you have to use the CString methods GetBuffer() and ReleaseBuffer().
GetBuffer() returns a LPTSTR (a char *).
But if you use GetBuffer(), then you must call ReleaseBuffer()
So in your case, use GetBuffer() and ReleaseBuffer().
And check out the CString documentation at MSDN.
I.e here[^]
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
|
namy1 wrote: basically i have a cstring and i want to use one function which takes char * parameters now i want to pass the value that is in cstring to this function how can i do that
Well if _UNICODE is defined then you will have to do some additional chores for converting to char* (Read this[^] for more info), else it's quite easy
CString csStr = "Non unicode string";
char *szStr = csStr.GetBuffer(0);
AFunctionToCall( szStr );
csStr.ReleaseBuffer(); Well if you need a const char* , it's much more easier
CString csStr = "Non unicode string";
const char* szStr = csStr;
AFunctionToCall( szStr );
|
|
|
|
|
use CString::GetBuffer() with CString::GetLength() to copy the enitre string into the char*.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
Link2006 wrote:Let's take it outside of CP
Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
|
|
|
|
|
Unless a copy is actually what is desired, there is no need to copy the data for this. GetBuffer returns a valid char* that can be used until you call ReleaseBuffer (at which time the CString object will be updated with the changes you made to the buffer).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
CString is replacable with char, ie you can put in a CString when a char[] is required.
try putting in a reference to your CString ie &string
|
|
|
|
|
I use SHBrowseForFolder to display folder select dialog. How detect folder change (create new, delete, ...) while this dialog displaying.
Thank for your answer.
|
|
|
|
|
Can you be more specific.
|
|
|
|
|
I use SHBrowseForFolder to display BrowforFolder dialog box.
And i create a button to create new folder.
Then, i don't know how to refresh the BrowseforFolder dialog box to update this folder i've created.
Yes, i know in SHBrowseForFolder has the new style dialog which may help us to create new folder.
But i want to create by my self and update to BrowforFolder dialog box is displyaing.
thank for your help.
|
|
|
|
|
Hope I understood your question
if you want to insert your buttons to SHBrowseForFolder for update or delete I see exmples of SHBrowseForFolder on codeproject
|
|
|
|
|
To update folder dialog, you can do follow:
Use SHGetPathFromIDList( m_bi.pidlRoot, pszPath ) to get root folder path
Use IShellFolder::ParseDisplayName to convert root folder path to LPITEMIDLIST (pidlRoot)
Assign this pointer (pidlRoot) to m_bi.pidlRoot:
m_bi.pidlRoot = pidlRoot;
to refresh folder dialog.
This code i didn't test, but i think it can do.
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
How can i write a select SQL statement for the DB that uses the string from CEdit1 ?
lets say database name : "Names_City" class : CNames_City
col 1 : "name"
col 2 : "city"
col 3 : "country"
CEdit1 : "m_name"
CEdit2 : "m_city"
CEdit3 : "m_country"
1) i have onChange for "m_name .When i write some txt in m_name i need to search in "Names_City > name = and if it matches i need the city in m_city and the country in m_country "
2)when i write in m_city and then in m_name i need to search in "name","city" and if m_name == "name" and m_city == "city" i need "country" in m_country.
* Remember i have ~260.000 Records ;
thank you in advance !
- please i need that information !
Bravoone
|
|
|
|
|
I wrote an example of SELECT for you did you see it?
|
|
|
|
|
yes but i dont understand it please write again for this example !
Bravoone
|
|
|
|
|
I think you need to reading a book about sql.For example you have a table1 with three cols you can use:
SELECT col1,col2,col3 FROM table1 WHERE name LIKE '%hello%'
(you can ask your question about sql on SQL / ADO / ADO.NET forum)
|
|
|
|
|
this i dont understand what is this :'%hello%' i need to search for the string lets say CString sName ;
m_name.GetWindowText(sName);
Bravoone
|
|
|
|
|
with LIKE you can retrive rows you can use LIKE with char,varchar,...
and in LIKE you have
% strings of any or some characters
- a character and,[],...
In VC you read your data with GetWindowText and insert your data to a statement sql
|
|
|
|
|
i think i start to understand the ideea but for that i need an ... example to understand thats way i request examples !
please , please , please write the SQL statement and m_name.GetWindowText( -->HERE<-- what!) for full understand !
thanks , and i will wait your answer ! please ...
-- modified at 3:08 Friday 22nd September, 2006
How can i write a select SQL statement for the DB that uses the string from CEdit1 ?
lets say database name : "Names_City" class : CNames_City
col 1 : "name"
col 2 : "city"
col 3 : "country"
CEdit1 : "m_name"
CEdit2 : "m_city"
CEdit3 : "m_country"
1) i have onChange for "m_name .When i write some txt in m_name i need to search in "Names_City > name = and if it matches i need the city in m_city and the country in m_country "
2)when i write in m_city and then in m_name i need to search in "name","city" and if m_name == "name" and m_city == "city" i need "country" in m_country.
Bravoone
|
|
|
|
|
i have try with CListCtrl you now , but it takes 5-6 mun to fill my list with data from DB and is not good maybe this is the solution my only problem is this : i want to search into DB from CEdit and i need to do fast !
Bravoone
|
|
|
|