Solved

Resize a combo box to a form view

Posted on 2002-06-26
4
294 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

777 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