|
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 !!
|
|
|
|
|
I have a xml in a remote machine. This remote machine is accessible to some machines, and not accessible to some machines. In a scenario we try to load the xml. We are getting a delay in the UI when machine which is not able to access the remote machine , is trying to load the xml from the remote machine. How to handle this scenario. Is there any way to check whether remote machine is accessible or not before loading that xml. Or any other better solution.
Thanks
|
|
|
|
|
If you don't want the UI looking like 'frozen' then you may use a worker thread to perform the connection with the remote machine.
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]
|
|
|
|
|
Just adding to Carlo's reply, here's an essay[^] that describes the usage of worker threads.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Do we have any api or any code snippet which can check whether remote machine is accessible or not.
|
|
|
|
|
You should already have it.
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]
|
|
|
|
|
Hello!
I want to use dynamic memory allocation for multi-dimensional arrays. While allocating there is no problem. But how to deallocate the memory? If I use the Method-1 will it be okay or will it cause memory leak or run time error? Which of the two methods are technically correct?
int nVal,i;
int **pVal=NULL;
pVal = new int * [5];
for(i=0;i<5;i++)
pVal[i] = new int [3];
Deallocation Method - 1
...
...
delete [] pVal;
Deallocation Method - 2
...
...
for(i=0;i<5;i++)
delete [] pVal[i];
delete [] pVal;
Any help in this matter will be highly appreciated. Thanks in advance.
|
|
|
|
|
Method-2 is the right way to do it.
Method-1 would cause memory leaks as it only frees the array of integer pointers and not the integer locations.
I would recommend you use one of the standard C++ containers.
Here is an example -
vector<vector<int>> ii;
vector<int> i;
i.push_back(10);
i.push_back(20);
i.push_back(30);
ii.push_back(i);
To access the value 20, you would do ii[0][1] or you can use iterators.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
In addition to the previous reply, there is one basic rule that you have to remember: for each call to the new operator, there should be a corresponding call to the delete operator if you want to avoir memory leaks.
So, your first solution is wrong because you call new 6 times and only call delete once.
|
|
|
|
|
As a further further reply, I'd recommend use of Boost.multi_array[^] rather than a raw array or a vector of vectors.
Why would I suggest this? Well, it's better than a raw C++ array because it's a single object and carries its bounds around with it. It's better than a vector of vectors because it's a single object that implies less memory allocations and also addresses a contiguous range of memory.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you all. Your suggestions have helped me a lot.
|
|
|
|
|
Hello
Is it possible to convert .cpl to .msc?
Or the other way around? (if the other way around, I need a way to list only specify ones, such as .msc does with there MMC.
Would appreciate any advice.
Thanks in advance,
Panarchy
|
|
|
|