Solved

Resize a combo box to a form view

Posted on 2002-06-26
4
299 Views
Last Modified: 2013-11-20
How do I Resize a combo box to a form view? What message handler should I use?
0
Comment
Question by:skibud2
  • 2
  • 2
4 Comments
 

Author Comment

by:skibud2
ID: 7110739
I basically want the combobox to be the size of the form view (or a little less). The formview can be resized.
0
 
LVL 1

Accepted Solution

by:
gurly earned 100 total points
ID: 7110822
use theh WM_SIZE message.
It should look something like that:

in your .h file:
     //{{AFX_DATA(CYourView)
     enum { IDD = IDD_YOUR_FORM };
     CComboBox     m_oCombo;
     //}}AFX_DATA

in your .cpp file:

void CYourView::DoDataExchange(CDataExchange* pDX)
{
     CFormView::DoDataExchange(pDX);
     //{{AFX_DATA_MAP(CYourView)
     DDX_Control(pDX, IDC_COMBO1, m_oCombo);
     //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CYourView, CFormView)
     //{{AFX_MSG_MAP(CResizingView)
     ON_WM_SIZE()
     //}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CYourView::OnSize(UINT nType, int cx, int cy)
{
     CFormView::OnSize(nType, cx, cy);
     
     CRect rc;
     GetClientRect(rc);

     rc.DeflateRect(5, 5);

     if (::IsWindow(m_oCombo.m_hWnd))
          m_oCombo.MoveWindow(rc);
     
}

This will set the combo's width.
If you also want to change the drop down height, check this link:
http://www.experts-exchange.com/questions/Q_20137661.html
0
 

Author Comment

by:skibud2
ID: 7110846
Awesome Answer.. I am just wondering is it possible to use the setWindowPos to do something like this? Thats what I was trying and I was getting a ASSERT Error. I tried
m_combl.SetWindowPos(NULL,10,10,cx-10,cy-10, SWP_NOREDRAW);
Appreciate the help
-Mike
0
 
LVL 1

Expert Comment

by:gurly
ID: 7110865
Where do you place that line and get an ASSERT ?

I tried the same and it worked ok.

maybe you didn't check that the window is alive ?
--->  if (::IsWindow(m_oCombo.m_hWnd))

Glad to be of help, anyway.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 155
Host to IP 7 80
sameEnds challenge 3 180
Way to decrease size of apk file 9 87
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question