Click here to Skip to main content
15,911,711 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralUse of CSocket or CAsynSocket with UDP protocol Pin
Atif Mushtaq19-Nov-03 20:52
Atif Mushtaq19-Nov-03 20:52 
GeneralRe: Use of CSocket or CAsynSocket with UDP protocol Pin
l a u r e n20-Nov-03 13:11
l a u r e n20-Nov-03 13:11 
GeneralRe: Use of CSocket or CAsynSocket with UDP protocol Pin
Atif Mushtaq20-Nov-03 18:23
Atif Mushtaq20-Nov-03 18:23 
GeneralRe: Use of CSocket or CAsynSocket with UDP protocol Pin
l a u r e n20-Nov-03 18:28
l a u r e n20-Nov-03 18:28 
QuestionHow to access Member functions of Application class Pin
Shenthil19-Nov-03 20:23
Shenthil19-Nov-03 20:23 
AnswerRe: How to access Member functions of Application class Pin
Shehzad Salim19-Nov-03 20:50
Shehzad Salim19-Nov-03 20:50 
AnswerRe: How to access Member functions of Application class Pin
Anonymous19-Nov-03 20:56
Anonymous19-Nov-03 20:56 
AnswerRe: How to access Member functions of Application class Pin
Antti Keskinen19-Nov-03 21:03
Antti Keskinen19-Nov-03 21:03 
Like the MFC Reference states, your application class is derived from CWinApp. There is a global MFC function AfxGetApp which returns a pointer to your class's parent CWinApp.

You can use the below method to access the class. Here, we assume that your the implementation of your dialog class (.cpp file) #includes the application class's header file. This is usually done for you when you create an application, but make sure just in case. If you have not included it, you will receive errors like 'Unknown variable'

// Achieve a pointer to the application class
CMyApp* ptrApp = DYNAMIC_DOWNCAST( CMyApp, AfxGetApp() );<DIV>

if ( !ptrApp )
   TRACE0("Failed to get application pointer\n");<DIV>

// Use the pointer
UINT uiReturnValue = ptrApp->MyFunction(PARAM param1, PARAM param2);


The DYNAMIC_DOWNCAST macro does a safe downcast from CWinApp* returned by AfxGetApp into the CMyApp* type. As your application class is derived from CWinApp, the cast is perfectly legal and will yeild a pointer to your derived class.

You can use a similar method with any MFC class, for example, you can use GetParentFrame method of getting a view's parent frame (CFrameWnd*) then cast it down to your derived CMyFrameWindow class.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
Questionhow to incorporate Excel's external data importer in my appn. Pin
Rajesh match19-Nov-03 18:58
Rajesh match19-Nov-03 18:58 
GeneralCtreeCtrl Pin
Member 42425919-Nov-03 18:52
Member 42425919-Nov-03 18:52 
GeneralRe: CtreeCtrl Pin
Antti Keskinen19-Nov-03 19:32
Antti Keskinen19-Nov-03 19:32 
GeneralRe: CtreeCtrl Pin
Shehzad Salim19-Nov-03 20:57
Shehzad Salim19-Nov-03 20:57 
GeneralRe: CtreeCtrl Pin
Antti Keskinen19-Nov-03 21:07
Antti Keskinen19-Nov-03 21:07 
GeneralRe: CtreeCtrl Pin
Member 42425919-Nov-03 23:01
Member 42425919-Nov-03 23:01 
QuestionAnone used CxImage?? Pin
Prakash Nadar19-Nov-03 18:00
Prakash Nadar19-Nov-03 18:00 
AnswerRe: Anone used CxImage?? Pin
Shehzad Salim19-Nov-03 21:05
Shehzad Salim19-Nov-03 21:05 
GeneralRe: Anone used CxImage?? Pin
Prakash Nadar19-Nov-03 21:26
Prakash Nadar19-Nov-03 21:26 
GeneralQuery data in unknown binary file Pin
NotProfessional19-Nov-03 17:57
NotProfessional19-Nov-03 17:57 
GeneralRe: Query data in unknown binary file Pin
Johnny ²19-Nov-03 21:39
Johnny ²19-Nov-03 21:39 
GeneralRe: Query data in unknown binary file Pin
NotProfessional20-Nov-03 3:51
NotProfessional20-Nov-03 3:51 
GeneralRe: Query data in unknown binary file Pin
Johnny ²20-Nov-03 5:24
Johnny ²20-Nov-03 5:24 
GeneralSimple problem Pin
helpapp19-Nov-03 17:53
helpapp19-Nov-03 17:53 
GeneralRe: Simple problem Pin
Antti Keskinen19-Nov-03 20:42
Antti Keskinen19-Nov-03 20:42 
GeneralRe: Simple problem Pin
helpapp19-Nov-03 22:41
helpapp19-Nov-03 22:41 
GeneralA Question On GDI+ Pin
Prakash Nadar19-Nov-03 17:15
Prakash Nadar19-Nov-03 17:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.