找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 8657|回復(fù): 0
收起左側(cè)

Spin控件的使用(簡(jiǎn)要說(shuō)明)

[復(fù)制鏈接]
ID:77367 發(fā)表于 2015-4-18 21:34 | 顯示全部樓層 |閱讀模式
Demo
一 利用MFC AppWiard[exe]向?qū)?chuàng)建一個(gè)基于對(duì)話框的應(yīng)用程序MySpin
二 添加控件和變量


編輯框 ID為ID_EDIT,成員變量 CEdit m_ctlEdit;
旋轉(zhuǎn)按鈕 ID為ID_SPIN,成員變量 CSpinButtonCtrl m_ctlSpin;
三 設(shè)置旋轉(zhuǎn)按鈕屬性


三 在BOOL CSpinnDlg::OnInitDialog()添加代碼,紅色部分
BOOL CSpinnDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
  CString strAboutMenu;
  strAboutMenu.LoadString(IDS_ABOUTBOX);
  if (!strAboutMenu.IsEmpty())
  {
   pSysMenu->AppendMenu(MF_SEPARATOR);
   pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  }
}
// 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
SetDlgItemText(IDC_EDIT, _T("0"));
//設(shè)置旋轉(zhuǎn)按鈕的位置范圍
m_ctlSpin.SetRange(-100, 100);
//設(shè)置旋轉(zhuǎn)按鈕的當(dāng)前位置
m_ctlSpin.SetPos(0);
//設(shè)置旋轉(zhuǎn)按鈕的當(dāng)前基數(shù)
m_ctlSpin.SetBase(1);
//設(shè)置旋轉(zhuǎn)按鈕的伙伴窗口   
m_ctlSpin.SetBuddy(GetDlgItem(IDC_EDIT));


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

最后按Ctrl+F5編譯運(yùn)行



回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表