|
siddharthsan wrote: Can anybody tell me about .aps file like what it is and uses???
http://www.wotsit.org/search.asp?s=windows
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hi,
Can anybody tell about .aps file like what it is and it's use???
|
|
|
|
|
|
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=1905445&df=100&mpp=50&fr=58#xx1905445xx
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I have written a reference class for one of my classes. It implements reference counting for that class and that's pretty much it. I have written a cast operator to the class type it references, but the compiler does not use that operator implicitly, so whenever i want to access the referenced object, i have to do an explicit cast (or call a method like getObject()). How can i prevent that ?
Here some code to illustrate my problem :
class MyClassReference;
class MyClass
{
public:
void doStuff();
static MyClassReference getInstance();
~MyClass();
private:
friend class MyClassReference();
MyClass();
void addReference();
void removeRererence();
int m_referenceCounter;
};
class MyClassReference
{
public:
MyClassReference(MyClass &object);
operator MyClass &();
~MyClassReference();
};
This is just the principle, feel free to comment on it.
wbr
Brainley
|
|
|
|
|
Your operator needs to return the reference to your class:
MyClass& operator& ();
|
|
|
|
|
same error : doStuff() is not a member of MyClassReference.
-- modified at 6:00 Wednesday 21st February, 2007
|
|
|
|
|
Show the code that is giving the error.
|
|
|
|
|
MyClassReference ref = MyClass::getInstance();
ref.doStuff();
He does not apply the cast implicitly. The following works :
((MyClass&)ref).doStuff();
The compiler told me though, that i have to declare the cast operator
operator class CNeighbour &();
in order for this to work. But he still does not apply the cast-operator implicitly.
|
|
|
|
|
Of course, you are not using the operator at all ! So it is logical that it complains.
BTW, are you trying to do something similar as a smart pointer (but using references instead) ?
|
|
|
|
|
1. Yes, it's not used. Thought it might be possible to use it implicitly, so the code looks better.
2. Yes. It actually is a smart pointer internally, but i tried to give it reference semantics and syntax. I need this for a synchronization problem. I have a list of references that is accessed from many threads. If one thread retrieves a reference from that list, and the list is cleared while it works on the reference, the reference remains valid until it goes out of scope (if it is a smart reference). This way i can minimize synchronization to the pure access on the list.
Maybe it would be better if i just overloaded the '->'-operator. It would have pointer-syntax then, but that would be ok i guess.
|
|
|
|
|
Mr.Brainley wrote: The compiler told me though, that i have to declare the cast operator
You need to apply that cast. Overloading operation MyClass doesn't mean that you can call members of MyClass using MyClassReference object. By doing this,you can cast MyClassReference class object for MyClass class.
|
|
|
|
|
hi,
I am new to vc++ , can any one tell me how to if window containg perticular view is focused or not.
I have one doc/view application in that in my CView class I have overloadedd onmouse active method now in that I want to check if the chid fram contaning that view is alredy active or not?
thanks in advance.
Rushiraj
|
|
|
|
|
CWnd::GetFocus returns pointer to window having focus.
|
|
|
|
|
hi
I have written this
int status = CView::OnMouseActivate(pDesktopWnd, nHitTest, message);
if(GetFocus()!=GetParent())
GetParentFrame()->SetFocus()->RedrawWindow();
return status;
what i want is it will not redraw window when foucs is on the same window and i clicked.
but in this code it always go in if condition.
Thanks ,
Rushiraj
|
|
|
|
|
rushiraj.jhala wrote: if(GetFocus()!=GetParent())
This should be like this,
if((*GetFocus())!=(*GetParent()))
{
}
|
|
|
|
|
sorry,
it is not woriking for me.
|
|
|
|
|
rushiraj.jhala wrote: it is not woriking for me.
I told you the way to compare the windows.
What type of error it is givng. I could not understand your logic basically.
|
|
|
|
|
int CImageView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
int status = CView::OnMouseActivate(pDesktopWnd, nHitTest, message);
if((*GetFocus())!=(*GetParent()))
GetParentFrame()->SetFocus()->RedrawWindow();
return status;
}
I have one Doc/view applivation in that i have one other dialog box also.
so when i click inside the view of my chid frame i want to check if this chid has foucs or not because if this frame has allready focus i dont need to redraw window other wise if dialog has foucs i have to set foucs the chid frame containing that view and redraw widnow.
for that in onmouseactive i wnat to check child frame is fouced or dialog box has foucs.
|
|
|
|
|
rushiraj.jhala wrote: so when i click inside the view of my chid frame i want to check if this chid has foucs or not
Whenever you click on a window, it will get focus automatically.
|
|
|
|
|
yes it will be
what i want is if child frame is focused and I click in client area of child i dont want to call GetParentFrame()->SetFocus()->RedrawWindow().
but in other case if dialog is focused and when i click on client area of child it will be focused but in addition i want to call GetParentFrame()->SetFocus()->RedrawWindow() function.
for that i want to know befour i have clicked is this child window is fouced or dialog.
|
|
|
|
|
rushiraj.jhala wrote: but in other case if dialog is focused and when i click on client area of child it will be focused but in addition i want to call GetParentFrame()->SetFocus()->RedrawWindow() function.
I really cant understand your requirement. In this case, you will never get focus on dialog in your question.
|
|
|
|
|
Dear, Dear,
I understand the problem now.
Refer your original code,
You are comparing window with focus with parent window of view, which will be child frame.
You need to modify your original code to this,
int CImageView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
if((*GetFocus())!= (*this))
SetFocus()->RedrawWindow();
return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
|
|
|
|
|
It works fine.
Thans Dear.
|
|
|
|
|
use CWnd::GetFocus() , it will return you the handle of the windows having the focus...
|
|
|
|