A basic grid control (major revision)
A basic grid control (major revision)
Hi all,
I've been playing around with some intriguing code posted by El-choni some time ago, and have hashed up a basic grid control based on a subclassed ListIconGadget.
I've decided to post the code at what is a very early stage of development in order that more experienced Windows coders might be able to give me some idea as to how far this code can go? Basically, this is approaching the limits of my knowledge of Win API at present and so I don't really know just how far this could be taken, let alone how far I could take it myself.
At the moment, the underlying ListIconGadget is created in the default report view with the default system fonts. Cells can be edited by double clicking. The control seems to behave itself whilst scrolling and whilst the user changes the column widths etc.
As I say, it is early days, but everyone is welcome to use the code in any way.
Regards.
http://www.purecoder.net/purebasic/egrid.zip
I've been playing around with some intriguing code posted by El-choni some time ago, and have hashed up a basic grid control based on a subclassed ListIconGadget.
I've decided to post the code at what is a very early stage of development in order that more experienced Windows coders might be able to give me some idea as to how far this code can go? Basically, this is approaching the limits of my knowledge of Win API at present and so I don't really know just how far this could be taken, let alone how far I could take it myself.
At the moment, the underlying ListIconGadget is created in the default report view with the default system fonts. Cells can be edited by double clicking. The control seems to behave itself whilst scrolling and whilst the user changes the column widths etc.
As I say, it is early days, but everyone is welcome to use the code in any way.
Regards.
http://www.purecoder.net/purebasic/egrid.zip
Last edited by srod on Fri Sep 30, 2005 8:37 pm, edited 3 times in total.
I may look like a mule, but I'm not a complete ass.
Update:
http://www.purecoder.net/purebasic/egrid.zip
- - The grids now seem to work with different fonts and font sizes in that there is no misalignment (at least on my system) with the cell being edited etc. Cells are edited by overlaying a good old string gadget and the alignment of the underlying text and all the margins has caused me a few headaches. It now seems to work on my computer, but I am hoping that others might be able to test this on different Windows setups etc.
-The enter key now acts as it should.
http://www.purecoder.net/purebasic/egrid.zip
I may look like a mule, but I'm not a complete ass.
The height of the header row is a superficial detail.
Can I ask what you did to end up with 2 edit boxes because I can't seem to recreate it?
Thanks.
**Edit: It seems to occur when the ListIcon gadget is scrolled by using the keyboard and thus avoiding the #WM_VCROLL event in the ListIcon callback. I'll try and fix it tonight. Thanks for reporting, as this one would probably have passed me by!**
Can I ask what you did to end up with 2 edit boxes because I can't seem to recreate it?
Thanks.
**Edit: It seems to occur when the ListIcon gadget is scrolled by using the keyboard and thus avoiding the #WM_VCROLL event in the ListIcon callback. I'll try and fix it tonight. Thanks for reporting, as this one would probably have passed me by!**
I may look like a mule, but I'm not a complete ass.
This might help

Code: Select all
Procedure LV_SetHeaderFontStyle(id.l)
LF.LOGFONT
hHeader = SendMessage_(id, #LVM_GETHEADER, 0, 0)
hCurrFont = SendMessage_(hHeader, #WM_GETFONT, 0, 0)
If GetObject_(hCurrFont, SizeOf(LF), LF) > 0
LF\lfWeight = #FW_BOLD ;#FW_NORMAL
LF\lfUnderline = #True
LF\lfItalic = #True
LF\lfStrikeOut = #False
LF\lfHeight = 20
DeleteObject_(hHeaderFont)
hHeaderFont = CreateFontIndirect_(LF)
hOldFont = SelectObject_(hHeader, hHeaderFont)
SendMessage_(hHeader, #WM_SETFONT, hHeaderFont, #True)
EndIf
EndProcedure
UPDATE:
After many long hours, the scrolling problems seem to be fixed and I cannot find any rendering problems at the moment (although I have only tested this software on Win XP home).
If I am correct and no one finds any bugs with the basic operation of the grid control, then the way is clear to add more of what I would call typical 'grid' functionality.
At the moment, the grid seems to work with any fontsize (I haven't adjusted the header row yet, but that's a minor detail). The grid allows editing in any cell and (fingers crossed) behaves well whilst the grid is scrolled (either using the mouse or the keyboard) or columns are resized etc.
If no bugs are found with the above, I will then set about the following:
Anyhow, any feedback/bug reports are greatly appreciated and my thanks to all who are able to test the grids.
Regards.
http://www.purecoder.net/purebasic/egrid.zip
After many long hours, the scrolling problems seem to be fixed and I cannot find any rendering problems at the moment (although I have only tested this software on Win XP home).
If I am correct and no one finds any bugs with the basic operation of the grid control, then the way is clear to add more of what I would call typical 'grid' functionality.
At the moment, the grid seems to work with any fontsize (I haven't adjusted the header row yet, but that's a minor detail). The grid allows editing in any cell and (fingers crossed) behaves well whilst the grid is scrolled (either using the mouse or the keyboard) or columns are resized etc.
If no bugs are found with the above, I will then set about the following:
- tidying up the header row
allowing for dynamic resizing of the entire grid
use of arrow / tab keys to navigate the grid (at the moment they scroll the entire grid without navigating from cell to cell -this was a convenience)
cutting and pasting
etc.
Anyhow, any feedback/bug reports are greatly appreciated and my thanks to all who are able to test the grids.
Regards.
http://www.purecoder.net/purebasic/egrid.zip
I may look like a mule, but I'm not a complete ass.
srod,
The updated grid works well, but I have found a problem. Try these steps:
1. Click in a cell to select it.
2. Click in the cell again to start editing it - you will see the caret flashing.
3. Scroll the grid up and down a few times using the mouse wheel, not the scroll bar.
4. I see a number of copies of the selected cell, on top of other cells.
If you click in one of the copies, it goes back to the original cell contents.
Can you (or anyone else) reproduce this behavior, or is it just a problem with my mouse or video drivers?
Regards,
Eric
The updated grid works well, but I have found a problem. Try these steps:
1. Click in a cell to select it.
2. Click in the cell again to start editing it - you will see the caret flashing.
3. Scroll the grid up and down a few times using the mouse wheel, not the scroll bar.
4. I see a number of copies of the selected cell, on top of other cells.
If you click in one of the copies, it goes back to the original cell contents.
Can you (or anyone else) reproduce this behavior, or is it just a problem with my mouse or video drivers?
Regards,
Eric
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
other controls within individual cells, but that's a little way off yet.

https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Ebs:
Thanks for the report. Unfortunately, I use a laptop and do not have a mouse wheel. The problem reported is the same that I experienced with the page up/down buttons however, and these were easily fixed. It could simply be a case of rummaging through the WIN API looking for some event I can trap for use of the mousewheel. If I am right, then it is literally 5 lines of code to repair. Unfortunately, however, I won't know if the problem is fixed until someone with a mouse wheel tests the code.
I'll have a look later tonight.
Thanks again.
Thanks for the report. Unfortunately, I use a laptop and do not have a mouse wheel. The problem reported is the same that I experienced with the page up/down buttons however, and these were easily fixed. It could simply be a case of rummaging through the WIN API looking for some event I can trap for use of the mousewheel. If I am right, then it is literally 5 lines of code to repair. Unfortunately, however, I won't know if the problem is fixed until someone with a mouse wheel tests the code.
I'll have a look later tonight.
Thanks again.
I may look like a mule, but I'm not a complete ass.
***Fix***
Have added code (3 lines!) which I hope fixes the aforementioned problem. I am unable to check whether the fix works because I have no mousewheel.
If someone could be so kind...
http://www.purecoder.net/purebasic/egrid.zip
Thanks.
Have added code (3 lines!) which I hope fixes the aforementioned problem. I am unable to check whether the fix works because I have no mousewheel.
If someone could be so kind...
http://www.purecoder.net/purebasic/egrid.zip
Thanks.
I may look like a mule, but I'm not a complete ass.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
I cannot see any graphic problems with the scroll wheel.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system