Controls within a grid
Dennis Bowen -- dbowen@pamd.cig.mot.com
Tuesday, April 09, 1996
Environment: VC++ 4.1, Win95 ( not that it matters for this question )
I am looking for suggestions on how to implement a grid which contains
controls. An example of what I want is the register in Quicken. I
would like to have a dialog with, among other things, a scrolled window
child. This scrolled window would contain a grid, for lack of a better
word. Each line of the grid would contain several controls such as a
calendar control, regular combo boxes, and text fields. I would like it
to appear that there is an unlimited number of lines in the grid.
My specific questions are:
Can I do this with a regular scrolled window or do I need to find a
grid
control?
Are there any MFC samples which do something like this?
What kind of data structure should I use to keep track of all the lines
in the scrolled window? The user should be able to edit any previously
entered line.
A _brief_ overview of how I would accomplish this would be great.
Thanks
--
Dennis Bowen
dbowen@pamd.cig.mot.com
Jack Tackett -- tackett@nando.net
Thursday, April 11, 1996
> Dennis Bowen
> dbowen@pamd.cig.mot.com
Dennis, I don't have specific answers for you , but for a starter you
can track down a grid class released on the net - the file name is :
wcmfclib.zip
an archie search or a web search should find it, if not let me know and we'll
see what we can do.
If you have a vew $$$ to spare then you might want to check out the
products offered by farpoint - these are stand alone controls and not
very extensible but relatively easy to use.
But I'd recommend you check out stingray's objective grid. this is a complete
grid written in MFC - so you can modifiy it any way you see fit for your
applications. check out their web site for info:
http://landru.unx.com/~stingray/
Finally you can use the grid control which ships with VC++, its not the best
but is usuable - check out the checkbook sample application (Note I've
not used VC++4.X so dont know if this is still available). If you want to use
that control then you may want to check out my new book (shameless self
promotion here ) The MFC Windows Controls Construction Kit which shows
how to use the various controls found in windows applicaitons. check out
http://www.qsystems.net/tristar/tristar.htm
Hope this helps.
--Jack
Mike Zhang -- mikez@teleport.com
Thursday, April 11, 1996
[Mini-digest: 4 responses]
Hi,
In MSDN, there is a sample named: LISTDLG: Implements an Owner-Drawn List Box of Modeless
Dialog Boxes. Maybe it helps you. But it is written in SDK. I had just merge it into my MFC code.
Mike
-----From: John Moulder
Take a look at http://users.aol.com/chinajoe/wcmfclib.html. There is an MFC
grid control ther that may be of assistance.
-----From: Jeff Wilkins
Dennis,
My advice to you is to use a grid control. It should be much easier than
starting from scratch. The grid control you select may not provide all of
the capabilities you need to embed other controls (calendar for example) but
in the worst case you should be able to draw the required controls within
the appropriate cell of the grid yourself. The grid control should be able
to handle all the scrolling, column resizing, etc. that users have come to
expect from anything that looks remotely like a spreadsheet.
As far as data structures go, the grid control you select and the data
you wish to display in the grid should dictate the way in which you design
your structures.
I was faced with a similar requirement and purchased Datatable from
Protoview. It works pretty well for us, although the documentation leaves a
lot to be desired for an MSVC/MFC project. The documentation seems to be
directed at Borland C++ developers. I have not had much chance to play with
MSVC 4.x yet, but I thought there was a grid control that came with 4.x.
Good Luck,
Jeff Wilkins
jwilkins@autonet.net
-----From: "Mike Blaszczak"
> Environment: VC++ 4.1, Win95 ( not that it matters for this question )
Actually, it matters for this question (and matters for almost every
question). Since you're targeting Win95, you have to worry about the number
of controls you have created so that you don't end up depleting the system
resources available to you on the USER heap. If you were targeting only
WinNT, this would not be a concern. This fact would necessarily and radically
change your approach to the problem.
> Each line of the grid would contain several controls such as a
> calendar control, regular combo boxes, and text fields.
> I would like it o appear that there is an unlimited number of lines in the
grid.
You might want to rethink your user interface. It seems like you could
possibly come up with something that is just as functional but not quite as
involved.
>Can I do this with a regular scrolled window or do I need to find a
> grid control?
You can do it with a regular scrolled window. Any grid control you buy is,
after all, just a scrolled window with a lot of fancy painting. I've not
heard of a grid control that offers calendar controls in cells, but I believe
I remember seeing a control advertised that allowed cells to contain combo
boxes as well as letting them act as text fields. I think you should do some
research: tear through computer programmer software catalogs and magazines and
see what grid controls are available, send away for information on them, and
see if they do what you want.
> Are there any MFC samples which do something like this?
No, I don't think there are.
> What kind of data structure should I use to keep track of all the lines
> in the scrolled window? The user should be able to edit any previously
> entered line.
I guess I would use a templated CArray class. I would have it contain an
array of structures or object that I designed. Each structure or object would
just manage pointers to the control windows involved in that line of your
special control, and perhaps provide some method of creating, destroying, and
doing data exchange with the controls. I would use a CArray because you'll
want to access the control windows based on the index to which the user has
scrolled.
> A _brief_ overview of how I would accomplish this would be great.
Once you have this array in place, all you really need to do is work out
coordinate math to get the controsl created in the right place in the
scrollable window. I think you could make a regular CWnd as a child of your
dialog and have a scrollbar. In response to the scrollbar, you'll need to
SetWindowPos() on all of the items which are visible.
Maybe it is a good idea to size this CWnd so it only shows one row. That way,
you could effectively make the control fake the user out: the user _seems_ to
be scrolling over row after row of this code, but you actually just move data
around in the controls in the one visible row. That makes things simpler for
you (since you don't have to debug all sorts of coordinate arithmetic and you
won't have to slowly move dozens of windows at runtime). Even if you show
more than one row, you should try to apply some technique like this so you can
avoid creating so many windows that your scrolling bogs down and/or you eat up
all of the available system heap.
.B ekiM
TCHAR szSpringtime[] = _T("Check twice and safe a life: I don't speak
officially for Microsoft.");
Terry Peterson -- petersot@motsat.sat.mot.com
Tuesday, April 16, 1996
Dennis,
The wcmfclib.zip file containing the WorldCom MFC grid class can be found at:
http://users.aol.com/chinajoe/wcmfclib.html
Terry Peterson
| Вернуться в корень Архива
|