mity / mctrl

C library providing set of additional user interface controls for Windows, intended to be complementary to standard Win32API controls from USER32.DLL and COMCTL32.DLL.
http://mctrl.org
235 stars 52 forks source link

Edit Label on DblClick #49

Closed Bugzero71 closed 7 years ago

Bugzero71 commented 7 years ago

Hi Martin, It is really tedious for me to implement in each NM_DBLCLICK notification message:

{
  NMHDR* hdr = (NMHDR*)lParam;
  if (wParam >= IDC_WATCH_GRID)
  {
    switch (hdr->code)
    {
    case NM_DBLCLK:
      {
        MC_GRECT rect;
        MC_GSELECTION selection;

        selection.rcData = ▭
        selection.uDataCount = 1;

        if (::SendMessage(hdr->hwndFrom, MC_GM_GETSELECTION, 0, (LPARAM)&selection) != 0)
        {
           ::PostMessage(hdr->hwndFrom, MC_GM_EDITLABEL, MAKEWPARAM(rect.wColumnFrom, rect.wRowFrom), 0);
        }

        *pResult = 0;
    return TRUE;
}

So I propose you to modify grid.c line 2880

  mc_send_notify(grid->notify_win, grid->win, NM_DBLCLK);

with these lines:

  if (mc_send_notify(grid->notify_win, grid->win, NM_DBLCLK)) {
    /* Application suppresses the default processing of the message */
    return;
  }

  /* Edit cell if MC_GS_EDITLABELS is set */
  if (grid->style & MC_GS_EDITLABELS) {
    MC_GHITTESTINFO info;

    info.pt.x = x;
    info.pt.y = y;
    grid_hit_test(grid, &info);

    grid_start_label_edit(grid, info.wColumn, info.wRow);
}

I've checked them in my project and in example_grid but possibly I'm missing something.

mity commented 7 years ago

I remember the logic was implemented to follow listview in this regard (and it was inspired by Wine's listview implementation). But it's true that for grid your proposition may make sense, as it's likely much less likely that application wants to hook a different action on a double-click.

I'll think about it.

mity commented 7 years ago

Done.