Solved

AfxGetApp() detaild

Posted on 2004-09-26
8
803 Views
Last Modified: 2013-11-20
Can someone tell me what AFxGetApp() is used for, in simple terms.
This is method belonging to which class.
in one program i have seen recently, what they r doing is there is handle to a cursor.
HCursor l;
and then
then do this
l=AfxGetApp()->LoadStandardCursor(IDC_ARROW)
SetCursor(l);

I know tht this is for changing the cursor to an arrow.
but can u explain the role od AfxGetApp and the cursor handle.SetCursor belongs to which class.
In this all a part of CWnd class.

Please give a "layman"expl
0
Comment
Question by:vikasgkutty
  • 4
8 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 50 total points
ID: 12155305
When you create an MFC application with the AppWizard, CWinApp derived object is always created, it is called always 'theApp', no matters how your project is named.
So, basically, AfxGetApp returns you a pointer to this object, so you can use all the functions that have this object class.
In this case, CWinApp has a function called LoadStandardCursor(), because the cursor is normally a resource of the application (.exe) file, or alternatively a system resource like IDC_ARROW.

0
 

Author Comment

by:vikasgkutty
ID: 12155468
ok,
so, what is SetCursor, is it also a method of CWinApp
if u dont mind, can u also explaina bit aout handles.
like HCursor.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12155689
HCURSOR is an identifier for a cursor you load into memory, it can be a system cursor o a propietary cursor.
SetCursor is not a mehtod of CWinApp. It is a global function, not related to a specific class.
Have a look to MSDN documentation:
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/resources/cursors/cursorreference/cursorfunctions/setcursor.asp
SetCursor needs a handle to your chosen cursor.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12171594
Do you have more doubts?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12560496
I hope I have made an understandable explanation.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question