Home > Software engineering >  Why is my COMBOBOX how are created to invoke the Create not successful
Why is my COMBOBOX how are created to invoke the Create not successful

Time:09-21

Int CAddressBar: : OnCreate (LPCREATESTRUCT LPCREATESTRUCT)
{
If (CPanel: : OnCreate (lpCreateStruct)==1)
return -1;

//TODO: here to add your special creation code
if (! M_imgTool. The IsNull ()) return 0;
M_imgTool. LoadFromResource (AfxGetInstanceHandle (), IDB_TOOLBAR);


If (m_btnGo. M_hWnd) return 0;
If (m_addressComboBox. M_hWnd) return 0;

CRect rcClient;
GetClientRect (rcClient);
M_addressComboBox. Create (WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN | CBS_HASSTRINGS | CBS_OWNERDRAWVARIABLE,
CRect (5, 5, rcClient Width () - 22, 200), and this, 10001);
M_btnGo. Create (NULL, _T (" "), WS_CHILD | WS_VISIBLE, CRect (rcClient. The Width () - 22, 11, rcClient. The Width (), 39), and this, 10002);
M_btnGo. SetImage (IDB_COMBOBOX_GO);
return 0;
}


It is the code that is what problem? Pray god help
M_addressComboBox. Create (WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN | CBS_HASSTRINGS | CBS_OWNERDRAWVARIABLE,
CRect (5, 5, rcClient Width () - 22, 200), and this, 10001);

CodePudding user response:

CBS_OWNERDRAWVARIABLE, there must be

//Derived class is responsible for implementing these handlers
// for the owner/self the draw controls (except for the optional called DeleteItem)
Void CComboBox: : DrawItem (LPDRAWITEMSTRUCT)
{ASSERT (FALSE); }
Void CComboBox: : MeasureItem (LPMEASUREITEMSTRUCT)
{ASSERT (FALSE); }
Int CComboBox: : CompareItem (LPCOMPAREITEMSTRUCT)
{ASSERT (FALSE); return 0; }

CodePudding user response:

reference 1st floor schlafenhamster response:
CBS_OWNERDRAWVARIABLE, there must be a

//Derived class is responsible for implementing these handlers
// for the owner/self the draw controls (except for the optional called DeleteItem)
Void CComboBox: : DrawItem (LPDRAWITEMSTRUCT)
{ASSERT (FALSE); }
Void CComboBox: : MeasureItem (LPMEASUREITEMSTRUCT)
{ASSERT (FALSE); }
Int CComboBox: : CompareItem (LPCOMPAREITEMSTRUCT)
{ASSERT (FALSE); return 0; }

I added the ah

CodePudding user response:

You construct a CComboBox object in two steps. The First call the constructor, then call Create, which creates the Windows combo box and attaches it to the CComboBox object.

CodePudding user response:

I put the code to a friend after he compiled using VS2012 running on his computer COMBOBOX is to create success! I use VS2008 exactly is this why??????? Who can tell me!!!!!!!!!!!

CodePudding user response:

When something goes wrong "retry" stop watch

CodePudding user response:

In VS 2008 debugging, hang where

CodePudding user response:

Whether to call the initialization

CodePudding user response:

Why you want to have this CBS_OWNERDRAWVARIABLE? Custom painting?

CodePudding user response:

Choose custom painting attributes to overloading DrawItem () function

CodePudding user response:

The original poster to solve no, hope to share!

CodePudding user response:

In the new construction compiled through, in the original project debugging through, but can't run, meet the same problem
  • Related