Solved

Resize a combo box to a form view

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Looking for a specific application/software 2 104
either24  challenge 19 90
Line meaning 9 82
Capture logon name 13 48
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

21 Experts available now in Live!

Get 1:1 Help Now