15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Grid Control with bitmaps

Leonard V. -- lvp01@mhs.sperry-marine.com
Wednesday, May 22, 1996

Platform: VC++ 4.0/Win NT

I am using the OLE OCX CGridCtrl and would like to put a bitmap in a 
cell.

Background: 
I went to the component gallery and inserted the OLE OCX CGridCtrl into 
my application. The component gallery inserted font.cpp, picture.cpp, and 
gridctrl.cpp into my project and it inserted an icon into the resource 
editor toolbox for the grid. In the resource editor I created a dialog, 
put a grid on the dialog, and pulled up the ClassWizard to create a class 
derived from CFormView to display the dialog containing the grid. I then 
added some code to OnInitialUpdate to put text into some cells, added an 
event sink map (via ClassWizard) to detect row/column clicks and rebuilt 
the app. Everything worked great. I went to the online help in the 
component gallery for the grid and on the first page it states that text 
OR bitmaps may be inserted into grid cells (the search was on), but 
nowhere in this online help does it instruct how to insert a bitmap. In 
gridctrl.cpp I found the function SetPicture(LPDISPATCH) that I thought 
might do it but I didn't know how to load LPDISPATCH with a bitmap. I 
searched through every directory under MSDEV, every piece of 
documentation supplied by Microsoft, the entire MFC documentation set, 
the VC++ on-line help, all OLE samples, both CD's of the Microsoft 
Developer Network April 1996 edition, and the latest FAQ that I had, and 
Kruglinski's Visual C++ 4.0 of which he has some CGridCtrl examples, but 
nowhere did I find a reference to SetPicture or otherwise how to put a 
bitmap into grid cell! 

Do you know how to put a bitmap into a grid cell?




Phil -- PhilW@micronetics.com
Wednesday, May 29, 1996

[Mini-digest: 3 responses]

What you need to do is create a picture object and then pass the dispatch to that
picture object into the grid control.  A picture object can hold icons and metafiles as
well as bitmaps.  You can also supply a palette for the bitmap if you like.  This example
creates a picture object for bitmap with no palette.

	LPDISPATCH	disp = NULL;

	PICTDESC pdesc;	
	pdesc.cbSizeofstruct = sizeof(pdesc);
	pdesc.picType = PICTYPE_BITMAP;
	pdesc.bmp.hbitmap = (HBITMAP)bitmaphandle;
	pdesc.bmp.hpal = NULL;
	
	OleCreatePictureIndirect( &pdesc, IID_IDispatch,
		                          FALSE, (LPVOID*)&disp);

	GridControl.SetPicture(disp);
	disp->Release();

Hope this helps.
Phil.
philw@micronetics.com

-----From: Gabriel Parlea-Visalon 

See KB: C and Visual C++: How to Set the Picture Property of an OLE control.
-- 
                             Gabriel Parlea-Visalon
                               Software Engineer
                           Derivative Trading Systems
                           gabriel@derivs.demon.co.uk
-----From: dobrin@itls.com

Buy Objective Grid from Stingray. It is 399$ and it gives you the 
source cod, so you can recompile the libaries whenever you want. The 
package has good samples and it is not difficult to use. And it is 
MFC code, not OCX or anything else. Demos are available from STINGRAY 
in Yahoo.

Dan Dobrin





| Вернуться в корень Архива |