NO

Author Topic: Babygrid flickers when navigating with keys or clicking  (Read 4322 times)

mennowo

  • Guest
Babygrid flickers when navigating with keys or clicking
« on: June 01, 2013, 02:16:17 AM »
Hello,
just started using Babygrid, and it works really well. I find it easy to implement and change layout etc.
I noticed, when navigating the control, that it is redrawn completely each time I either click or use keys the mouse to navigate, which causes a flicker. This as opposed to the behaviour while scrolling, which is really smooth. I'm wondering if anyone else has this kind of issue? I tried to isolate where in the code this happens but could not find the right place.
Kind regards!
Menno

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Babygrid flickers when navigating with keys or clicking
« Reply #1 on: June 01, 2013, 08:24:48 AM »
Another grid here
May the source be with you

mennowo

  • Guest
Re: Babygrid flickers when navigating with keys or clicking
« Reply #2 on: June 03, 2013, 04:34:48 PM »
Thank you for your reply. I tried the other grid before also, but thought it was harder to implement. Looking into a little further now I succeeded in doing more or less the same as with Babygrid, and I changed the layout according to my needs. With this grid the painting is much more smooth.

I did find that page-up and page-down are not handled in the way I was expecting (the seem to move to the top or bottom of the control instead of moving the scrollbar one page), but have not yet been able to find a solution. Anyhow I will look into handling of click and key events so it will suit what I am looking for.

In case anyone is interested I am happy to share my changes and extensions of the code.

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Babygrid flickers when navigating with keys or clicking
« Reply #3 on: June 03, 2013, 05:10:15 PM »
In case anyone is interested I am happy to share my changes and extensions of the code.

That would be great!  There is a feature on Code Project that allows members to post alternative projects to the original.  Look at the side bar for the link: "Add your own alternative version."  You could post a write up of the improvements with the source code and then post a link to your improvements in the user contributions forum here as I have done for the original.
No one cares how much you know,
until they know how much you care.

mennowo

  • Guest
Re: Babygrid flickers when navigating with keys or clicking
« Reply #4 on: June 05, 2013, 11:44:17 PM »
Ok will do that later on!

Meanwhile I have managed to handle pageup and pagedown the way I want to.
Now I'm trying to get into edit mode for a cell with a single mouse click. I'd like to be able to edit the contents of a cell after a single click, always. So if another cell is being edited, it'd be best for me if that cell looses focus, storing whatever value is in the edit box inside the appropriate listbox entry, and then starting to edit the newly clicked cell.
However, I cannot really get my head around how things work internally with the notify messages.

Inside Grid_OnNotify() I added "NM_RCLICK == pnm->code", like this (around line 1150):

Code: [Select]
else if (ID_LISTVIEW == id)
{
if (NM_DBLCLK == pnm->code || NM_RCLICK == pnm->code || NM_CLICK == pnm->code || LVN_COLUMNCLICK == pnm->code)
return Grid_OnMouseClick(hwnd, pnm);
else
return FALSE;
}

After this change, the right mouse button does show the behaviour I want...
Anyone has an idea as to how to pinpoint where to change this?
Actually I would also like to be able to scroll while a cell is being edited, but that might proof difficult, since it would involve moving the edit box up and down. So first things first :-).

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Babygrid flickers when navigating with keys or clicking
« Reply #5 on: June 09, 2013, 11:35:12 AM »
Test this:
DataGridView.c
line 1023
Code: [Select]
if (NM_DBLCLK == pnm->code || NM_CLICK == pnm->code|| NM_SETFOCUS == pnm->code)and line 1070
Code: [Select]
if (NM_DBLCLK == pnm->code || NM_CLICK == pnm->code || LVN_COLUMNCLICK == pnm->code || NM_SETFOCUS == pnm->code)
May the source be with you

czerny

  • Guest
Re: Babygrid flickers when navigating with keys or clicking
« Reply #6 on: June 09, 2013, 12:04:59 PM »
Try to edit cell in col1/row2 and press enter multiple times --> other cells (in row1) will be updated.
There is no logic in what is next cell after enter.
Sometimes edit field is in the header.

mennowo

  • Guest
Re: Babygrid flickers when navigating with keys or clicking
« Reply #7 on: June 26, 2013, 10:42:42 PM »
Thanks for the replies. I was on vacation, hence a rather slow follow-up.

@timovjl: thanks, this works: when clicking another cell, it immediately has the edit mode.

@czerny: I experience the same behaviour: when clicking on what is supposedly the row header for the second row (first one if using column headers), then pressing enter, the behaviour is rather weird. Also I am able to edit the contents of the row headers...
Anyway I experience weird behaviour now when in edit mode and pressing enter multiple times. Maybe it's due to successive small changes I made.
Will try to resolve this.

I have two more things I'd like to alter about the behauviour of the control:
- First is to be able to use the scroll wheel while in edit mode. As a user I'd expect this to work, then when pressing a key the control could jump back to the edited cell. When clicking a different cell, that could get focus.
- Second: when in edit mode, scrolling down with the arrow keys goes one at a time, and pagedown etc don't work; I'd like the behaviour of these keys to be about the same as when not in edit mode...
Maybe both come down to the same question: how to pass messages delivered to the edit box on to the list control. Then also: how to update the edit box appropriately...

Any help or ideas really welcome!

mennowo

  • Guest
Re: Babygrid flickers when navigating with keys or clicking
« Reply #8 on: July 02, 2013, 10:44:13 PM »
Hello,

meanwhile I more or less resoved most of the things I came accross.

One rather stubborn aspect: with expanding of the last column enabled, when I resize the columns, the last column and editor window will only adjust once the mouse comes off the headers again and onto the listview. I understand why this is (only then is the WM_SETCURSOR message dispatched), but I would really like to have the sizes adjust once I release the mouse button.

I tried coupling the resizing to the WM_LBUTTONUP event, but to no avail. Maybe this has to do with the fact that listview headers are internally actually seperate controls?
Any ideas on how to resolve this issue?

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Babygrid flickers when navigating with keys or clicking
« Reply #9 on: July 03, 2013, 05:17:57 PM »
I remember that WM_SETCURSOR trick, I felt rather clever at the time I realized I could abuse it to signal a resize of the editor. 8)

I'm several years removed from that project but you might look at subclassing the header and handling the mouse events in the headers callback.
No one cares how much you know,
until they know how much you care.