- 论坛徽章:
- 39
|
- if(((LPNMHDR)lParam)->code == NM_DBLCLK)
- {
- int nItem, nSubItem;
- LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE)lParam;
- RECT rect;
- //Get the row number
- nItem = temp->iItem;
- //Get the Column number
- nSubItem = temp->iSubItem;
- if (/*nSubItem == 0 || */nSubItem == -1 || nItem == -1)
- {
- return FALSE;
- }
-
- char text[255]={0};
- memset(&LvItem,0,sizeof(LvItem));
- LvItem.mask=LVIF_TEXT;
- LvItem.iSubItem=nSubItem;
- LvItem.pszText=text;
- LvItem.cchTextMax=256;
- LvItem.iItem=nItem;
- SendMessage(hList,LVM_GETITEMTEXT, nItem, (LPARAM)&LvItem);
- char text2[255]={0};
-
- RECT rect1,rect2;
- ListView_GetSubItemRect(hList,nItem,nSubItem,LVIR_BOUNDS,&rect);
- // sprintf(text2,"rect,rect.left:%d,rect.right:%d,rect.top:%d,rect.bottom:%d",rect.left,rect.right,rect.top,rect.bottom);
- // MessageBox(NULL,text2,"rect",MB_OK);
- //Get the Rectange of the List Control
- GetWindowRect(temp->hdr.hwndFrom,&rect1);
- // sprintf(text2,"rect1,rect1.left:%d,rect1.right:%d,rect1.top:%d,rect1.bottom:%d",rect1.left,rect1.right,rect1.top,rect1.bottom);
- // MessageBox(NULL,text2,"rect1",MB_OK);
- //Get the Rectange of the Dialog
- GetWindowRect(hWnd, &rect2);
- // sprintf(text2,"rect1,rect2.left:%d,rect2.right:%d,rect2.top:%d,rect2.bottom:%d",rect2.left,rect2.right,rect2.top,rect2.bottom);
- // MessageBox(NULL,text2,"rect2",MB_OK);
- int x = rect1.left - rect2.left;
- int y = rect1.top - rect2.top;
- HWND hEdit = GetDlgItem(hWnd, IDC_INPUT);
- //SetWindowPos(hEdit,HWND_TOP,rect.left+x,rect.top+4,rect.right-rect.left-3,rect.bottom-rect.top-1,NULL);
- SetWindowPos(hEdit,HWND_TOP,rect.left+x,rect.top+14*2+7,rect.right-rect.left-3,rect.bottom-rect.top-1,NULL);
- ShowWindow(hEdit, SW_SHOW);
- SetFocus(hEdit);
- //Draw a rectangle around the SubItem
- Rectangle(GetDC(temp->hdr.hwndFrom), rect.left,rect.top-1,rect.right,rect.bottom);
- //Set the listItem text in the EditBox
- SendMessage(hEdit,WM_SETTEXT, 0, (LPARAM)"aaaaaa");
- }
复制代码 y的位置不好算。。SubItem == 0 的时候,选择变成了整行的了,这个需要注意 |
|