NO

Author Topic: Data Grid View  (Read 7531 times)

Offline DMac

  • Member
  • *
  • Posts: 258
Data Grid View
« 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.




Win32 SDK Data Grid View Made Easy

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

Regards,
DMac
« Last Edit: June 04, 2010, 05:26:59 pm by DMac »
No one cares how much you know,
until they know how much you care.

JohnF

  • Guest
Re: Data Grid View
« Reply #1 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

Offline DMac

  • Member
  • *
  • Posts: 258
Re: Data Grid View
« Reply #2 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);
}
No one cares how much you know,
until they know how much you care.

JohnF

  • Guest
Re: Data Grid View
« Reply #3 on: July 16, 2009, 06:36:04 pm »
That works!

John

nicolas.sitbon

  • Guest
Re: Data Grid View
« Reply #4 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 :

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 60
    • http://www.bcxgurus.com/
Re: Data Grid View
« Reply #5 on: July 17, 2009, 02:46:00 am »
Hello all,
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~

JohnF

  • Guest
Re: Data Grid View
« Reply #6 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

Offline DMac

  • Member
  • *
  • Posts: 258
Re: Data Grid View
« Reply #7 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 
No one cares how much you know,
until they know how much you care.

Offline DMac

  • Member
  • *
  • Posts: 258
Data Grid View Updated
« Reply #8 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
No one cares how much you know,
until they know how much you care.

JohnF

  • Guest
Re: Data Grid View
« Reply #9 on: July 20, 2009, 06:27:59 pm »
David, you need to do more work for it to compile for UNICODE.

John

Offline DMac

  • Member
  • *
  • Posts: 258
Re: Data Grid View
« Reply #10 on: July 22, 2009, 05:24:18 pm »
The Demo app is now Unicode friendly along with the control.   ::)
No one cares how much you know,
until they know how much you care.

Seltsamuel

  • Guest
Re: Data Grid View
« Reply #11 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

Offline DMac

  • Member
  • *
  • Posts: 258
Re: Data Grid View
« Reply #12 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
No one cares how much you know,
until they know how much you care.