Home > Software engineering >  Maximize window or adjust the size drop-down list box after Combo box does not display the drop-down
Maximize window or adjust the size drop-down list box after Combo box does not display the drop-down

Time:09-21

I use Visual Studio 2008 set up a dialog box procedure, using MFC to achieve maximum window size or adjust the options in the drop-down list after showed no, can't the drop-down displays all the options, I call GetDlgItem - & gt; ResetContent and GetDlgItem - & gt; AddString doesn't solve the problem, first thank you,
 void CSimApplianceDlg: : ReSize (void) 
{
Float FSP [2].
POINT Newp;//get the size of the dialog now
CRect recta;
GetClientRect (& amp; Recta);//in the client area size
Newp. X=recta. Right - recta. Left;
Newp) y=recta) bottom - recta. Top;
FSP [0]=(float) Newp. X/old. X.
FSP [1]=(float) Newp. Y/old. Y;
CRect the Rect.
Int woc.
CPoint OldTLPoint TLPoint;//the top left corner
CPoint OldBRPoint BRPoint;//at the bottom right
HWND hwndChild=: : GetWindow (m_hWnd, GW_CHILD);//list all control
While (hwndChild) {
Woc=: : GetDlgCtrlID (hwndChild);//ID
GetDlgItem (woc) - & gt; GetWindowRect (the Rect);
The ScreenToClient (the Rect);
OldTLPoint=the Rect. TopLeft ();
TLPoint. X=long (OldTLPoint. * x FSP [0]).
TLPoint. Y=long (OldTLPoint. * y FSP [1]).
OldBRPoint=the Rect. BottomRight ();
BRPoint. X=long (OldBRPoint. * x FSP [0]).
BRPoint. Y=long (OldBRPoint. * y FSP [1]).
The Rect. SetRect (TLPoint BRPoint);
GetDlgItem (woc) - & gt; MoveWindow (the Rect, TRUE);
HwndChild=: : GetWindow (hwndChild GW_HWNDNEXT);
}
Old=Newp;
}

CodePudding user response:

MCombox. SetItemHeight (1, nHeight) adjust

CodePudding user response:

reference 1st floor zgl7903 response:
mCombox. SetItemHeight (1, nHeight) adjust
add this statement to where ah, can say in detail?

CodePudding user response:

reference 1st floor zgl7903 response:
mCombox. SetItemHeight (1, nHeight) adjust


I'm calling the ReSize () function and then add the following code, but still doesn't work,
//Set the height of every item to be the 
//vertical size of the item 's text among.
Cstrings STR.
CSize sz.
The CDC * pDC=((CComboBox *) GetDlgItem (IDC_COMBO_AC_MODE1)) - & gt; GetDC ();
for (int i=0; I & lt; ((CComboBox *) GetDlgItem (IDC_COMBO_AC_MODE1)) - & gt; GetCount (); I++)
{
((CComboBox *) GetDlgItem (IDC_COMBO_AC_MODE1)) - & gt; GetLBText (I, STR);
Sz=pDC - & gt; GetTextExtent (STR);

((CComboBox *) GetDlgItem (IDC_COMBO_AC_MODE1)) - & gt; SetItemHeight (I, sz. Cy);
}
((CComboBox *) GetDlgItem (IDC_COMBO_AC_MODE1)) - & gt; The ReleaseDC (pDC);

CodePudding user response:

Can you upload a picture, please?

CodePudding user response:

 
Void CDlg3Dlg: : ReSize (void)
{
The SIZE Newp;//get the size of the dialog now
CRect recta;
GetClientRect (& amp; Recta);//in the client area size
Newp. Cx=recta. Width ();
Newp. Cy=recta. Height ();

Cx/double fxZoom=(double) Newp. (double) old. Cx.
Double fyZoom=(double) Newp. Cy/(double) old. Cy.

HWND hwndChild=: : GetWindow (m_hWnd, GW_CHILD);//list all control
While (hwndChild)
{
CRect the Rect.
: : GetWindowRect (hwndChild, & amp; The Rect);
The ScreenToClient (& amp; The Rect);

The Rect. Left=(int) (the Rect. Left * fxZoom + 0.5);
The Rect. Right=(int) (the Rect. Right * fxZoom + 0.5);
The Rect. Top=(int) (the Rect. Top * fyZoom + 0.5);
The Rect. Bottom=(int) (the Rect. Bottom * fyZoom + 0.5);

: : MoveWindow (hwndChild, the Rect. Left, the Rect. The top, the Rect. The Width (), the Rect. Height (), TRUE);

//modify COMBOBOX height
TCHAR szClass [64 + 1)={0};
If (GetClassName (hwndChild szClass, 64)
& & _tcscmp (szClass, _T (" COMBOBOX "))==0)
{
: : SendMessage (hwndChild CB_SETITEMHEIGHT, 1, the Rect. Height ());
}

HwndChild=: : GetWindow (hwndChild GW_HWNDNEXT);
}
Old=Newp;//the SIZE old
}

CodePudding user response:

The above _tcscmp change, _tcsicmp (szClass, _T (" COMBOBOX)"

CodePudding user response:

The building Lord I also encountered the same problem with you search online tried many ways did not solve your problem finally resolved yet? How to solve? Sharing methods qq272710437, grateful

CodePudding user response:

The solution? Help

CodePudding user response:

That can process CBN_DROPDOWN messages online looking for
//get the size of the ComboBox control, and then reset

CRect rc;
GetDlgItem (IDC_COMBO1) - & gt; GetClientRect (& amp; Rc);
M_ComBox. SetWindowPos (NULL, 0, 0, rc. The Width (), rc, Height () + 100, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);

Reference:
https://zhidao.baidu.com/question/540471281.html
http://blog.csdn.net/youyongyoumou/article/details/46363633

CodePudding user response:

Down list box using movewindow adjust the size, the size of the rect determines the size of the drop-down box

CodePudding user response:

references to the tenth floor xianglitian response:
down list box using movewindow adjust the size, the size of the rect determines the size of the drop-down box


This the rect which piece refers to?

CodePudding user response:

11 references Sweet__yy response:
Quote: reference to the tenth floor xianglitian response:

Down list box using movewindow adjust the size, the size of the rect determines the drop-down box the size of the


This the rect which piece refers to? nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related