Pelles C forum

C language => User contributions => Topic started by: DMac on October 24, 2007, 08:33:58 PM

Title: Simple DataGridView custom control for Pelles C
Post by: DMac on October 24, 2007, 08:33:58 PM
The attached project demonstrates how to create a simple custom control in Pelles C (simple as in not drawing everything from scratch).  I wanted an editable list view and threw in some other customizations as a bonus.  The header file contains macroes for each custom message that demonstrate the usage of the messages.  Also many ListView related messages can be used with this control (all list view messages are forwarded to the list view component.)
Title: Re: Simple DataGridView custom control for Pelles C
Post by: Stefan Pendl on October 24, 2007, 09:37:08 PM
That is really useful 8)

Thanks for sharing ;D
Title: Re: Simple DataGridView custom control for Pelles C
Post by: JohnF on October 25, 2007, 07:39:20 AM
I get an error when compiling

---------------
DataGridView.c(1354): error #3114: [asm] Invalid combination of opcode and operands.
*** Error code: 1 ***
---------------

Any ideas on how to correct that?

edit:

OOPS, I didn't have the latest PellesC.

Anyway, nice contribution, thanks.

John
Title: Re: Simple DataGridView custom control for Pelles C
Post by: DMac on October 25, 2007, 06:28:47 PM
Stephan,
Glad you find this useful.

John,
Surprisingly, most of the time I spent on this was getting the scrolling to work right.  I ended up having to store scroll info in my struct instead of using GetScrollInfo() it seems that once the scroll bars disappear the control's scroll info is cleared.

DMac
Title: Re: Simple DataGridView custom control for Pelles C
Post by: JohnF on October 25, 2007, 10:40:10 PM
Quote from: DMac on October 25, 2007, 06:28:47 PM
John,
Surprisingly, most of the time I spent on this was getting the scrolling to work right.  I ended up having to store scroll info in my struct instead of using GetScrollInfo() it seems that once the scroll bars disappear the control's scroll info is cleared.

DMac

I've used GetScrollInfo a few times but I don't know what you mean by 'scroll bars disappear'. However you seem to have managed it fine.

John
Title: Re: Simple DataGridView custom control for Pelles C
Post by: DMac on October 25, 2007, 11:59:41 PM
QuoteI've used GetScrollInfo a few times but I don't know what you mean by 'scroll bars disappear'.

Here's the scenario,

1.  User scrolls the control to the last collumn.

2.  User then chooses to stretch window to see all grid.

3.  Scroll bars go away because the window size is greater than the page size.
Unfortunately the window might not be aligned with the Grid.

At this point I want to pan the view so that the top left of the grid is the top left of the control but unfortunately GetScrollInfo() returns an empty structure.

The solution was to store the scroll info independent of the Control's window.
Title: Re: Simple DataGridView custom control for Pelles C
Post by: JohnF on October 26, 2007, 07:36:52 AM
Ok I see now. I guess the best way is to scroll the window as the user is stretching so that when the scroll bar finally disappears the window is in the right place.

Btw, I had to adjust MainDlg_OnSize() as the buttons were encroaching on the grid, I use 120 DPI screen setting.

John