Pelles C forum

C language => User contributions => Topic started by: DMac on July 16, 2009, 02:52:22 AM

Title: Data Grid View
Post by: DMac on July 16, 2009, 02:52:22 AM
Hello all,

I finally polished off the data grid view.  One version of which can be found in the Pelles C Wiki.

It can be found with accompanying article (focusing on writing custom controls) at the code project.

Here's a Screen shot.

(http://www.codeproject.com/KB/winsdk/Win32_SDK_data_grid/Figure1.png)


Win32 SDK Data Grid View Made Easy (http://www.codeproject.com/KB/winsdk/Win32_SDK_data_grid.aspx)

I simplified the code for this version of the control and improved keyboard and mouse handling.

Regards,
DMac
Title: Re: Data Grid View
Post by: JohnF on July 16, 2009, 10:09:53 AM
That's good DMac.

One small quibble - when resizing the control you move the grid control by using

rect.left += 80;

This is not relevant when the user has a different DPI setting, better to use SetWindowPos() API with the SWP_NOMOVE flag set, just resize it without moving it.

John
Title: Re: Data Grid View
Post by: DMac on July 16, 2009, 05:58:07 PM
John,

Thanks for the tip.

I played around with this and finally came up with:

Code: [Select]
void MainDlg_OnSize(HWND hwnd, UINT state, int cx, int cy)
{
RECT rcDlg, rcGrid;
GetClientRect(hwnd,&rcDlg);
GetClientRect(hList1,&rcGrid);
MapWindowPoints(hList1,hwnd,(LPPOINT)&rcGrid.left,2);

SetWindowPos(hList1,NULL,0, 0,rcDlg.right - rcGrid.left,
rcDlg.bottom - rcGrid.top,SWP_NOMOVE);
}
Title: Re: Data Grid View
Post by: JohnF on July 16, 2009, 06:36:04 PM
That works!

John
Title: Re: Data Grid View
Post by: nicolas.sitbon on July 16, 2009, 07:55:04 PM
Your code is not 64 bits compliant, for example GetWindowLong(), and the grid is buggy on 64 bits :
(http://img141.imageshack.us/img141/3545/sanstitrehra.jpg)
Title: Re: Data Grid View
Post by: MrBcx on July 17, 2009, 02:46:00 AM
Hello all,
http://www.codeproject.com/KB/winsdk/Win32_SDK_data_grid.aspx (http://www.codeproject.com/KB/winsdk/Win32_SDK_data_grid.aspx)

David ... thanks for the honorable mention in the code project article. ;D

Kevin Diggins
~MrBcx~
Title: Re: Data Grid View
Post by: JohnF on July 17, 2009, 07:12:56 PM
Your code is not 64 bits compliant, for example GetWindowLong(), and the grid is buggy on 64 bits :

Did you find the reason that it is buggy on 64bits apart from the GetWindowLong() API?

John
Title: Re: Data Grid View
Post by: DMac on July 17, 2009, 08:14:50 PM
Nicolas,

I'm currently not working in 64 bits so any suggestions for improvement are helpful.

The screenshot actually hilights an issue from John's post.  My screen resolution is different and my lazy coding technique caused the wrong position of the control in the demo on his screen.  I'll update the demo with the proper technique and repost it.

Kevin,

BCX is a wonderful coding tool.  I'm convinced that it is the quickest route to Win32 SDK development and understanding C.  It has greatly influenced my coding style.

Keep up the good work BCX team!

DMac 
Title: Data Grid View Updated
Post by: DMac on July 20, 2009, 05:53:17 PM
Pelles C forum,

I updated the DataGridView based on some of the feedback I'm getting and reposted the article and source.

The control now supports Unicode and should work fine with Win64.  In addition to this, I improved the way the control handles the Edit box after the grid has been scrolled and the edit box ends up off screen.  Now the control behaves in a manner similar to Excel.

Regards,
DMac
Title: Re: Data Grid View
Post by: JohnF on July 20, 2009, 06:27:59 PM
David, you need to do more work for it to compile for UNICODE.

John
Title: Re: Data Grid View
Post by: DMac on July 22, 2009, 05:24:18 PM
The Demo app is now Unicode friendly along with the control.   ::)
Title: Re: Data Grid View
Post by: Seltsamuel on July 23, 2009, 01:55:36 PM
Hi,

is this Data Grid View capable of displaying only 1 Column holding clickable imagebuttons? As i see it scrolls when there is more Content than fitting on screen so this would be a solution for my Problem here: http://forum.pellesc.de/index.php?topic=2925.0

Thanks

Seltsamuel
Title: Re: Data Grid View
Post by: DMac on July 23, 2009, 05:35:07 PM
You would be better off simply using the list view and adapting it to your needs.

This grid is geared toward editing tabular data.

regards,
DMac