Originally posted by: Fischer
IDC_IPEDIT is for a identifier. Where get I a unique idenitfier?
ReplyOriginally posted by: Chirag Bindal
COMBOBOXEXITEM cbItem;
Any comments from anyone would help.
The drop down control in the list box works wonderfully. I'd also like the drob down list to have icons. So I tried to use CComboBoxEx instead, ie, I derive InPlaceList from CComboBoxEx. Since AddString doesn't work with CComboBoxEx, I replaced it with InsertItem. When SetFocus is called for InPlaceList in its OnCreate handler, the control directly goes to OnKillFocus handler and the dropdown list is not shown. This is my code inside OnCreate:
cbItem.mask = CBEIF_IMAGE|CBEIF_SELECTEDIMAGE|CBEIF_TEXT;
cbItem.cchTextMax = 0; // is ignored
cbItem.iItem = -1; // insert at end
for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;)
{
//AddString((LPCTSTR)(m_lstItems.GetNext(pos))) ;
CString strText = (LPCSTR)m_lstItems.GetNext(pos);
cbItem.pszText = strText.GetBuffer(strText.GetLength());
InsertItem(&cbItem);
strText.ReleaseBuffer();
}
SetCurSel(m_nSel);
SetFocus();
Thanks!
Originally posted by: Jim Garnett
I needed both these features (edit and combo box). It would've taken me weeks to figure it out by myself.
ReplyOriginally posted by: cyber_being
Hi done some changing to the code in
CMyListCtrl::ShowInPlaceList because I didn't like the
combobox overlapping the subitem below it i found the rect
round the subitem before but can't recall it now i know it
is a CListCtrl function that return the rect or you give it
a param to the rect to fill. I also change the call to
CComboBox::Create() to take the new rect coords but only
the listbox of the combobox resize and drop down only about
4 pixels. here the code
CComboBox* CMyListCtrl::ShowInPlaceList( int nItem, int nCol,
CStringList &lstItems, int nSel )
{
//old way to find rect for the combobox
//new way to find rect for the combobox
CRect newrect;//used in Create() below
//Now here find the sub item where the combox will be shown when unexpanded(combobox's listbox not shown).
//Now combobox should fit in the same sub item rect and not overlap others in the list
//new way to find rect for the combobox
DWORD dwStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL
|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL;
CComboBox *pList = new CInPlaceList(nItem, nCol, &lstItems, nSel);
pList->Create( dwStyle, /*rect*//*old*//*newrect*//*new*/, this, IDC_IPEDIT );
pList->SetItemHeight( -1, height);
pList->SetHorizontalExtent( GetColumnWidth( nCol ));
//pList->//Maybe Add more CComboBox code that will help
return pList;
}
Originally posted by: Daniel
I have a trouble with writing code for shellexe.
I have an "Edit Box", called "Grade_Student_ID" (defended as m_ Grade_Student_ID), and I need to get the value from the Edit Box and display on Webpage.
The code I have put is so far:
but, obviously it does not work.
Please let me know how to correct it.
Sincerely,
Daniel
Hi,
siofile.WriteString("<center><Table border=1 width=50%>");
// Make table
siofile.WriteString("<TR>");
sColName = "Student ID";
sColName.MakeLower();
sLetter = sColName[0];
sLetter.MakeUpper();
sColName.SetAt(0,sLetter[0]);
siofile.WriteString("<TD BGCOLOR=#D9D9F3 TEXT=#996600>");
siofile.WriteString("<b>" "Student ID Number" "</B>");
siofile.WriteString("<TD BGCOLOR=#D9D9F3 TEXT=#996600>");
// Get the value from Edit box
//???????????????
CString csValue;
sColName =GetWindowText(m_Grade_Student_ID, csValue);
// int nLength = m_Grade_Student_ID.GetLength();
siofile.WriteString("<b>" + sColName + </B>"); ////////???????????????????????????????????????
// siofile.WriteString("<b>" +sColName+ "</B>");
siofile.WriteString("</TD>");
siofile.WriteString("</TR>");
////////////////////////////////////////////////////////////////////////////////////////////////
Originally posted by: Andrew Skowronski
1)Scroll bars on drop down - I didn't need them because
Function to change is ShowInPlaceList()
Instead of using:
I just use:
2) When the list control was scrolled or the columns
For example:
In message map of list control:
New method:
Then you need to do similar fix to the ShowInPlaceList
This code replaces the for loop:
ASSERT( nColumnCount <= MAX_NUM_COLUMNS );
int offset = 0;
I love this tip, but I had to make a few enhancements to
the basic idea.
I only have a few items and I know they will always fit:
WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL
|WS_HSCROLL|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL;
WS_BORDER|WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST;
sorted I got a ugly UI glitch if the drop down was
"alive". The popdown kills itself if it loses focus,
however it seems that sorting or scrolling does not
automatically change the focus back to the list control.
Maybe there is an easier way, but I found that I had
to handle the WM_HSCROLL, WH_VSCROLL and HDN_ITEMCLICK
messages.
ON_WM_VSCROLL()
void MyCtrl::OnVScroll( UINT nSBCode,
UINT nPos,
CScrollBar* pScrollBar )
{
SetFocus();
CListCtrl::OnVScroll( nSBCode, nPos, pScrollBar );
}
3) Reordered columns. If the user drags columns to a new
ordering the popup will be drawn in the wrong place.
First you need to fix HitTestEx, I wrote a seperate
comment about that:
(/mfc/comments/6921.shtml)
method:
int aColumnOrder[ MAX_NUM_COLUMNS ];
VERIFY( ListView_GetColumnOrderArray(GetSafeHwnd(),
nColumnCount,
aColumnOrder) );
int index = 0;
while( aColumnOrder[ index ] != nCol )
{
offset += GetColumnWidth( aColumnOrder[ index ] );
index++;
}
Originally posted by: Daniel Chiaramello
Please, could someone give me a clue on what is the best
visual way to let the user know that this column hides a
dropdown list, and is not something purely static?
Thanks! :
Originally posted by: Brian Bailey
I have implemented all of the previous suggestions regarding the CBS_DROPDOWN style. The control appears to be working in most respects, except:
When I click on the listview item and the edit portion of the control appears, and if I then click on another item in the listview, the first edit control does not disappear.
Additionally, if I click on the listview item and the edit portion of the control appears, and if I then click on another control in my frame window (e.g., a toolbar button), the edit control does not disappear.
Everything works fine if I click on the dropdown button to display the dropdown list. When I click on other items, the dropdown list and edit control disappear properly.
I'm sure someone's fixed this already. Can someone please post their fix?
UPDATE: I see what I've done wrong. A previous post indicated that the SetFocus() function that was used within OnCreate() caused some problems. I had removed the SetFocus() call, so the new control was displayed, but never had the focus. When I clicked on another item, the dropdown control never received the WM_KILLFOCUS message because it never had the focus to begin with. Putting this function call back in solved the problem.
ReplyOriginally posted by: DongDong
Solving:
I just programed a project with this article. The code is
very smart,but I found I can edit label after clicked row
item, and I don't want this function.
Response LVN_BEGINEDITLABEL and add some code:
LV_ITEM *pItem = pDispInfo->item;
if(pItem->iSubItem == 0)// label
pResult == 1;
else
pResult == 0;
Originally posted by: John Phelps
CInPlaceList::OnKillFocus is stated to send a notification message to the parent of the ListControl. I am however finding that the messages are trapped in the CMyListCtrl class and do not reach the view or dialog class that the list control is placed in.
Ideally I need to trap this message to inform the user of changes in the document data and to update the document data.
Has anyone managed to allow the messages to reach the "host" view or dialog class ?
Has anyone else had similar problems with the WM_NOTIFY message not reaching the "host" ?
Any help would be most appreciated ?
Reply