|
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]
|
|
|
|
|
Few typos there, C#
I have made a reply to the other response.
|
|
|
|
|
Mikey_H wrote: template <class ttype="">
TType& AssocArray<ttype>::operator [](string s)
{
return new TType;
}
That doesn't look quite right - typo somewhere?
Mikey_H wrote: array = new Array<AssocArray<int>>();
// Error C2679
array[x][str] = y;
Similarly here - you can't use operators directly with pointers - but now I understand the error message.
The type of array is Array<AssocArray<int>>* . So, the type of array[x] is Array<AssocArray<int>>& - and that has an operator[] that takes an integer index, not a string index.
So, either declare array as Array<AssocArray<int>> array(); or use (*array)[x][str]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: you can't use operators directly with pointers
Ok, I did not think about that. So (*varPointer) will derefernce this?
(Is this only for user defined types? A pointer to a standard C array does not have to be derferenced does it?)
That first issue is solved with the corrections, another small one exists tho, probably a similar issue.
(*array)[x][str] = y;
will give the error....
error C2440: 'return' : cannot convert from 'int' to 'AssocArray<TType> &'
Do I need to dereference the AssocArray somehow too?
Thank you for your responses
modified on Tuesday, May 26, 2009 5:27 AM
|
|
|
|
|
Mikey_H wrote: (Is this only for user defined types? A pointer to a standard C array does not have to be derferenced does it?)
Quite right - pointers are special cases
Think about it - you're applying an operator defined on a class. The operator syntax a[b] is equivalent to a.operator[](b). So, with a pointer to the object, you can see that the method call syntax would be pa->operator[](b) , or (*pa).operator[](b) .
Mikey_H wrote: That first issue is solved with the corrections, another small one exists tho, probably a similar issue.
(*array)[x][str] = y;
will give the error....
error C2440: 'return' : cannot convert from 'int' to 'AssocArray<ttype> &'
Do I need to dereference the AssocArray somehow too?
Here's some sample code I wrote that has the operator[] layout you want:
#include <string>
#include <iostream>
template<class Element>
class Array
{
public:
Element& operator[](int index) { return e; }
private:
Element e;
};
template<class Element>
class AssocArray
{
public:
Element& operator[](std::string const& s) { return e; }
private:
Element e;
};
int main()
{
Array< std::string > as;
AssocArray< std::string > aas;
Array< AssocArray< std::string > > aaas;
as[2];
aas["Hello"];
aaas[2]["Hello"] = "Test";
std::cout << aaas[2]["Hello"] << std::endl;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Ok, I got it working, I had it right by the last response, the next error that came up was somewhere else unrelated and I was too tired to notice.
Thank you very much for your help.
|
|
|
|
|
Is there a specific reason why you don't want to use the containers from the STL (std::map, std::vector, ...) ? All these classes already provide support for what you are doing, so why do you want to rewrite that ?
|
|
|
|
|
Just an attempt to learn a little more.
|
|
|
|
|
I can't find any refrence any where(like this website, google, wiki).
-----------------How I found it-------------------------------------------
It's a Window's string message(0xC000 through 0xFFFF).
I got this from my [MFC Dialogbased Program]:
create a new [MFC Dialogbased Program], put a breakpoint here:
thrdcore.cpp
BOOL AFXAPI AfxInternalPumpMessage()
{
_AFX_THREAD_STATE *pState = AfxGetThreadState();
if (!::GetMessage(&(pState->m_msgCur), NULL, NULL, NULL))
Do nothing but start you program, you will get a message over 0xC000.
Use spy++ or GetClipboardFormatName you will get "MSUIM.Msg.*" //* may be Private
|
|
|
|
|
Dear all,
I met a problem where after i patch my VC++ 6.0 to service pack 5 and patch processor pack onto it, my application crash and pop up message saying that there is a stack over flow.
The problem is before patch, the same source code does not crash stack over flow.
Is there any setting i need to set after pack processor pack? Or what can i do.
The error message is :
During run time, the error message is :
The instruction at "0x09e02ebc" referenced memory at "0x00000004". The memory could not be "read".
But when i debug the release version:
Unhandled exception in MyApplication.exe (MyApplication.DLL) : 0xC00000FCD:Stack Overflow.
Please advice .
Thank you !!
|
|
|
|