|
Hi Darkoman,
That's me again. Now I have probably simple problem, but I can't solve it. I have created simple application with main window and status bar. In a workspace between menu and statusbar Grid is located. Now, when window is resized then Grid is also resized, but it overlaps with status bar or there is a space between them. Any suggestion to solve this problem??
Regards
WojciechW
|
|
|
|
|
if debug,it has no error.But I built it in release."remove all",then duobled click on datagrid control,then it pop out a error"unknow software exception(0c0000094)".
|
|
|
|
|
Hi I'm using your grid in my application, and as others have said, thanks for all your hard work. I'm making some modifications (as my application is slightly odd) and am trying to implement Hidden Rows, i.e. I've added an attribute to each row which when set the row is not redrawn, instead the next one is (unless that is hidden, and so on). Frankly, as I'm not an expert Windows programmer, I'm having trouble! Perhaps this is something you would consider adding yourself?
Also I noticed a problem where the vertical scroll bar "bounces" when dragged to the bottom. This seems to fix it:
case SB_THUMBTRACK:
{
RECT rowRect, clientRect, columnRect;
GetRowRect( hwnd, 0, &rowRect );
GetColumnRect( hwnd, 0, &columnRect );
GetClientRect( hwnd, &clientRect );
clientRect.top = columnRect.bottom;
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
GetScrollInfo( hwnd, SB_VERT, &si );
int OldPos = si.nPos;
int NewPos = si.nTrackPos;
// Rick these two lines cause the vertical scrollbar bounce
// which occurs when the scroll bar is dragged to the bottom
//int diff = NewPos % (rowRect.bottom-rowRect.top-1);
//NewPos -= diff;
si.nPos = NewPos;
si.nTrackPos = NewPos;
SetScrollPos( hwnd, SB_VERT, NewPos, TRUE );
InvalidateRect( hwnd, NULL, TRUE );
UpdateWindow(hwnd);
Any comments?
--Ricko
|
|
|
|
|
Hello, thanks if you find it usefull. Yes, I can do this small fix in the next two or three days so I will post an update.
Best regards...
|
|
|
|
|
Wow - that'd be great!
FYI the issues I've identified are:
(1) when the user clicks on a row to select it, converting the click position to the correct row given that there may be hidden rows. For example,
Row 1,2,3,8,9,10 are displayed (rows 4,5,6,7 are hidden)
Click on the 4th visible row, that means that row 8 has been selected.
(2) The vertical scrollbar must be resized depending on the number of visible rows
(3) Select Next/Prev must select the Next / Prev visible row
(4) When the currently selected row is hidden, it needs to be "un-selected"
(5) EnsureRowVisible needs to take account of hidden rows
Items (1) and (5) have got me stumped.
Item (2) required that a count is kept of the number of visible rows as well as the total number of rows. Keeping this in sync is a bit nasty when rows are added, removed, hidden and unhidden.
I look forward to the update! Thanks.
--Ricko
|
|
|
|
|
Nice work, you got my 4. Not many are willing to do this kind of thing in Win32; even fewer are willing to share their code for free. Love the grid, but I have a few suggestions for you. Ignore these if you've heard them before.
- Try drawing only those cells that are visible. You can greatly speed up the responsiveness of the grid when there are 500+ cells.
- Try to implement more functions as windows messages. This would make wrapping your control in an MFC, WTL, or other object windows environment much easier.
- Provide a UNICODE implementation. I see an earlier post suggesting this; you're right, it is simple to do.
- Consider XP theming. It's very easy to implement and adds a lot of visual bang for the buck.
- Build yourself a way of subclassing the edit box and any other controls you wish to use for editing the grid. This way you can catch things like the Enter, Escape, and Tab keys and perform appropriate actions in the grid.
- Implement a handler for WM_GETDLGCODE. This way users putting your grid in a dialog can still get the standard behavior for any keyboard input on the grid.
Thanks again for your hard work, I appreciate it.
Sharpmike
|
|
|
|
|
Hello, thanks for these very good sugestions. I am going to implement most of these things in the next release of the DataGrid. Now, I am on the secret SWF-PROJECT (not present here on CodeProject), so it will take some time.
Considering cell drawing, well, only visible cells are drawn on the screen, otherwise if there are more then 500 cells it would be a problem. I am performing that kind of calculation before I do any drawing.
Best regards...
|
|
|
|
|
Hi Darkoman,
Your control is really cool, and up to now it work without any problems. But I need some additional functionalities:
1. would it be possible to change a colour of only one cell?
And now more complicated things:
2. would it be possible to select a block of cells?
3. and maybe also to set a border for cell/block of cells?
I know, it looks like a wish list...;)
Regards
WojciechW
|
|
|
|
|
Hello...
thanks for you comment. Now, it wont be difficult to change the color of the single cell, but your next two requests ask for some additional time I must find to make it work in the way you like it. Hope to do it soon...
Regards...
|
|
|
|
|
Hi darkoman,
thanks for fast reply. I wait for improvements I have ordered...;)
Regards
WojciechW
|
|
|
|
|
Hi Darkoman - nice piece of work. I have your grid working quite will in a test harness.
When I put the class into my MFC Doc/View, the SDI client window does not draw the grid. I know everyhting is working, because if I Create() the datagrid using the MainFrm (toolbar/status bar etc) as parent, I can see it drawing in the menu bar and status bars, well some of it anyway.
But when I set the CMyView.m_hWnd as parent on call to CDataGrid::Create() - nada drawing in the SDI client.
Can you kindly suggest what I might be missing?
int CTestGridView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
RECT rect = {50,50,700,300};
m_DG.Create( rect, m_hWnd, 5 );
};
void CTestGridView::OnInitialUpdate()
{
// Set dummy DataGrid column info, then
CView::OnInitialUpdate();
}
void CTestGridView::OnDraw(CDC* pDC)
{
CTestGridDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//nothing here since grid get WM_DRAW messages first as child. yes???
}
Many thanks
Luke
(may the source be with you)
|
|
|
|
|
Hello...
you can put your creation code in OnInitialUpdate member function of the CView derived class and process WM_SIZE message of the main window (can be done also in CView derived class) calling Resize() member of the CDataGrid control.
You should see the grid drawing in the client area of the window.
Regards...
|
|
|
|
|
Thanks, darkoman.
Yes that's right, I have it working now. Also, I wrote some extra code to callback the CMyView each time a Row is drawn, so the view can terminate the redraw.
This assists my application where I am using the CDataGrid to display time-stamped incoming messages from the serial port. The redraw operation should not slow down my application, so that is why I did this. After some quiet time I call back and complete the draw.
Regards
Luke
(may the source be with you)
|
|
|
|
|
Hi,
I wanna develope a program and i use VC++ + win32 and i really need a cool data grid. so after many search i found yours. but it seems that it has many bugs and doesn't support unicode! (i tested it). can you help me. is there any component like that (free one ) to help me or can we have a cooperation to edit it?
Best Wishes - Mohammad
mghalambor at gmail.com
|
|
|
|
|
Thank you for your interest.
Yes, this control did have some bugs but they were fixed...
Now, I am sure that a similar thing can be found on the Internet (CodeProject or CodeGuru, maybe?), but if you are really interested in I am willing to help you develop a better-looking data grid control.
PS.
To get UNICODE work should not be so hard:
1) Hard-coded strings should be changed from "some_text" to _T("some_text")
2) All functions like e.g. strlen() should be written like e.g. _tcslen()
3) Also, fonts should be used that have different character-set mappings (e.g. don't use font like System, but like TimesNewRoman or Arial)
4) For UNICODE project compiling UNICODE pre-processor directive should be defined and not MBCS (Check on CodeProject or MSDN for details)
Best regards,
Darkoman
|
|
|
|
|
Hi darkoman,
Thank u for your fast reply.
yes, i am so interested in your component and i hope to have no problem with that.
is the last version of it (already in code project) without bug?
why can't i have a grid with less than 6 rows!!!?
Best Wishes - Mohammad
|
|
|
|
|
Hello...
well, I hope it is. If you find one, please tell me.
I didn't understand exactly the last thing you have written. I have downloaded the code and
chanded the number of created rows in WM_CREATE event of WndProc function of the main window
(I have put just 1 row) and everything went well.
So, please explain more...
Best regards,
Darkoman
|
|
|
|
|
When you select one cell to edit ,and then you click the "remove all" button, then the selected cell still appear the contents you inputed.
|
|
|
|
|
Was away for a while...
It will be soon repaired and working...
Thanks!
|
|
|
|
|
The code as presented here does not work. Just because it seems to compile does not mean it is stable. You use variables without initializing them, you use short variables to store long values, column resizing is prone to errors, cell editing does not work, etc.
While most code has some bugs that may only show up in certain unusual circumstances, this code has so many bugs that pop up with just a cursory test. The fact that it generates 28 warnings when compiled at warning level 4 should be enough of a clue that there is something wrong.
Your idea seems nice, and the grid looks good, but the code needs a lot of work.
1
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Yes, it probably doesn't but...
Try again these days...
Thanks for comment!
|
|
|
|
|
Another bug: Select collumn 0 to sort, then select collumn 1 to sort, then select collumn 0 to sort again: Access violation error - read of address 00000818. Great beginning to a useful item, though.
As far as the first bug that Kochise illuminated: you don't even have to select between collumn 0 and 1: simply resize collumn 1 to a negative width and collumn 0 becomes __*very*__ wide. Placing a 'minWidth' variable in would fix this behavior.
David
|
|
|
|
|
It will be repaired and will work...
Thanks!
|
|
|
|
|
it seems good in look.
but when i test it, the screen refresh a lot.
|
|
|
|
|
7 warnings, from 'unreferenced local variables' to... err... 'not all control paths return a value' !
Select between Column0 and Column1, then drag the limit completely on the left, before Column0 (width == 0).
Select between Column1 and Column2, then drag the limit completely on the left, before Column0 (width == -width Column0).
Sort the lines with clicking the following clomuns header in the following order :
Column0 6 times
Column1
Column2
Column1
Column0
The message grid don't automatically scroll down when too much messages comes.
Would like to see a tree on Column0 if I want...
Beside all of this, you get my 4. Right now I suspend my vote, I'd like to give you a 5 Thanks for updating things... And debug more carefully, please :/
Kochise
In Code we trust !
|
|
|
|
|