Bonjour,

J'ai un CListCtrl éditable (code que j'ai récupéré sur internet). Il marche bien sauf que j'ai un tableau plutôt large avec un scroll horizontal et dès que j'essai d'éditer un élément à droite du tableau. Le scroll se remet alors à la position 0 et je ne vois plus la cellule que je suis en train d'éditer. Voici quelques morceaux de code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 
//----------------------------------------------
void ListCtrlStandard::OnLButtonDown(UINT nFlags, CPoint point){
  LVHITTESTINFO lvhit;
  lvhit.pt = point;
  int item = SubItemHitTest(&lvhit);
  if (item != -1 && lvhit.iSubItem && (lvhit.flags &
    LVHT_ONITEM )){
    if (m_subitem == lvhit.iSubItem && item == m_item){
      BaseList::OnLButtonDown(nFlags, point);
    }else{
      BaseList::OnLButtonDown(nFlags, point);
      m_subitem = lvhit.iSubItem;
      m_item = item;
      //int horzScrollPos = this->GetScrollPos(SB_HORZ);
      ////this->last //TODO je m'arrete la
      this->lastRightScrollPos = CSize(this->GetScrollPos(SB_HORZ), this->GetScrollPos(SB_VERT));
 
      //tagSCROLLINFO scrollInfo;
      //this->GetScrollInfo(SB_HORZ, &scrollInfo);
      //UINT nMask = scrollInfo.fMask;
      //scrollInfo.fMask = SIF_DISABLENOSCROLL;
      //this->SetScrollInfo(SB_HORZ, &scrollInfo);
      EditLabel(item);
      //this->Scroll(this->lastRightScrollPos);
      //this->Update(0);
      //this->SetScrollPos(SB_HORZ, horzScrollPos, TRUE);
      //this->Invalidate(TRUE);
      //this->RedrawItems(0, this->GetItemCount());
    }
  }else{
    BaseList::OnLButtonDown(nFlags, point);
  }
}
//----------------------------------------------
 
//----------------------------------------------
void ListCtrlStandard::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar){
  BaseList::OnHScroll(nSBCode, nPos, pScrollBar);
}
//----------------------------------------------
 
//----------------------------------------------
void ListCtrlStandard::OnLvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult){
  NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
  if(m_subitem > 1){
    //*
    this->editing = true;
    //this->SetScrollPos(SB_HORZ, this->lastRightScrollPos, TRUE);
    //int yScrollPos = this->GetScrollPos(SB_VERT);
    //CSize scrollPos(20, yScrollPos);
    //this->Scroll(scrollPos);
    ASSERT(m_item == pDispInfo->item.iItem);
    CRect subrect;
    GetSubItemRect(pDispInfo->item.iItem, m_subitem, LVIR_BOUNDS , subrect );
    HWND hWnd=(HWND)SendMessage(LVM_GETEDITCONTROL);
    ASSERT(hWnd!=NULL);
    VERIFY(m_editWnd.SubclassWindow(hWnd));
    m_editWnd.m_x=subrect.left + 6;
    m_editWnd.SetWindowText(GetItemText(pDispInfo->item.iItem,m_subitem));
    CRect rect;
    GetSubItemRect(pDispInfo->item.iItem,m_subitem,
    LVIR_LABEL ,rect);
    CDC* hDc = GetDC();
    hDc->FillRect(rect,&CBrush(::GetSysColor(COLOR_WINDOW)));
    ReleaseDC(hDc);
    //CSize scrollPos = CSize(this->GetScrollPos(SB_HORZ), this->GetScrollPos(SB_VERT));
    //if(this->lastRightScrollPos != scrollPos){
      //this->Scroll(this->lastRightScrollPos);
      //this->OnLvnBeginlabeledit(pNMHDR, pResult);
      //this->lastRightScrollPos = scrollPos;
    //}
    //*/
    /*
    ASSERT(m_item == pDispInfo->item.iItem);
               
    CRect  rcSubItem;
    GetSubItemRect(pDispInfo->item.iItem, m_subitem, LVIR_BOUNDS, rcSubItem);
               
    HWND hWnd= (HWND)SendMessage(LVM_GETEDITCONTROL);
    ASSERT(hWnd != NULL);
    VERIFY(m_editWnd.SubclassWindow(hWnd));
 
    m_editWnd.m_x = rcSubItem.left + 4;
    m_editWnd.SetWindowText(GetItemText(pDispInfo->item.iItem, m_subitem));
    //*/
 
    *pResult = 0;
  }else{
    *pResult = 1; ///With that we cannot edit the first column
  }
}
//----------------------------------------------
C'est au moment de l'appel de la fonction EditLabel que le scroll est remis au début. Quelqu'un sait comment je pourrai empêcher ce comportement?

Merci d'avance