|
No need to convert anything, you can simply assign your buffer in your CString object:
CString csPath = buffer;
If you need to concatenate your buffer at the end of the CString content, you can also do it like this:
CString csPath = "Something";
csPath += buffer;
BTW, what is SIZEOFTCHAR ? What is its value ? If it is the size of one character, then your string will only be able to contain 1 single character, so I guess this is not really what you want.
|
|
|
|
|
Thanks for ur Reply.....
but the issueis...
TCHAR buffer[8000];
::GetSystemDirectory(buffer,8000);
i need add the below string to the path which is obtained from above function..
CString csPath;
csPath=_T("\\")+"files.ini";
Please help me..
|
|
|
|
|
p_1960 wrote: i need add the below string to the path which is obtained from above function..
CString csPath;
csPath=_T("\\")+"files.ini";
CString csPath = buffer;
csPath += _T("\\files.ini");
|
|
|
|
|
TCHAR buffer[8000];
if (! ::GetSystemDirectory(buffer,8000))
{
}
CString csPath(buffer);
csPath += _T("\\files.ini");
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]
|
|
|
|
|
p_1960 wrote: TCHAR buffer[8000];
What's your fetish with the number 8000?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I make a guess:
This sample [^] uses 32767 , that is 0x8000-1 (Well..., actually the two things are probably unrelated...)
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]
|
|
|
|
|
CPallini wrote: This sample [^] uses 32767, that is 0x8000-1 (Well..., actually the two things are probably unrelated...)
thats probably best answer i ever got!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Thank you, anyway I guess you got too few answers in you life...
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]
|
|
|
|
|
CPallini wrote:
Thank you, anyway I guess you got too few answers in you life
i thought you are taliking about question
|
|
|
|
|
Just kidding, pal (I know, I often forgot the joke icon... )
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]
|
|
|
|
|
CString is 16 bit under unicode but 8bit under non unicode version i guess.
but
so underunicode version direct conversion can be done as TCHAR is unsigned short.
where in non unicode version, WideCharToMultiByte() can be used
|
|
|
|
|
|
You have this code
HCURSOR hcur;
hcur = ::LoadCursorFromFile((LPCWSTR)"C:\\eglobe.ani");
::SetSystemCursor(hcur,OCR_NORMAL);
This bit - (LPCWSTR)"C:\\eglobe.ani" - will not work. The string literal is of type LPCSTR. That cannot be correctly converted to LPCWSTR with a simple cast. Instead, use this:
hcur = ::LoadCursorFromFile(_T("C:\\eglobe.ani"));
The _T macro either uses the string literal ("C:\\eglobe.ani" ) or the wide-char equivalent (L"C:\\eglobe.ani" ) as necessary
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Now my code is as below:
But Still it enters else bock ie.,"Failed"
CString s("Sucess");
HCURSOR hcur;
hcur = ::LoadCursorFromFile(_T("C:\\eglobe.ani"));
if(hcur!=NULL)
{
::SetSystemCursor(hcur,OCR_NORMAL);
}
else
{
s="Failed";
}
|
|
|
|
|
This worked, but setting back the curso to normal did not work ie.,last statement
Plese help
CString s("Sucess");
HCURSOR hcur;
HCURSOR hCurBusy = ::LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ANICURSOR1));
HCURSOR hCurStandard = ::LoadCursor(NULL, IDC_ARROW);
::SetSystemCursor(hCurBusy,OCR_NORMAL);
int i;
while(some length process)
{
}
::SetSystemCursor(hCurStandard,OCR_NORMAL);
|
|
|
|
|
This worked, but setting back the curso to normal did not work ie.,last statement
Plese help
HCURSOR hcur;
HCURSOR hCurBusy = ::LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ANICURSOR1));
HCURSOR hCurStandard = ::LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_NORCURSOR));
::SetSystemCursor(hCurBusy,OCR_NORMAL);
int i;
while(i=0)
{
Sleep(100);
i++;
}
::SetSystemCursor(hCurStandard,OCR_NORMAL);
|
|
|
|
|
ptr_Electron wrote: ::SetSystemCursor(hCurBusy,OCR_NORMAL);
Eeep - that's the WRONG way to change cursors.
With Windows, you either set the cursor in a window's class or respond to WM_SETCURSOR[^] messages to set the cursor. Your way is changing the cursor for the whole system - people will cuss you if you do that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Can you please help me to understand how to respond to WM_SETCURSOR
|
|
|
|
|
OK...you need to add a WM_SETCURSOR message handler to the window where you want your special cursor to be shown. This handler should use SetCursor to change the cursor to the one you want and return TRUE.
The form of the message handler obviously depends on what Windows framework (if any you're using) - here's an example using MFC[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I want to handle the WM_SETCURSOR is the view class and
Set BeginWaitCursor(); and EndWaitCursor(); in a non MFC class with
handles the lengthy operation.
Is that ok, Please advice the best way
|
|
|
|
|
ptr_Electron wrote: Is that ok
Should be - best way to see is to try it.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
ptr_Electron wrote: But Still it enters else bock ie.,"Failed"
Have you used GetLastError() to find out why?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have made a few wrapper classes for arrays to include dynamic resizing, string indexing etc.
The classes worked fine when used on their own in an app. Now i have attempted to make a Hashtable class which uses an Array object of AssocArray objects.
When I attempt to access data by using code like ' array[x][str] = y; ' I get the following error...
error C2679: binary '[' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
#include <string>
using std::string;
int x = 0;
int y = 1;
string = "Foo";
array = new Array<AssocArray<int>>();
array[x][str] = y;
Function for overloaded operators is very similar for both Array, and AssocArray. I have removed all code inside function as it produced the same error when commented out.
template <class TType>
TType& AssocArray<TType>::operator [](string s)
{
return new TType;
}
It is my understanding that the line ' array[x][str] = y; ' would be computed like this...
AssocArray<int> ax = array[x];
ax[str] = y;
Am I correct about this?
I'm not sure what is going on here, and assume this is all the relevant code, If you would like to see any more just ask.
|
|
|
|
|
Mikey_H wrote:
#include <string>
using std::string;
int x = 0;
int y = 1;
string = "Foo";
array = new Array<AssocArray<int>>();
// Error C2679
array[x][str] = y;
does it stands for:
int x = 0;
int y = 1;
string str = "Foo";
Array<AssocArray<int>> * array;
array = new Array<AssocArray<int>>();
(*array)[x][str] = y;
?
Mikey_H wrote: template <class ttype="">
TType& AssocArray<TType>::operator [](string s)
{
return new TType;
}
does it stands for
TType& AssocArray<TType>::operator [](string s)
{
return *(new TType);
} ?
Have you C# (or Java ) roots?
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]
|
|
|
|