Solved

Resize a combo box to a form view

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now