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

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


Grid Control

5YB JAN MICHAEL MUNCH KNUDSEN -- 5YB@dmumsmailgw.aarhues.dk
Wednesday, April 17, 1996


MFC/VC++ 4.0 Win95

I have a 'simple' problem -  How to set the propyty of a grid control (from 
vc's own ocx) to edit fields,
so it is possible to type text in the fields?

Thank you

     Michael



Joe Ficara -- joef@kofax.com
Friday, April 19, 1996

     You may be supprised to here this but YOU CANT EDIT FIELDS IN THE 
     MICROSOFT GRID CONTROL OCX!! I assumed the same thing you did, its a 
     grid control and the great thing about grid controls is they let the 
     user enter lots of info in a small amount of screen relistate, however 
     after much tinkering and talking with Microsoft, the only way to edit 
     data in a grid control is to create this functionality manually.  
     There are several options (none simple and easy).  You can put a edit 
     control at the row and column the user clicks upon, you can write your 
     own edit functionality supporting all of the nasty editing stuff 
     (insert, delete arrow control ect..), you may even be able to 
     "subclass" (or OLE speak extend through aggregation "good luck!") the 
     existing OCX  and extend its functionality or you can buy a OCX which 
     supports this functionality.
     
     Sorry...
     


______________________________ Reply Separator _________________________________
Subject: Grid Control
Author:  mfc-l@netcom.com at Internet
Date:    4/17/96 2:33 PM


Received: by ccmail from sandy.kofax.com
>From @netcom18.netcom.com:owner-mfc-l@netcom.com 
X-Envelope-From: @netcom18.netcom.com:owner-mfc-l@netcom.com
Received: from netcom18.netcom.com by sandy.kofax.com id aa24582;
          19 Apr 96 4:51 PDT
Received: (from daemon@localhost) by netcom18.netcom.com (8.6.13/Netcom)
    id VAA15718; Thu, 18 Apr 1996 21:03:33 -0700
From: 5YB JAN MICHAEL MUNCH KNUDSEN <5YB@dmumsmailgw.aarhues.dk> 
To: MFC list 
Subject: Grid Control
Date: Wed, 17 Apr 96 14:33:00 PDT
Message-Id: <3175676F@msmailgw.aarhues.dk> 
Encoding: 10 TEXT
X-Mailer: Microsoft Mail V3.0
Sender: owner-mfc-l@netcom.com
Precedence: list
Reply-To: mfc-l@netcom.com  
MFC/VC++ 4.0 Win95
     
I have a 'simple' problem -  How to set the propyty of a grid control (from 
vc's own ocx) to edit fields,
so it is possible to type text in the fields?
     
Thank you
     
     Michael
     



GERARD LIM -- GERARDLIM@ych.com
Thursday, October 31, 1996


Environment: Windows NT 4.0 Workstation, MSVC 4.1

I am trying to add a grid into a dialog.  When I try to 'drag and drop' the
grid control from the toolbar, I get the message:

 "The OLE control "Grid Control" could not be instantiated because it
requires design-time license"

I have the same problem with some other controls e.g. Key State Control,
Microsoft Multimedia Control etc.

I have already included the file GRID32.OCX in my project.  Can anyone
help me or point me in the right direction, please?




Robert H. Mowery III -- rmowery@csci.csc.com
Thursday, October 31, 1996

[Mini-digest: 5 responses]

It sounds like you are missing the license file associated with the
controls.  I would try re-installing you MSVC since these are standard
controls that ship with it and either something did not install properly or
a file got trashed.  While this may not effect the VC++ install, I usually
shut down all applications and this includes MS Office toolbars and
anything else that could effect the install.  

Other than that I am not sure what could be occuring but others may have
some ideas.  

-Robert Mowery 

----------
> From: GERARD LIM 
> To: Mircosoft Foundation Class 
> Subject: Grid Control
> Date: Thursday, October 31, 1996 2:34 PM
> 
> 
> Environment: Windows NT 4.0 Workstation, MSVC 4.1
> 
> I am trying to add a grid into a dialog.  When I try to 'drag and drop'
the
> grid control from the toolbar, I get the message:
> 
>  "The OLE control "Grid Control" could not be instantiated because it
> requires design-time license"
> 
> I have the same problem with some other controls e.g. Key State Control,
> Microsoft Multimedia Control etc.
> 
> I have already included the file GRID32.OCX in my project.  Can anyone
> help me or point me in the right direction, please?
> 
-----From: jeremy@omsys.com (Jeremy H. Griffith)

See KBase article Q151804:Dynamic Creation of Redistributable Control,
available at:
  http://www.microsoft.com/kb/developr/visual_c/q151804.htm
which directly addresses this issue.

--Jeremy
-----From: Rob Tessier 

Apparently you are not a licenced developer of that OCX and this OCX enforces 
the optional licensing checks.

You need to obtain a licensed copy from the OCX provider which will contain the 
.LIC file.

[Moderator's note: He is talking about an OCX that comes *with*
VC++.  You'd think they would license everyone for these controls.]
-----From: GERARD LIM 

I have the same problem with some other controls e.g. Key State Control,
Microsoft Multimedia Control etc.

I have already included the file GRID32.OCX in my project.  Can anyone
help me or point me in the right direction, please?

-----From: "Colurcio Massimo" 

Old VBX use something like a .LIC file that contains design-time license.
For OCX too? I mean you must verify.




Louis de Beer -- dbeerlj@mwp.eskom.co.za
Monday, December 02, 1996

Environment : MSVC 4.2b + Win95

Hi there

I need to implement a grid control in my program.  I have
only very recently started using MFC, and I don't really
know how OLE works.
I managed to get the grid displayed on the form, but I
cannot get any data in the cells.

I looked at the following function which is part of the
GRIDCTRL files, but I don't know how the VARIANT data type
is used :

short CGridCtrl::AddItem(LPCTSTR Item, const VARIANT&
Index)
{
	short result;
	static BYTE parms[] =
		VTS_BSTR VTS_VARIANT;
	InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2,
(void*)&result, parms,
		Item, &Index);
	return result;
}

Help would be much appreciated...

LdB



P. Senthil -- senthilp@geocities.com
Wednesday, December 04, 1996

I guess you would'nt want to know how to handle VARIANT's after you see
the definition.

Check up the Grid control's documentation for all functions as VARIANT
is a huge union. You can generally pass LPCSTR or the like for most
functions in the Grid control if you're using Microsoft's.

Here goes the definition:

typedef struct FARSTRUCT tagVARIANT VARIANT; 
typedef struct FARSTRUCT tagVARIANT VARIANTARG; 
 
typedef struct tagVARIANT  { 
	VARTYPE vt; 
	unsigned short wReserved1; 
	unsigned short wReserved2; 
	unsigned short wReserved3; 
	union { 
		unsigned char	bVal;			/* VT_UI1				*/ 
		short			iVal;			/* VT_I2					*/ 
		long			lVal;			/* VT_I4					*/ 
		float			fltVal;			/* VT_R4					*/ 
		double			dblVal;			/* VT_R8					*/ 
		VARIANT_BOOL		bool;			/* VT_BOOL				*/ 
		SCODE			scode;			/* VT_ERROR				*/ 
		CY				cyVal;			/* VT_CY					*/ 
		DATE			date;			/* VT_DATE				*/ 
		BSTR			bstrVal;			/* VT_BSTR				*/ 
		Iunknown			FAR* punkVal;	/* VT_UNKNOWN			*/ 
		Idispatch		FAR* pdispVal;	/* VT_DISPATCH			*/ 
		SAFEARRAY		FAR* parray;		/* VT_ARRAY|*			*/ 
		unsigned char	FAR *pbVal;		/* VT_BYREF|VT_UI1		*/ 
		short			FAR* piVal;		/* VT_BYREF|VT_I2		*/ 
		long			FAR* plVal;		/* VT_BYREF|VT_I4		*/ 
		float			FAR* pfltVal;	/* VT_BYREF|VT_R4		*/ 
		double			FAR* pdblVal;	/* VT_BYREF|VT_R8		*/ 
		VARIANT_BOOL		FAR* pbool;		/* VT_BYREF|VT_BOOL		*/ 
		SCODE			FAR* pscode;		/* VT_BYREF|VT_ERROR		*/ 
		CY				FAR* pcyVal;		/* VT_BYREF|VT_CY		*/ 
		DATE			FAR* pdate;		/* VT_BYREF|VT_DATE		*/ 
		BSTR			FAR* pbstrVal;	/* VT_BYREF|VT_BSTR		*/ 
		IUnknown FAR*	FAR* ppunkVal;	/* VT_BYREF|VT_UNKNOWN	*/ 
		IDispatch FAR*	FAR* ppdispVal;	/* VT_BYREF|VT_DISPATCH	*/ 
		SAFEARRAY FAR*	FAR* parray;		/* VT_ARRAY|*			*/ 
		VARIANT			FAR* pvarVal;	/* VT_BYREF|VT_VARIANT	*/ 
		void			FAR* byref;		/* Generic ByRef			*/ 
	}; 
};

Louis de Beer wrote:
> 
>                            Postage paid by:
>                                [Image]
>                          Your Home on the Web!
> 
>     ---------------------------------------------------------------
> 
> Environment : MSVC 4.2b + Win95
> 
> Hi there
> 
> I need to implement a grid control in my program.  I have
> only very recently started using MFC, and I don't really
> know how OLE works.
> I managed to get the grid displayed on the form, but I
> cannot get any data in the cells.
> 
> I looked at the following function which is part of the
> GRIDCTRL files, but I don't know how the VARIANT data type
> is used :
> 
> short CGridCtrl::AddItem(LPCTSTR Item, const VARIANT&
> Index)
> {
>         short result;
>         static BYTE parms[] =
>                 VTS_BSTR VTS_VARIANT;
>         InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2,
> (void*)&result, parms,
>                 Item, &Index);
>         return result;
> }
> 
> Help would be much appreciated...
> 
> LdB

-- 
P. Senthil
-----------------------------------------------------------------------
1, 7th Avenue (West),
7th Main Road,
Dhandeeswaram Nagar,
Velachery,
MADRAS - 600 042.

Mail:  senthilp@geocities.com

Homepage: www.geocities.com/SiliconValley/Heights/6504



Per Clausen - PCL/TC/GBJ -- pclausen@grundfos.com
Wednesday, December 04, 1996

Environment : MSVC 4.2b + Win95

An easy way to set data is by using SetCol/SetRow and SetText. Here is an 
example:

Prototypes:
void CGridCtrl::SetCol(short propVal)
void CGridCtrl::SetRow(short propVal)
void CGridCtrl::SetText(LPCTSTR propVal)

{
   m_mygrid.SetRows(5);
   m_mygrid.SetCols(5);

   for (int iRow = 0; iRow < 5; iRow++)
      for (int iCol = 0; iCol < 5; iCol++)
      {
         strTmp.Format("%d:%d", iRow, iCol); 
         m_mygrid.SetRow(iRow);
         m_mygrid.SetCol(iCol);
         m_mygrid.SetText(strTmp);
      } 
}



I hope this helps !

Per Clausen

 




dobrin@itls.com
Wednesday, December 04, 1996

[Mini-digest: 4 responses]

Try using the Stingray Objective Grid. It is easy to use and does 
a lot of work for you.

I use it in the company for half a year and the only thing I can do is 
just recommend it. 

Dan.



> From:          "Louis de Beer" 
> To:            "MFC List" 
> Subject:       Grid control
> Date:          Mon, 2 Dec 1996 09:01:08 +0200
> Reply-to:      mfc-l@netcom.com

> Environment : MSVC 4.2b + Win95
> 
> Hi there
> 
> I need to implement a grid control in my program.  I have
> only very recently started using MFC, and I don't really
> know how OLE works.
> I managed to get the grid displayed on the form, but I
> cannot get any data in the cells.
> 
> I looked at the following function which is part of the
> GRIDCTRL files, but I don't know how the VARIANT data type
> is used :
> 
> short CGridCtrl::AddItem(LPCTSTR Item, const VARIANT&
> Index)
> {
> 	short result;
> 	static BYTE parms[] =
> 		VTS_BSTR VTS_VARIANT;
> 	InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2,
> (void*)&result, parms,
> 		Item, &Index);
> 	return result;
> }
> 
> Help would be much appreciated...
> 
> LdB
> 
Dan Dobrin
Intertrans Logistics Solutions Ltd.
Richmond Hill, CANADA
e-mail : dan.dobrin@itls.com
phone  : (905) 771-8088, ext.251
-----From: Shaju Mathew 

I'm assuming that the CGridCtrl is the generated class interface 
when you inserted the control into  your client app. I'm pretty 
sure that you'd not have to work on the VARIANT& parameter except
in the InvokeHelper(), which's already been taken care of..

	I've never worked with teh grid ctrl, but here's a sample
snippet of a test program that tries it out...from a CFormView-based
window

void CTestgridCtrlView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	m_GridCtrl.SetCols(4);

	m_GridCtrl.SetRows(5);

	m_GridCtrl.SetText("Junk");//you'll have to guess and do
//trial and error to see what these do..

	m_GridCtrl.Set_Text("junk1");

}

Good luck - give me a call if you need further help

> Environment : MSVC 4.2b + Win95
> 
> Hi there
> 
> I need to implement a grid control in my program.  I have
> only very recently started using MFC, and I don't really
> know how OLE works.
> I managed to get the grid displayed on the form, but I
> cannot get any data in the cells.
> 
> I looked at the following function which is part of the
> GRIDCTRL files, but I don't know how the VARIANT data type
> is used :
> 
> short CGridCtrl::AddItem(LPCTSTR Item, const VARIANT&
> Index)
> {
> 	short result;
> 	static BYTE parms[] =
> 		VTS_BSTR VTS_VARIANT;
> 	InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2,
> (void*)&result, parms,
> 		Item, &Index);
> 	return result;
> }
> 
> Help would be much appreciated...
> 
> LdB
> 


--
***********************************************************************
                              .---.         .---.
Shaju Mathew                 /" "  \  WWW  /  " "\    Off:(916)785-9018 
Performance Technology  Lab / / ""  \(*|*)/  "" \ \ 
Hewlett-Packard Company    //////   '. V .`   \\\\\\ Home:(916)722-4576
8000, Foothills Blvd      //// / // : """ : \\ \ \\\\
MS 5723, Roseville       // /   /  /`.""" '\  \   \ \\Fax:(916)785-1264
CA 95747-5723           //          //.".\\          \\
                     ------------- -UU---UU---------------
Shaju_Mathew@hp.com                '//|||\\`
                                     '' ``     
***********************************************************************
-----From: sathiya@colmds2.com (Sathiyamurthy Thiruvengadathan)

Louis de Beer wrote:
> 
> Environment : MSVC 4.2b + Win95
> 
> Hi there
> 
> I need to implement a grid control in my program.  I have
> only very recently started using MFC, and I don't really
> know how OLE works.
> I managed to get the grid displayed on the form, but I
> cannot get any data in the cells.
> 
> I looked at the following function which is part of the
> GRIDCTRL files, but I don't know how the VARIANT data type
> is used :
> 
> short CGridCtrl::AddItem(LPCTSTR Item, const VARIANT&
> Index)
> {
>         short result;
>         static BYTE parms[] =
>                 VTS_BSTR VTS_VARIANT;
>         InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2,
> (void*)&result, parms,
>                 Item, &Index);
>         return result;
> }
> 
> Help would be much appreciated...
> 
> LdB

GridCtrl exposes a function called SetText which takes an LPCTSTR as
parameter. Use this function to set the data in the cells. But before
calling this function you will have to set the current row and column by
calling SetRow() and SetCol() respectively. GridCtrl.h which comes when
you pick the grid control from component gallery contains all the
functions exposed by the Grid control. More info about the control can
be found in CtrlRef.hlp in your MSDEV\HELP directory. Hope this info
helps

Bye,
Sathya
-----From: Tom Allen 

Louis,

I use code similar to the following to populate a grid control:

	CGridCtrl	m_itemgrid;

	// tell the grid how many rows & columns
	m_itemgrid.SetCols(2);
	m_itemgrid.SetRows(nRows + 1);

	// set the width for each column
	m_itemgrid.SetColWidth(0, COLUMN0_WIDTH);
	m_itemgrid.SetColWidth(1, COLUMN1_WIDTH);

	// position the grid control to row 0, column 0 and fill the cell at =
that position
	m_itemgrid.SetRow(0);
	m_itemgrid.SetCol(0);
	m_itemgrid.SetText("Item ID");

	// position the grid to row 0, column 1, and fill the cell at that =
position
	m_itemgrid.SetCol(1);
	m_itemgrid.SetText("Artist");

	// ...and so on

Note that to populate a cell with numerics, you must first convert them =
to a text buffer and then use SetText().

Unfortunately, I found that when filling a grid with a large amount of =
data (8 columns x 5000 rows) using this method , the performance hit is =
rather unacceptable.  On my system (P133, 32 meg RAM, Win 95), =
populating the grid from a CObList collection takes better than 2 =
minutes!  But for smaller grids I've found the approach outlined above =
more than adequate.

I would also be interested in any documentation and/or sample code that =
explains using the AddItem method.  My suspicion is that this is =
probably a much faster way to populate the grid, but unfortunately I =
have been unable to find any further info regarding its use.  Any leads =
would be appreciated.

-TA

----------
From: 	Louis de Beer[SMTP:dbeerlj@mwp.eskom.co.za]
Sent: 	Monday, December 02, 1996 2:01 AM
To: 	MFC List
Subject: 	Grid control

Environment : MSVC 4.2b + Win95

Hi there

I need to implement a grid control in my program.  I have
only very recently started using MFC, and I don't really
know how OLE works.
I managed to get the grid displayed on the form, but I
cannot get any data in the cells.

I looked at the following function which is part of the
GRIDCTRL files, but I don't know how the VARIANT data type
is used :

short CGridCtrl::AddItem(LPCTSTR Item, const VARIANT&
Index)
{
	short result;
	static BYTE parms[] =3D
		VTS_BSTR VTS_VARIANT;
	InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2,
(void*)&result, parms,
		Item, &Index);
	return result;
}

Help would be much appreciated...

LdB






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