MFC下拉框设置 下拉框不能工作

qq_25281187 2015-01-13 09:44:28
// step1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "step1.h"
#include "step1Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStep1Dlg dialog

CStep1Dlg::CStep1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CStep1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStep1Dlg)
m_edit = _T("");
m_chk1 = FALSE;
m_chk2 = FALSE;
m_chk3 = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CStep1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStep1Dlg)
DDX_Control(pDX, IDC_COMBO1, m_combo1);
DDX_Control(pDX, IDC_RADIO2, m_radfemale);
DDX_Control(pDX, IDC_RADIO1, m_radmale);
DDX_Text(pDX, IDC_EDIT1, m_edit);
DDV_MaxChars(pDX, m_edit, 4);
DDX_Check(pDX, IDC_CHECK1, m_chk1);
DDX_Check(pDX, IDC_CHECK2, m_chk2);
DDX_Check(pDX, IDC_CHECK3, m_chk3);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CStep1Dlg, CDialog)
//{{AFX_MSG_MAP(CStep1Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_MAXTEXT(IDC_EDIT1, OnMaxtextEdit1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStep1Dlg message handlers

BOOL CStep1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
//m_edit.SetWindowText("welcome");
//m_edit.EnableWindow(false);
m_edit="123";
UpdateData(false);
m_combo1.AddString( "23");
m_combo1.InsertString(4, "24" );
m_combo1.SetCurSel(4);

return TRUE; // return TRUE unless you set the focus to a control
}

// If you add a minimize button to your dialog, will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CStep1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CStep1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CStep1Dlg::OnMaxtextEdit1()
{
// TODO: Add your control notification handler code here
UpdateData(true);
AfxMessageBox(m_edit);
}

void CStep1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString str;
if(m_radmale.GetCheck())
m_radmale.GetWindowText(str);
else
m_radfemale.GetWindowText(str);
UpdateData(true);
if(m_chk1) str+="、 游泳" ;
if(m_chk2) str+="、 跑步" ;
if(m_chk3) str+="、 打球" ;
MessageBox(str,"测试",MB_OKCANCEL);

}

void CStep1Dlg::OnRadio1()
{
m_radmale.SetCheck(true);
m_radfemale.SetCheck(false);
}

void CStep1Dlg::OnRadio2()
{
// TODO: Add your control notification handler code here
m_radmale.SetCheck(false);
m_radfemale.SetCheck(true);
}


...全文
297 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shen_wei 2015-01-14
  • 打赏
  • 举报
回复
楼上都说完了,楼主实验OK了否?
ArthurKingYs 2015-01-14
  • 打赏
  • 举报
回复
顶楼上 就是说你的方法没错 就是下拉列表 高度不够 显示不出来 把鼠标放到最右边的箭头 可以把他往下拉拉就显示出来了
信阳毛尖 2015-01-14
  • 打赏
  • 举报
回复
引用 2 楼 lx624909677 的回复:
在资源视图里,把鼠标移到右边那个下拉箭头那里,然后拉的大一些
+1 资源视图中,找到CStep1Dlg资源编辑视图,选中你那个combox,将其高度拉大一些(combox本身高度+弹出下拉窗口高度)
lx624909677 2015-01-13
  • 打赏
  • 举报
回复
在资源视图里,把鼠标移到右边那个下拉箭头那里,然后拉的大一些
qq_25281187 2015-01-13
  • 打赏
  • 举报
回复
求大神指导 在线等

16,372

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧