本文整理汇总了C++中CButton::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ CButton::Create方法的具体用法?C++ CButton::Create怎么用?C++ CButton::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CButton
的用法示例。
在下文中一共展示了CButton::Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addColumn
// Add a new column to current tab's list and
// a button for the column.
void CLoungeDlg::addColumn(LPCTSTR coltitle, int totalcolumns, BOOL inQueue)
{
const int BtnSizeY = (1.6f * Global::GetCharHeight());
int btnId = IDC_LD_BUTTONIDBASE;
CRect r;
listCtrl_.GetWindowRect(&r);
int i = listCtrl_.GetHeaderCtrl()->GetItemCount();
int width = float(r.Width()) / float(totalcolumns);
// force width between min and max
width = min(width, MaxColumnWidth);
width = max(width, MinColumnWidth);
listCtrl_.InsertColumn(i, coltitle, LVCFMT_LEFT, width, i);
if (buttons_.size() < (i + 1))
{
CButton* pBtn = new CButton();
if (pBtn)
{
CRect rectBtn(r.left, r.bottom + 5, r.left + width, r.bottom + 5 + BtnSizeY);
ScreenToClient(&rectBtn);
rectBtn.OffsetRect(i * width, 0);
UINT style = WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON;
if (inQueue)
pBtn->Create(g_szRemoveFromQueue, style, rectBtn, this, btnId + i);
else
pBtn->Create(g_szAddToQueue, style, rectBtn, this, btnId + i);
pBtn->SetFont(CFont::FromHandle(
(HFONT)::GetStockObject(DEFAULT_GUI_FONT)));
buttons_.push_back(pBtn);
}
}
}
示例2: CreateSpeedBundle
void CdynControlDlg::CreateSpeedBundle(cJSON *json, int x, int y, int w, int h)
{
int idx = cJSON_GetObjectItem(json, "id")->valueint;
int speed = cJSON_GetObjectItem(json, "speed")->valueint;
int ptx = x;
int width = w - SPEEDBTN_WIDTH - LOCKBTN_WIDTH;
CString str;
CEdit *edit = new CEdit();
edit->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
CRect(ptx, y, ptx + width, y + h),
this,
SPEED_ID_OFFSET + idx);
str.Format(_T("%d"), speed);
edit->SetWindowText(str);
ptx += width;
width = SPEEDBTN_WIDTH;
CButton *btn = new CButton();
btn->Create(_T("set"), WS_CHILD | WS_VISIBLE | BS_TOP,
CRect(ptx, y, ptx + width, y + h),
this,
SPEEDBTN_ID_OFFSET + idx);
ptx += width;
width = LOCKBTN_WIDTH;
btn = new CButton();
btn->Create(_T("lock"), WS_CHILD | WS_VISIBLE | BS_TOP,
CRect(ptx, y, ptx + width, y + h),
this,
LOCKBTN_ID_OFFSET + idx);
}
示例3: NuevoGrupoControles
void CGestionMineralesDlg::NuevoGrupoControles(int nIndice)
{
const unsigned __int8 nFilasMax = 20;
const unsigned __int8 nTamCheck = 15;
const unsigned __int8 nEspaciado = 25;
const unsigned __int8 nDistanciaColumnas = 200;
const unsigned __int8 nSangriaInicial = 40;
const unsigned __int8 nTamBotones = 15;
const unsigned __int8 nEspaciadoBotones = 25;
// lista para enlazar los indices iniciales con los reales de los vectores
//m_vecMap.push_back(nIndice);
unsigned int fila, columna;
CButton* pButton;
CString csInfo;
HBITMAP hBitmapEditar= (HBITMAP) m_bitmapEditar.GetSafeHandle();
HBITMAP hBitmapBorrar= (HBITMAP) m_bitmapBorrar.GetSafeHandle();
fila = nIndice % nFilasMax;
columna = nIndice / nFilasMax;
csInfo.Format("%-4s - %s",theApp.m_minerales.GetAbreviatura(nIndice), theApp.m_minerales.GetNombre(nIndice));
// Delete
pButton = new CButton;
pButton->Create("x",WS_CHILD | WS_VISIBLE |BS_BITMAP/*| BS_LEFTTEXT*/,
CRect(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2),
m_rect.bottom + nEspaciado*fila,
nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2) + nTamBotones,
m_rect.bottom + nEspaciado*fila + nTamBotones ), this, CONTROLES_DINAMICOS_MIN + nIndice*3 +2);
pButton->SetBitmap(hBitmapBorrar);
m_vecDelete.push_back(pButton);
//Edit
pButton = new CButton;
pButton->Create("e",WS_CHILD | WS_VISIBLE |BS_BITMAP /*| BS_LEFTTEXT*/,
CRect(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones,
m_rect.bottom + nEspaciado*fila,
nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones + nTamBotones,
m_rect.bottom + nTamBotones + nEspaciado*fila), this, CONTROLES_DINAMICOS_MIN + nIndice*3 +1);
pButton->SetBitmap(hBitmapEditar);
m_vecEdit.push_back(pButton);
//Check
pButton = new CButton;
pButton->Create(csInfo,WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX /*| BS_LEFTTEXT*/,
CRect(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones*2,
m_rect.bottom + nEspaciado*fila,
nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones*2 + nDistanciaColumnas,
m_rect.bottom + nTamCheck + nEspaciado*fila), this, CONTROLES_DINAMICOS_MIN + nIndice*3);
pButton->SetCheck(theApp.m_minerales.m_list[nIndice]->m_bActivo);
m_vecCheck.push_back(pButton);
this->SetWindowPos(NULL,0,0,max(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones*2 + nDistanciaColumnas + 50, m_rect.right),
m_rect.bottom + nTamCheck + nEspaciado*nFilasMax + 50, SWP_NOMOVE | SWP_NOZORDER); //+50 para el menu y barra de titulo
}
示例4: _InsertPage
//---------------------------------------------------------------------------
// Function name : _InsertPage
// Description : Called by InsertPage(...) methods
// Return -1 if an error occurs
//---------------------------------------------------------------------------
int CRollupCtrl::_InsertPage(const TCHAR* caption, CDialog* pwndTemplate, int idx, BOOL bAutoDestroyTpl)
{
ASSERT(pwndTemplate!=NULL);
ASSERT(pwndTemplate->m_hWnd!=NULL);
//Get client rect
CRect r; GetClientRect(r);
//Create GroupBox
CButton* groupbox = new CButton;
groupbox->Create(_T(""), WS_CHILD|BS_GROUPBOX, r, this, 0 );
//Create Button
CButton* but = new CButton;
but->Create(caption, WS_CHILD|BS_AUTOCHECKBOX|BS_PUSHLIKE|BS_FLAT, r, this, 0 );
//Change Button's font
HFONT hfont= (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
CFont* font = CFont::FromHandle(hfont);
but->SetFont(font);
//Add page at pagelist
RC_PAGEINFO* pi = new RC_PAGEINFO;
pi->cstrCaption = caption;
pi->bExpanded = FALSE;
pi->bEnable = TRUE;
pi->pwndTemplate = pwndTemplate;
pi->pwndButton = but;
pi->pwndGroupBox = groupbox;
pi->pOldDlgProc = (WNDPROC)::GetWindowLong(pwndTemplate->m_hWnd, DWL_DLGPROC);
pi->pOldButProc = (WNDPROC)::GetWindowLong(but->m_hWnd, GWL_WNDPROC);
pi->bAutoDestroyTpl = bAutoDestroyTpl;
int newidx;
if (idx<0) newidx = (int)m_PageList.Add(pi);
else { m_PageList.InsertAt(idx, pi); newidx=idx; }
//Set Dlg Window datas
::SetWindowLong(pwndTemplate->m_hWnd, GWL_USERDATA, (LONG)m_PageList[newidx]);
::SetWindowLong(pwndTemplate->m_hWnd, DWL_USER, (LONG)this);
//Set But Window data
::SetWindowLong(but->m_hWnd, GWL_USERDATA, (LONG)m_PageList[newidx]);
//SubClass Template window proc
::SetWindowLong(pwndTemplate->m_hWnd, DWL_DLGPROC, (LONG)CRollupCtrl::DlgWindowProc);
//SubClass Button window proc
::SetWindowLong(but->m_hWnd, GWL_WNDPROC, (LONG)CRollupCtrl::ButWindowProc);
//Update
m_PageHeight+=RC_PGBUTTONHEIGHT+(RC_GRPBOXINDENT/2);
RecalLayout();
return newidx;
}
示例5: MoveAdjust
void CScroll::MoveAdjust()
{
CButton* pc;
Math::Point pos, dim;
if ( m_dim.y < m_dim.x*2.0f ) // very short lift?
{
delete m_buttonUp;
m_buttonUp = 0;
delete m_buttonDown;
m_buttonDown = 0;
}
else
{
if ( m_buttonUp == 0 )
{
m_buttonUp = new CButton();
pc = m_buttonUp;
pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL);
pc->SetRepeat(true);
m_eventUp = pc->GetEventType();
}
if ( m_buttonDown == 0 )
{
m_buttonDown = new CButton();
pc = m_buttonDown;
pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL);
pc->SetRepeat(true);
m_eventDown = pc->GetEventType();
}
}
if ( m_buttonUp != 0 )
{
pos.x = m_pos.x;
pos.y = m_pos.y+m_dim.y-m_dim.x/0.75f;
dim.x = m_dim.x;
dim.y = m_dim.x/0.75f;
m_buttonUp->SetPos(pos);
m_buttonUp->SetDim(dim);
}
if ( m_buttonDown != 0 )
{
pos.x = m_pos.x;
pos.y = m_pos.y;
dim.x = m_dim.x;
dim.y = m_dim.x/0.75f;
m_buttonDown->SetPos(pos);
m_buttonDown->SetDim(dim);
}
AdjustGlint();
}
示例6: AddButton
void COptionSheet::AddButton(wchar_t *txt, int x, int w, UINT id, BOOL showButton)
{
CButton *btn;
CRect rect;
CRect rcClient;
GetClientRect(rcClient);
rect.left = x;
rect.right = x + w;
rect.top = rcClient.Height() - (PAGE_SPACING2 + m_ButtonHeight);
rect.bottom = rect.top + m_ButtonHeight;
btn = new CButton();
DWORD style = WS_TABSTOP | BS_DEFPUSHBUTTON;
if(TRUE == showButton) {
style |= WS_VISIBLE;
}
btn->Create(txt, style, rect, this, id);
btn->SetFont(&m_Font);
m_Buttons.AddTail(btn);
}
示例7: CreateButton
void CDBSchemaTableView::CreateButton(CButton& btn, UINT id, CWnd* pParent, LPCTSTR lpTitle, UINT width, UINT height, DWORD dwStyle, CFont* pFont)
{
static CFont* pDefaultFont = 0;
if(!pDefaultFont)
{
pDefaultFont = new CFont;
pDefaultFont->CreateFont(16, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
0, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T( "Arial ")); // lpszFac
}
RECT rect = {0, 0, width, height};
btn.Create(lpTitle, dwStyle, rect, pParent, id);
if(!pFont) pFont = pDefaultFont;
btn.SetFont(pFont);
btn.ShowWindow(SW_SHOW);
}
示例8: OnInitDialog
BOOL CToolMonsterShow::OnInitDialog()
{
CDialog::OnInitDialog();
skin.SetButtonSkin( m_OK);
int x;
int y;
for (x=0;x<2*10+1;x++)
{
for (y=0;y<2*8+1;y++)
{
CButton *but = new CMonsterButton(x,y);
RECT rect;
rect.top=29+y*20;
rect.left=20+x*20;
rect.right=rect.left+14;
rect.bottom=rect.top+14;
but->Create("test",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON|BS_FLAT|BS_3STATE,rect,this,IDC_MONSTERSHOW_FIRSTBUTTON);
m_monsterButtons[x][y]=but;
}
}
refreshVisibleCreatures();
SetTimer(1001,500,NULL);
return TRUE;
}
示例9: OnCreate
int CPicContainer::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
//创建按钮
CRect ClientRect;
GetClientRect(&ClientRect);
CRect rect;
long lButtonSizeX=70;
long lButtonSizeY=60;
long lDelta =20;
int PosX,PosY;
for(size_t i=0;i<m_ButtonInfo.size();i++)
{
CButton *pButton =new CButton;
rect.left =lDelta*(i+1)+lButtonSizeX*i;
rect.top =ClientRect.Height()-lDelta-lButtonSizeY;
rect.bottom =rect.top+lButtonSizeY;
rect.right =rect.left+lButtonSizeX;
m_ButtonInfo[i].rect =rect;
pButton->Create(NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON/*|BS_OWNERDRAW*/ , rect, this, ID_FB+i);
m_buttons.push_back(pButton);
}
return 0;
}
示例10: OnCreate
int CControlPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 여기에 특수화된 작성 코드를 추가합니다.
CRect rect;
GetWindowRect(&rect);
list<GroundControl::Node*>& nodelist = GroundControlManager.getNodeList();
int idx = 0;
for (list<GroundControl::Node*>::iterator iter = nodelist.begin(); iter != nodelist.end(); ++iter)
{
GroundControl::Node* node = *iter;
m_nodelist.push_back(node);
CButton* rButton = new CButton();
wstring wstr = wstring(node->name().begin(), node->name().end());
rButton->Create(wstr.c_str(), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 20, rect.top + 20 * (idx + 1), rect.left + 20 + 100, rect.top + 20 * (idx + 1) + 20), this, ID_NODE_LIST_BTN_BASE+idx);
if (idx == 0)
{
rButton->SetCheck(BST_CHECKED);
m_curnode = node;
}
else
{
rButton->SetCheck(BST_UNCHECKED);
}
m_nodelistBtn.push_back(rButton);
idx++;
}
m_rnoneBtn.Create(_T("None"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 160, rect.top + 20, rect.left + 160 + 100, rect.top + 20 + 20), this, ID_CONTROLLER_BTN_BASE);
m_rmouseBtn.Create(_T("Mouse"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 160, rect.top + 40, rect.left + 160 + 100, rect.top + 40 + 20), this, ID_CONTROLLER_BTN_BASE+1);
m_rjoystickBtn.Create(_T("Joystick"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 160, rect.top + 60, rect.left + 160 + 100, rect.top + 60 + 20), this, ID_CONTROLLER_BTN_BASE+2);
m_rnoneBtn.SetCheck(BST_UNCHECKED);
m_rmouseBtn.SetCheck(BST_CHECKED);
m_rjoystickBtn.SetCheck(BST_UNCHECKED);
m_goForwardBtn.Create(_T("전진"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 110, rect.top + 100, rect.left + 110 + BUTTON_SIZE_X, rect.top + 100 + BUTTON_SIZE_Y), this, ID_GO_FORWARD_BTN);
m_stopBtn.Create(_T("정지"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 110, rect.top + 200, rect.left + 110 + BUTTON_SIZE_X, rect.top + 200 + BUTTON_SIZE_Y), this, ID_STOP_BTN);
m_goBackwardBtn.Create(_T("후진"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 110, rect.top + 300, rect.left + 110 + BUTTON_SIZE_X, rect.top + 300 + BUTTON_SIZE_Y), this, ID_GO_BACKWARD_BTN);
m_goLeftBtn.Create(_T("좌회전"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 10, rect.top + 200, rect.left + 10 + BUTTON_SIZE_X, rect.top + 200 + BUTTON_SIZE_Y), this, ID_GO_LEFT_BTN);
m_goRightBtn.Create(_T("우회전"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 210, rect.top + 200, rect.left + 210 + BUTTON_SIZE_X, rect.top +200 + BUTTON_SIZE_Y), this, ID_GO_RIGHT_BTN);
m_mouseControlPanel.Create( NULL, NULL, WS_CHILD | WS_VISIBLE | SS_NOTIFY | WS_BORDER, CRect(rect.left + 310, rect.top + 0, rect.left + 310 + 400, rect.top + 0 + 400), this, ID_MOUSE_CONTROL_PANEL);
SetTimer(100, 30, NULL);
m_curController = &m_mouseControlPanel;
return 0;
}
示例11: OnInitDialog
BOOL CExampleDemoDlg::OnInitDialog()
{
CDialogEx::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
// 设置窗口为屏幕宽高
MoveWindow(0, 0, GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN));
SetDlgItemInt(ID_MSG, 0);
m_tempplate=LoadTemplateImg("template");
//1、动态创建进入下一张图片按钮
CRect rcBtn(20, 0, 120, 15); //按钮高度为15,间隔高度为10
DWORD dwStyle = WS_CHILD | BS_PUSHBUTTON;
m_nextimageb = new CButton();
m_nextimageb->Create("下一张", dwStyle, rcBtn, this, IDC_NEXT_BUTTON);
//2、动态创建单选框按钮
for (int i = 0; i < m_tempplate.size(); i++)
{
DWORD dwStyle = WS_CHILD | BS_AUTORADIOBUTTON;
rcBtn.top += 25;
rcBtn.bottom += 25;
CButton *pButton = new CButton();
if (0 == i)
{
dwStyle |= WS_GROUP; //第一个按钮时添加分组风格
}
CString index;
index.Format("%d", i);
pButton->Create(index, dwStyle, rcBtn, this, IDC_GROUP_BUTTON + i);
pButton->SetFont(GetFont()); //设置为父窗口的字体
m_radioList.push_back(pButton);
}
::SetWindowPos(this->m_hWnd, HWND_BOTTOM, 200, 0, 1400, 1000, SWP_NOZORDER);
return TRUE; // return TRUE unless you set the focus to a control
}
示例12:
CRDdialog::CRDdialog(std::vector<string> ids):_ids(ids),RDbuttons()
{
int id =0;
for(std::vector<string>::iterator it=_ids.begin();it!=_ids.end();++it)
{
CButton rd;
rd.Create(_T((*it).c_str()), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,
CRect(10,40,100,70), this, id++);
RDbuttons.push_back(&rd);
}
}
示例13: NewRadio
void CMyGroupBox::NewRadio(CString sCaption, UINT nID)
{
CFont* font = GetFont();
CButton* pBtn = new CButton();
int nCount = GetRadioCount();
int t = 20 + m_nRadioHeight * nCount;
pBtn->Create(sCaption, WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, CRect(10, t, 400, t + m_nRadioHeight), this, nID);
if (nCount == 0)
{
pBtn->SetCheck(1);
}
pBtn->SetFont(font);
m_RadioList.Add(pBtn);
}
示例14: AddCheck
// add a check box at the specified column
void CCustomListRowWnd::AddCheck(INT32 col)
{
CButton* pBut = new CButton();
m_ColumnObjects[col] = pBut ;
CRect cr;
GetClientRect(&cr);
ASSERT(cr.Height() == CCustomList::ROWHEIGHT);
CRect rect;
rect.left = m_Parent->m_Parent->m_ColumnOffsetsArray[col] ;
rect.right = rect.left + GetSystemMetrics(SM_CXMENUCHECK);
rect.top = (CCustomList::ROWHEIGHT - GetSystemMetrics(SM_CYMENUCHECK))/2;
rect.bottom = rect.top + GetSystemMetrics(SM_CYMENUCHECK) ;
pBut->Create(NULL, WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, rect, this, 4);
}
示例15: CreatePositionBundle
void CdynControlDlg::CreatePositionBundle(cJSON *json, int x, int y, int w, int h)
{
int idx = cJSON_GetObjectItem(json, "id")->valueint;
ids.push_back(idx);
CString str;
char *name = cJSON_GetObjectItem(json, "name")->valuestring;
int min = cJSON_GetObjectItem(json, "min")->valueint;
int max = cJSON_GetObjectItem(json, "max")->valueint;
str.Format(_T("0x%x: %s\n [%d, %d]"), idx, charTotchar(name), min, max);
CButton *checkBox = new CButton();
checkBox->Create(str,
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE,
CRect(x, y, x + CHECK_WIDTH, y + h),
this,
CHECK_ID_OFFSET + idx);
checkBox->SetCheck(BST_CHECKED);
CSliderCtrl *slider = new CSliderCtrl();
int width = w - (CHECK_WIDTH + VIEW_WIDTH);
int ptx = x + CHECK_WIDTH;
slider->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
CRect(ptx, y, ptx + width, y + h),
this,
SLIDER_ID_OFFSET + idx);
slider->SetRange(min, max);
slider->SetTicFreq(1);
int initPos = cJSON_GetObjectItem(json, "init")->valueint;
slider->SetPos(initPos);
CEdit *edit = new CEdit();
ptx += width;
width = VIEW_WIDTH;
edit->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
CRect(ptx, y, ptx + width, y + 30),
this,
VIEW_ID_OFFSET + idx);
str.Format(_T("%d"), initPos);
edit->SetWindowText(str);
}