|
-
October 17th, 2011, 09:27 AM
#1
Create Combobox with ToolTips
Hi everyone,
I must create a Combobox having ToolTips. I saw this article http://www.codeguru.com/cpp/controls...icle.php/c4949 but it seems not working.
Tooltip text and its combo item must be different.
Someone could help me?
Thank you
-
October 18th, 2011, 09:13 AM
#2
Re: Create Combobox with ToolTips
What "seems not working"?
Victor Nijegorodov
-
October 18th, 2011, 02:33 PM
#3
Re: Create Combobox with ToolTips
 Originally Posted by VictorN
What "seems not working"?
PreSubclassWindow() is not automatically called, for this reason m_lstCombo is not initialized and also CreateEx() has wrong arguments.
Also creating MyPreSubclassWindow() [equal to PreSubclassWindow()], my application crashes when I try to create m_lstCombo.
-
October 18th, 2011, 03:00 PM
#4
Re: Create Combobox with ToolTips
 Originally Posted by symreds
PreSubclassWindow() is not automatically called, for this reason m_lstCombo is not initialized and also CreateEx() has wrong arguments.
Also creating MyPreSubclassWindow() [equal to PreSubclassWindow()], my application crashes when I try to create m_lstCombo.
- What type of application are you using (dialog, SDI, MDI, ...)?
- How do you create this combobox: in a resource editor or dynamically using Create/CreateEx (if dynamically - show your code)
- how did you implement the PreSubclassWindow call?
- What is the exact error message for 'CreateEx() has wrong arguments" and how do you call this CreateEx?
Victor Nijegorodov
-
October 19th, 2011, 02:24 AM
#5
Re: Create Combobox with ToolTips
1 Dialog called in a MDI application
2 Resource Editor
3 I've just created a method having the same code of PreSubclassWindow() and I've called it.
4 m_lstCombo.CreateEx( 0, WC_LISTVIEW, NULL, dwStyle, rc, this, 0 ); [from TooltipComboBox.cpp]
while
CListCtrl::CreateEx( In_ DWORD dwExStyle, _In_ DWORD dwStyle, _In_ const RECT& rect, In_ CWnd* pParentWnd, _In_ UINT nID); [from afxcmn.h]
-
October 19th, 2011, 02:32 AM
#6
Re: Create Combobox with ToolTips
 Originally Posted by symreds
...
4 m_lstCombo.CreateEx( 0, WC_LISTVIEW, NULL, dwStyle, rc, this, 0 ); [from TooltipComboBox.cpp]
while
CListCtrl::CreateEx( In_ DWORD dwExStyle, _In_ DWORD dwStyle, _In_ const RECT& rect, In_ CWnd* pParentWnd, _In_ UINT nID); [from afxcmn.h]
1. What does the list view control class WC_LISTVIEW have to do with the combobox? 
2. You haven't answered my questions 3 and 4. If you are not going to show your actual code and error messages then don't expect any real help.
3. Please, use Code tags while posting code snippets.
Victor Nijegorodov
-
October 19th, 2011, 03:12 AM
#7
Re: Create Combobox with ToolTips
1 I don't know, I only reported the call made in CTooltipComboBox class found at that link (that is different to CListCtrl::CreateEx).
2 I answered to your questions.
2.3) I created a dummy method equal to CTooltipComboBox::PreSubclassWindow(). It was just a way to force PreSubclassWindow, that is an "event method" that should be automatically called during CTooltipComboBox creation but it doesn't. Forget this part.
2.4) Error code is ...\tooltipcombobox.cpp(100): error C2660: 'CListCtrl::CreateEx' : function does not take 7 arguments. This is due to the fact that in that class CreateEx has 7 paramaters, while CListBox::CreateEx has 5 (as I shown).
3 Sorry, but I don't see a button to add code quotes. Is this syntax correct?: <Code> example </Code>
Last edited by symreds; October 19th, 2011 at 03:14 AM.
-
October 19th, 2011, 03:30 AM
#8
Re: Create Combobox with ToolTips
 Originally Posted by symreds
...
2 I answered to your questions...
You didn't.
I asked you to post your actual code (snippet), not a part of a line without any context.
 Originally Posted by symreds
Error code is ...\tooltipcombobox.cpp(100): error C2660: 'CListCtrl::CreateEx' : function does not take 7 arguments. This is due to the fact that in that class CreateEx has 7 paramaters, while CListBox::CreateEx has 5 (as I shown).
And how does this line 100 (and some others above and below it) look like? 
 Originally Posted by symreds
Sorry, but I don't see a button to add code quotes. Is this syntax correct?: <Code> example </Code>
No, this syntax is wrong.
Please, read what you had to read before doing any post here: Announcement: Before you post....
Victor Nijegorodov
-
October 19th, 2011, 03:39 AM
#9
Re: Create Combobox with ToolTips
Code:
void CTooltipComboBox::PreSubclassWindow()
{
CRect rc( 0, 0, 10, 10 );
DWORD dwStyle = WS_POPUP | WS_BORDER | LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_SINGLESEL | LVS_OWNERDATA;
m_lstCombo.CreateEx( 0, WC_LISTVIEW, NULL, dwStyle, rc, this, 0 ); // row 100, m_lstCombo is CTooltipListCtrl object, where class CTooltipListCtrl : public CListCtrl.
DWORD dwStyleEx = m_lstCombo.GetExtendedStyle( );
m_lstCombo.SetExtendedStyle( dwStyleEx | LVS_EX_FULLROWSELECT );
m_lstCombo.Init( this );
CRect rcAll;
GetDroppedControlRect( &rcAll );
GetWindowRect( &rc );
SetDroppedWidth( rcAll.Width( ) );
SetDroppedHeight( rcAll.Height( ) - rc.Height( ) );
CComboBox::PreSubclassWindow( );
EnableToolTips( );
}
PreSubclassWindow() is not called => m_lstCombo is not initialized => calling CTooltipComboBox::SetItemTip() my application crashes
Code:
int CTooltipComboBox::SetItemTip( int nRow, CString sTip )
{
return m_lstCombo.SetItemTip( nRow, sTip );
}
Last edited by symreds; October 19th, 2011 at 04:02 AM.
-
October 19th, 2011, 04:00 AM
#10
Re: Create Combobox with ToolTips
What is CTooltipComboBox? how is it declared?
What is m_lstCombo and which CreateEx method is used? Is it CTooltipListCtrl method?
Victor Nijegorodov
-
October 19th, 2011, 04:13 AM
#11
Re: Create Combobox with ToolTips
In the first message of this thread I posted this link, telling that is not working: http://www.codeguru.com/cpp/controls...icle.php/c4949
at the end of the article there's a download part, where we can download CTooltipComboBox.cpp, CTooltipComboBox.h, CTooltipListCtrl.cpp and CTooltipListCtrl.h files.
I'm trying to use that two classes, but I have the problems I described.
-
October 19th, 2011, 04:25 AM
#12
Re: Create Combobox with ToolTips
I'm not going to download this code and then test it and compare with rgese couple of line you have posted.
It is very clear that if your code doesn't compile (as you stated in the post#7) it cannot run and therefore cannot produce any crash.
If it does compile then what does your post#7 mean? 
If we ignored this post#7 and suggested that your code compiles and links but then
 Originally Posted by symreds
PreSubclassWindow() is not automatically called
then I'd say you implemented it wrong.
Besides:
Also creating MyPreSubclassWindow() [equal to PreSubclassWindow()], my application crashes when I try to create m_lstCombo.
What is MyPreSubclassWindow? What does "[equal to PreSubclassWindow" mean in this context? How is this function called? 
How exactly does your app "crash"?
Victor Nijegorodov
-
October 19th, 2011, 04:43 AM
#13
Re: Create Combobox with ToolTips
The code we can download does not compile because m_lstCombo.CreateEx() has 7 parameters instead of 5. For this reason I changed the code in this way
Code:
m_lstCombo.CreateEx( 0, dwStyle, rc, this, 0 );
then in my program I declared the object in this way:
Code:
CTooltipComboBox *pCombo = (CTooltipComboBox*)GetDlgItem(IDC_... ); // IDC_... resource ID of my combo
when I do
Code:
pCombo->SetItemTip(iCount, strTips);
my application crashes. Call stack: m_lstCombo is not inizialized.
I searched where m_lstCombo should be created (CTooltipComboBox::PreSubclassWindow()) => put a breakpoint inside it => PreSubclassWindow() is never called.
I tryed to create a public method (CTooltipComboBox::MyPreSubclassWindow()) with the same code of PreSubclassWindow() and I called it after pCombo definition => application crashes in
Code:
m_lstCombo.CreateEx( 0, dwStyle, rc, this, 0 );
in particular it crashes here:
Code:
BOOL CListCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID)
{
// initialize common controls
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_LISTVIEW_REG));
CWnd* pWnd = this;
return pWnd->Create(WC_LISTVIEW, NULL, dwStyle, rect, pParentWnd, nID); // here
}
-
October 19th, 2011, 05:07 AM
#14
Re: Create Combobox with ToolTips
Remove your MyPreSubclassWindow.
Implement the virtual PreSubclassWindow but do it correctly! usually you should use ClassWizard (in VC6 or VS2010) or some similar tool in other IDEs
Victor Nijegorodov
-
October 19th, 2011, 05:19 AM
#15
Re: Create Combobox with ToolTips
...but virtual PreSubclassWindow is already implemented in the code we download. I don't know how to do it "correctly".
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|