Solved

AfxGetApp() detaild

Posted on 2004-09-26
8
780 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now