Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Resize a combo box to a form view

Posted on 2002-06-26
4
Medium Priority
?
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 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