(newbie)CWinApp::LoadIcon() call within a CView object 
Author Message
 (newbie)CWinApp::LoadIcon() call within a CView object

Hi everyone!

I noticed the DrawIcon() method in a CDC class overview, and just for the
thrill of it, decided to give it a spin within a test application's View
class.
Besides coordinates, DrawIcon() requires a HICON. To get a HICON reference
to one of the icons in my resources, all I could find was the CWinApp method
LoadIcon(). Hm. Obviously not ideal; since LoadIcon returns a HICON, I tried
calling "theApp.LoadIcon()", assuming since theApp is technically a global
variable, it should work, but it doesn't.
Does anyone have any ideas? Thanks.

Cheers,
            - Tom



Sun, 16 Jul 2000 03:00:00 GMT  
 (newbie)CWinApp::LoadIcon() call within a CView object

Quote:

> Hi everyone!

> I noticed the DrawIcon() method in a CDC class overview, and just for the
> thrill of it, decided to give it a spin within a test application's View
> class.
> Besides coordinates, DrawIcon() requires a HICON. To get a HICON reference
> to one of the icons in my resources, all I could find was the CWinApp method
> LoadIcon(). Hm. Obviously not ideal; since LoadIcon returns a HICON, I tried
> calling "theApp.LoadIcon()", assuming since theApp is technically a global
> variable, it should work, but it doesn't.
> Does anyone have any ideas? Thanks.

> Cheers,
>             - Tom

The object "theApp" does not normally appear in the app .h file so the
compiler does not know that symbol when compiling a view class.  Try
adding a line like this to your app .h file:

extern CMyApp theApp;

By the way, another way is to use a built-in MFC access function like
this:

        HICON hi = ((CMyApp*)AfxGetApp())->LoadIcon(..);



Sun, 16 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Obtaining the CWinApp pointer within a CView function?

2. Help: Trouble calling object classes within other object classes

3. Multiple CViews within one CView

4. A CView within a CView..possible?

5. Add CView within CView

6. NEWBIE calling ATL gods: Problem in calling DOM object

7. newbie - how to refer an object within the dialog box

8. How to call a COM object within Visual C++

9. Finding a CWinApp's CView or CDocument

10. VC6: CString/DLL memory problem within CWinApp.InitInstance?

11. One CDocument object and many CView objects ?

12. Controls on CWnd object on CView object?

 

 
Powered by phpBB® Forum Software