Home > Net >  Bottom coordinates of CListBox is not set correctly
Bottom coordinates of CListBox is not set correctly

Time:09-11

MFC beginner question.

I created a listbox and a button using CListBox::Create and CButton::Create respectively, using CRect for their size and location. The two CRect has the same height, but when they are shown in the screen, the height of the listbox is shorter than that of the button.

I checked the pixel coordinate using a mouse click event handler OnLButtonDown, and noticed that the size and location of the button are correct. The bottom coordinate of the CListBox is not correct. Why is this happening?

The option I used to create the listbox was WS_CHILD | WS_VISIBLE | LBS_STANDARD, and used WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON for the button. I tried removing the LBS_STANDARD, but still the height was not changed.

The MSDN on CListBox::Create just describes this:

rect

Specifies the list-box size and position. Can be either a CRect object or a RECT structure.

Is there something I missed?

CodePudding user response:

Add the LBS_NOINTEGRALHEIGHT style:

Specifies that the size of the list box is exactly the size specified by the application when it created the list box. Normally, the system sizes a list box so that the list box does not display partial items.

  • Related