|
The easiest way is to create a mouse pointer in your resource editor and then charge it in your view with
m_hCursor=AfxGetApp()->LoadCursor(IDC_MYCURSOR);
if (m_hCursor)
::SetCursor (m_hCursor);
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Thanks Nelek, I'll give it a go.
Cheers.
|
|
|
|
|
BTW, I once faced with a problem, the cursor was changing when i clicked in a button, but then when I moved the mouse, the cursor changed another time to the standard one.
To avoid this, I made my m_hCursor member variable, set the first two lines in the click where I wanted to have the new cursor, and the last line "::SetCursor (m_hCursor)" in the OnMouseMove ()
It maybe is not the best solution but it works.
Logically you will have to load another time the usual white cursor when you end with your personal one.
Do it with LoadStandardCursor(IDC_ARROW)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Are you handling the WM_SETCURSOR message? In it, you can set the cursor by calling SetCursor() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi everybody,
if you create a new Dialog and create from it a new CDialog derived class,
then the class with the most common function is already written by Visual Studio
or the MFC.
This nude basic class, how is it called?
Because i derived a View-Class of CFormView which includes all the functions and variables
of all my view's in the whole project.
If i create a new View, the class is derived from CFormView. So i need to change the class
that it derives from my "UniView" Class.
Is it possible to create a own "Template" of this class, so that all the sourcecode is
automatically inserted ?
I hope you can understand my request, it's complicated to explain with expression which i don't know
how the are called LOL
Big thanks
|
|
|
|
|
Go to the *.h and to the *.cpp, press ctrl+h and replace CFormView with your CUniView
w8 a moment... what do u want exactly to achieve? A View that is derived from your CUniView, or a View derived from CFormView but that you can use everywhere in your project?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I have a View-derived-Class "UniView" ... there'in i have many functions which are
the common basic functionalities of all my implemented views. ( For example the view is colored
in blue, initialization of variables, etc )
For each window in my project i create a dialog ressource and create a new class from CFormView.
Visual Studio writes now a "standard view class" kind of
class NewView : public CFormView
{
NewView();
~NewView();
#ifdef DEBUG
...
...
#endif
};
So the user can now implements his code into it.
But i change the source code in this way that this new view is derived by my proper UniView.
I change the constructor, add Handlers, etc ...
These changings are made in all Views of my project ...
So i need to applic this changings everytime i create a new view.
Now the question is: Is it possible to create directly a "template" that the self-generated
source code of the new view is derived from UniView, has directly handled some handlers
and so far ...
Big thanks for help
|
|
|
|
|
Then it can be done as I said at the 1st try.
Go to the NewView.h and the NewView.cpp, press ctrl+H, replace all CFormView with CUniView. So you are deriving like this.
CUniView : Public CFormView
CNewView : Public CUniView //(and for extension is : Public CFormView too)
The functions and all things that you have in your CUniView may be public but MUST NOT be private if they are supposed to be used in the NewView. If you have private things that you want to use in the other one, change it to protected (its not public, but can be used by the derived classes).
I hope it helps you
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi all,
I want make package of my MFC application so that it can be installed and used on any windows machine. I have made MFC dialog based application under VC 2005. How could i make package as we can do for application made in VB. Is there any provision for it?
Hemang
|
|
|
|
|
i made it with NSIS (NullSoft Installer System), it is quite easy to solve, but I got an error by the file associations, I dont know if is programm error or my error, Im still trying to solve it. But the installator works perfectly.
Before do it, be sure that you pack release version and that ou have all important dlls that other computer may not have. Check it out with "dependancy walker"
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Ok thanks for haveng been looked at my post. I'll go through it. Once again thanks a lot for suggestion
Hemang
|
|
|
|
|
Ok thanks for having been looked at my post. I'll go through it. Once again thanks a lot for suggestion
Hemang
|
|
|
|
|
Hi ALL,
I am writing function which return template object of type CArray. Following is the defintion for this.
CArray<cstring,cstring> COpenFolderPage::GetPagesPath()
{
CArray<cstring,cstring> pagePathArray;
// some code
return pagePathArray;
}
When i compile this code, then there is error as "no copy constructor is found" So how to write copy constructor in this case.
Thanks in Advance
Atul
|
|
|
|
|
I made a lot of different objects in my project deriving from CObject. In all of them I have the constructor/destructor, copy and assingment operators, and in just some the equality operator
CMyObject();
CMyObject(const CMyObject &obj);
CMyObject& operator= (const CMyObject &obj);
BOOL operator== (const CMyObject &obj);
virtual ~CMyObject();
and I code them following this schema
CMyObject::CMyObject()
{ m_dVar1 = 0.0;
m_bVar2 = FALSE;
}
CMyObject::CMyObject(const CMyObject &obj)
{ m_dVar1 = obj.m_dVar1;
m_bVar2 = obj.m_bVar2;
}
CMyObject& CMyObject::operator= (const CMyObject &obj)
{ m_bVar1 = obj.m_bVar1;
m_bVar2 = obj.m_bVar2;
return *this;
}
BOOL CMyObject::operator== (const CMyObject &obj)
{ return ((this->m_bVar1 == obj.m_bVar1) &&
(this->m_bVar2 == obj.m_bVar2) &&
);
}
CMyObject::~CMyObject()
{
}
With this schema you can use the object in arrays, in lists, just as independant object and make operations and so on. Up to complicated hierachies of objects that are owned from other objects. (For more info about what I mean take a look into my answers in the comments of my article SmartListII[^], I wrote there more or less the structure I use with the objects in one project, using lists, arrays and so on)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
pagePathArray( pagePathArray& rhs )
{
m_memberOne = rhs.m_memberOne;
...
}
Or easier:
void COpenFolderPage::GetPagesPath( CArray<type,type>& pagePathArray )
{
}
|
|
|
|
|
Do you want to do exactly what your code implies? Sure?
Do you want to return a copy of the local CArray object?
Uhm...
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.
|
|
|
|
|
Because the board software eats all > and <.
CArray<type, type> COpenFolderPage::GetPagesPath()
{
CArray<type, type> pagePathArray;
return pagePathArray;
} looks quite reasonable.
CArray surly has a copy-c'tor.
Otherwise the class is much more broken than I ever imagined.
Hint: std::vector<type> works equally well and is actually modern C++ instead of some funny hack for MS C++ 4 (of 10 years ago).
-- modified at 4:56 Monday 19th November, 2007
Major oops - nevermind. If you saw the interim-version: Forget it immediatly!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Much better, but I still think it is not a good idea to return a copy of the local array.
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.
|
|
|
|
|
As long as he does not return a pointer or reference to it, I think there is nothing wrong.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
As you are pointing out, it is not an error; anyway, as I pointed out, it is not a good idea (hint: efficiency).
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.
|
|
|
|
|
That is probably premature optimisation.
When specifically this copying of the array slows the whole application down, then we can think about how we speed his code up.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Oh no, this is definitely NOT premature optimization.
The original method design is simply bad: whenever you deal with array or (not trivial) objects, reference passing is a must (unless you have strong motivations to do the opposite).
Premature optimization is bad. Bad design is even worse.
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.
|
|
|
|
|
OK, you won.
I am changing my function definition to
const CArray<type, type>& COpenFolderPage::GetPagesPath()
Oh- wait!
The Array is a function-local variable. We *have to* return it by value!
The compiler would have to do a copy anyway.
We have three objects involved:
TargetArray - temporary - Source( local to function)
The target being a mere reference is illegal, because the local variable goes out of scope.
So, in all possible implementations, two of the three objects can be merged in one by the optimizer, but never all three.
The compiler has to copy once.
-- modified at 4:58 Monday 19th November, 2007
(This modification overlapped with the replyh
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Because the local variable goes out of scope.
I know, I'm quite polemical, cheers
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.
|
|
|
|
|
CPallini wrote: I know, I'm quite polemical, cheers
No you are'nt. I was acting faster than I was thinking.
But I was just in the processinng of modifying my post...
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|