Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
// 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);
    }
  }
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 5
0
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
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
	BOOL	OnCreate( LPCREATESTRUCT lpCreateStruct ){
		m_pWorkItem	= CreateThreadpoolWork( WorkerThread, this, NULL );
		if( m_pWorkItem == NULL ){
			return FALSE;
		}

		m_btnStart.Create(this, 10, 10, 100, 25, IDC_START_BTN, _T("START"));
		m_btnStart.SetFont();

		m_ListBox.Create(this, 10, 30, 200, 200, IDC_LISTBOX);
		m_ListBox.SetFont();

		cmd.Initialize( this );
		cmd.Register( IDC_START_BTN, &CMainForm::OnStartBatch );

		msg.Initialize( this );
		msg.Register( WM_APP_COMPLETED, &CMainForm::OnCompleted );

		return TRUE;
	}
Ejemplo n.º 8
0
void CGeneralMsgBox::CreateBtns()
{
  // The minimum button's dimension
  m_dimBtn = CSize(FromDlgX(m_aMetrics[CX_MIN_BTN]), 0);

  // DC and Font for use in some dimension calculations
  CClientDC dc(this);

  CFont *pWndFont = GetFont();
  CFont *poldFont = dc.SelectObject(pWndFont);

  CRect rcDummy; // dimesion doesn't matter here

  INT_PTR cBtns = m_aBtns.GetSize();

  for (int i = 0; i < cBtns; ++i) {
    BTNDATA &btndata = m_aBtns[i];

    // Finding the minimum dimension needed to properly show any button
    CSize dimBtn = dc.GetTextExtent(btndata.strBtn);

    m_dimBtn.cx = max(m_dimBtn.cx, dimBtn.cx);
    m_dimBtn.cy = max(m_dimBtn.cy, dimBtn.cy);

    // Creating the button with MFC's CButton help.
    CButton btnCtrl;

    btnCtrl.Create(btndata.strBtn,
                   WS_CHILD|WS_VISIBLE|WS_TABSTOP,
                   rcDummy, this, btndata.uiIDC);
    btnCtrl.SetFont(pWndFont);
    btnCtrl.UnsubclassWindow();
  }

  dc.SelectObject(poldFont);

  // Add the button margins
  m_dimBtn.cx += 2 * FromDlgX(m_aMetrics[CX_BTN_BORDER]);
  m_dimBtn.cy += 2 * FromDlgY(m_aMetrics[CY_BTN_BORDER]);
}
Ejemplo n.º 9
0
BOOL CBaseDlg::OnInitDialog()
{
	//CDialog::OnInitDialog();
	if (m_hIcon)
	{
		SetIcon(m_hIcon, TRUE);   // 设置大图标
		SetIcon(m_hIcon, FALSE);  // 设置小图标
	}

	m_bInit = TRUE;

	for (int i = 0; i < m_vecCtrl.size(); i++)
	{
		switch (m_vecCtrl[i].type)
		{
		case BASE_BUTTON:
		case BASE_CHECK_BUTTON:
		{
			CButton* pCtrl = (CButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_COMMOM_BUTTON:
		{
			CCommonButton* pCtrl = (CCommonButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_STATIC:
		{
			CStatic* pCtrl = (CStatic*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_MY_CHECK_BUTTON:
		{
			CMyCheckButton* pCtrl = (CMyCheckButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_INDICATOR:
		{
			CIndicator* pCtrl = (CIndicator*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_GROUPBOX:
		{
			CGroupBox* pCtrl = (CGroupBox*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_EDIT_CSTRING:
		case BASE_EDIT_DOUBLE:
		{
			CEdit* pCtrl = (CEdit*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_COLOR_TEXT:
		{
			CColorText* pCtrl = (CColorText*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_DRAWVIEW:
		{
			CDrawView* pCtrl = (CDrawView*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_LIST:
		{
			CListCtrl* pCtrl = (CListCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_TABVIEW:
		{
			CTabViewCtrl* pCtrl = (CTabViewCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_GRADIENT_BACKGROUND:
		{
			CGradientBackground* pCtrl = (CGradientBackground*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_COMBOBOX:
		{
			CComboBox* pCtrl = (CComboBox*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			CString caption = m_vecCtrl[i].sCaption;
			for (int j = 0; j < m_vecCtrl[i].nDataCount; j++)
			{
				int endpos = caption.Find(L"\n");
				CString item = caption.Mid(0, endpos);
				pCtrl->AddString(item);
				caption = caption.Right(caption.GetLength()-endpos-1);
			}
			pCtrl->SetCurSel(0);
			break;
		}
		case BASE_PROGRESS:
		{
			CProgressCtrl* pCtrl = (CProgressCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData != NULL)
			{
				pCtrl->SetRange32((int)m_vecCtrl[i].dMinVal,(int)m_vecCtrl[i].dMaxVal);
			}
			break;
		}
		case BASE_SLIDER:
		{
			CSliderCtrl* pCtrl = (CSliderCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData != NULL)
			{
				pCtrl->SetRangeMax((int)m_vecCtrl[i].dMaxVal);
				pCtrl->SetRangeMin((int)m_vecCtrl[i].dMinVal);
			}
			break;
		}
		case BASE_SLIDER_GROUP:
		{
			CSliderGroup* pCtrl = (CSliderGroup*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData!=NULL)
			{
				pCtrl->GetSlider()->SetRangeMax((int)m_vecCtrl[i].dMaxVal);
				pCtrl->GetSlider()->SetRangeMin((int)m_vecCtrl[i].dMinVal);
			}
			break;
		}
		default:
			break;
		}
	}
	UpdateData(FALSE);
	return TRUE;
}