Board index » Visual Studio » Displaying a bitmap in a CView ..

Displaying a bitmap in a CView ..

Visual Studio335
Hello all,



I wish to display a bitmap in the CView instance associated with a document

template in an MDI type application. To do this, I dynamically created a

CStatic control as follows:





CStatic* theFMSmall = new CStatic;

BOOL theAnswer = theCPCaption->Create ("FM Samll",

WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE,



CRect (250, 170, 370, 240), this,

ID_FMSMALLBM);

theFMSmall->SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE

(IDB_BM_FMSMALL)));

theFMSmall->ShowWindow (SW_SHOW);









I have used something rather similar to display static controls within

CView instances that only contained text. If I remove the styles

SS_BITMAP | SS_CENTERIMAGE, the text "FM Small" is displayed.



The bitmap IDB_BM_FMSMALL exists. I am sure of that. If it didn't the

code wouldn't compile properly.



I have displayed this bitmap in some dialog boxes, so I know it is a good

image.



Am I doing something wrong? It is not possible to use a CStatic to display

a resource derived bitmap in a CView instance? Is this a bug in VS .NET?



Just wondering ..



Harvey


-
 

Re:Displaying a bitmap in a CView ..

"Harvey J Cohen" <hjNOSPAMcohen@sbcNOSPAMHEREglobal.net>wrote in message

Quote
Hello all,



I wish to display a bitmap in the CView instance associated with a

document

template in an MDI type application. To do this, I dynamically created a

CStatic control as follows:





CStatic* theFMSmall = new CStatic;

BOOL theAnswer = theCPCaption->Create ("FM Samll",

WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE,



CRect (250, 170, 370, 240), this,

ID_FMSMALLBM);

theFMSmall->SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE

(IDB_BM_FMSMALL)));

theFMSmall->ShowWindow (SW_SHOW);









I have used something rather similar to display static controls within

CView instances that only contained text. If I remove the styles

SS_BITMAP | SS_CENTERIMAGE, the text "FM Small" is displayed.



The bitmap IDB_BM_FMSMALL exists. I am sure of that. If it didn't the

code wouldn't compile properly.



I have displayed this bitmap in some dialog boxes, so I know it is a good

image.



Am I doing something wrong? It is not possible to use a CStatic to

display

a resource derived bitmap in a CView instance? Is this a bug in VS .NET?



It may exist, but is the call to LoadBitmap successful? I think you need to

pass your module's HINSTANCE to LoadBitmap. The NULL value is used for

predefined system bitmaps.

--

Jeff Partch [VC++ MVP]





-

Re:Displaying a bitmap in a CView ..

"Jeff Partch" <jeffp@mvps.org>wrote in



Quote


It may exist, but is the call to LoadBitmap successful? I think you

need to pass your module's HINSTANCE to LoadBitmap. The NULL value is

used for predefined system bitmaps.



Well duh ..



Everything works now. That is what I get for using code snippets from

MS examples ..



Thankx







-