//绑定函数
VOID CPasswordControl::PreSubclassWindow()
{
	__super::PreSubclassWindow();

	//获取位置
	CRect rcClient;
	CRect rcWindow;
	GetClientRect(&rcClient);
	GetWindowRect(&rcWindow);

	//创建按钮
	CRect rcButton(0,0,0,0);
	m_btKeyboard.Create(NULL,WS_CHILD|WS_VISIBLE,rcButton,this,IDC_BT_KEYBOARD);
	m_btKeyboard.SetButtonImage(IDB_BT_KEYBOARD,GetModuleHandle(SHARE_CONTROL_DLL_NAME),false,false);

	//创建控件
	CRect rcEditCreate;
	rcEditCreate.top=4;
	rcEditCreate.left=4;
	rcEditCreate.bottom=16;
	rcEditCreate.right=rcClient.Width()-23;
	m_edPassword.Create(WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_PASSWORD,rcEditCreate,this,IDC_ED_PASSWORD);

	//设置控件
	m_edPassword.LimitText(LEN_PASSWORD-1);
	m_edPassword.SetEnableColor(RGB(0,0,0),RGB(255,255,255),RGB(92,100,105));
	m_edPassword.SetFont(&CSkinResourceManager::GetInstance()->GetDefaultFont());

	//移动窗口
	SetWindowPos(NULL,0,0,rcWindow.Width(),24,SWP_NOMOVE|SWP_NOZORDER|SWP_NOCOPYBITS);
	m_btKeyboard.SetWindowPos(NULL,rcClient.Width()-20,3,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS|SWP_NOACTIVATE);

	return;
}
예제 #2
0
BOOL CSettingsSheet::SkinMe(LPCTSTR pszSkin, UINT nIcon, BOOL bLanguage)
{
	EnableBanner( FALSE );

	m_szPages.cx = m_szPages.cy = 0;

	for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ )
	{
		CSettingsPage* pPage = GetPage( nPage );
		CDialogTemplate pTemplate;

		if ( pPage->GetTemplateName() == NULL )  continue;

		if ( pTemplate.Load( pPage->GetTemplateName() ) )
		{
			CSize size;
			pTemplate.GetSizeInPixels( &size );
			m_szPages.cx = max( m_szPages.cx, size.cx );
			m_szPages.cy = max( m_szPages.cy, size.cy );
		}
	}

	CRect rcWindow(
		0,
		0,
		m_szPages.cx + m_nListWidth + m_nListMargin,
		m_szPages.cy + + m_nButtonHeight + 8 + 8 + 2 );
	CalcWindowRect( &rcWindow );
	SetWindowPos( &wndTop, 0, 0, rcWindow.Width(), rcWindow.Height(),
		SWP_NOMOVE|SWP_NOZORDER );

	CRect rcTree(
		0,
		2,
		m_nListWidth,
		2 + m_szPages.cy );
	m_wndTree.MoveWindow( &rcTree );

	CRect rcButton(
		8,
		2 + m_szPages.cy + 8,
		8 + m_nButtonWidth,
		2 + m_szPages.cy + 8 + m_nButtonHeight );
	m_wndOK.MoveWindow( &rcButton );
	rcButton.OffsetRect( rcButton.Width() + 8, 0 );
	m_wndCancel.MoveWindow( &rcButton );
	rcButton.OffsetRect( rcButton.Width() + 8, 0 );
	m_wndApply.MoveWindow( &rcButton );

	CenterWindow();

	SetActivePage( m_pPage ? m_pPage : m_pFirst );

	return CSkinDialog::SkinMe( pszSkin, nIcon, bLanguage );
}
CXTPSkinObjectFrame::CCaptionButton* CXTPSkinObjectFrame::HitTestButton(CPoint pt)
{
    DWORD dwStyle = GetStyle();

    for (int i = 0; i < m_arrButtons.GetSize(); i++)
    {
        CCaptionButton* pButton = m_arrButtons[i];
        CRect rcButton(pButton->m_rcButton);

        if ((dwStyle & (WS_MAXIMIZE | WS_CHILD)) == WS_MAXIMIZE)
            rcButton.InflateRect(0, 2, i == 0 ? 2 : 0, 0);

        if (rcButton.PtInRect(pt) && pButton->m_bEnabled)
            return pButton;
    }
    return NULL;
}
예제 #4
0
void CBackstagePageInfo::OnCheckForIssuesDropDown()
{
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
	
	CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(pMainFrame->GetCommandBars());
	pPopupBar->SetDefaultButtonStyle(xtpButtonCaptionAndDescription);
	pPopupBar->SetShowGripper(FALSE);
	
	pPopupBar->GetControls()->Add(xtpControlButton, IDS_CHECK_INSPECT_DOCUMENT);
	pPopupBar->GetControls()->Add(xtpControlButton, IDS_CHECK_ACCESSIBILITY);
	
	CXTPWindowRect rcButton(GetDlgItem(IDC_BUTTON_CHECKFORISSUE));	
	pMainFrame->GetCommandBars()->TrackPopupMenu(pPopupBar, TPM_RETURNCMD | TPM_NONOTIFY, rcButton.left, rcButton.bottom, this);
	
	
	pPopupBar->InternalRelease();
}
예제 #5
0
void CSingleExamDlg::SetExamInfo(pEXAMINFO pExamInfo)
{
	_pExamInfo = pExamInfo;

	ReleaseData();
	InitData();
	USES_CONVERSION;
	for (auto pSub : _pExamInfo->lSubjects)
	{
		pEXAM_SUBJECT pSubject = pSub;
		CBmpButton* pNewButton = new CBmpButton();// 也可以定义为类的成员变量。
		pNewButton->SetStateBitmap(IDB_Exam_SubjectBtn, 0, IDB_Exam_SubjectBtn_Hover);
		CRect rcButton(10, 10, 50, 30); // 按钮在对话框中的位置。
		pNewButton->Create(A2T(pSub->strSubjName.c_str()), 0, rcButton, this, LOWORD(pSubject->nSubjID * 10 + pSubject->nSubjID + _pExamInfo->nExamID));
		pNewButton->ShowWindow(SW_SHOW);
		m_vecBtn.push_back(pNewButton);
	}
	InitCtrlPosition();
}
예제 #6
0
파일: NavPane.cpp 프로젝트: ijprest/WinDjVu
void CNavPaneWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
	if (m_bDragging)
	{
		CRect rcClient = ::GetClientRect(this);
		if (rcClient.Width() > 70)
		{
			CRect rcButton(CPoint(rcClient.right - 21, rcClient.top + 2), CSize(19, 18));
			if (rcButton.PtInRect(point))
			{
				GetParent()->SendMessage(WM_COLLAPSE_NAV);
				m_bCloseActive = false;
				m_bClosePressed = false;
			}
		}

		m_bDragging = false;
		ReleaseCapture();
	}

	UpdateButtons();
	CWnd::OnLButtonUp(nFlags, point);
}
예제 #7
0
void CBackstagePageInfo::OnProtectDocumentDropDown()
{

	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(pMainFrame->GetCommandBars());
	pPopupBar->SetDefaultButtonStyle(xtpButtonCaptionAndDescription);
	pPopupBar->SetShowGripper(FALSE);
	pPopupBar->SetIconSize(CSize(32, 32));

	pPopupBar->GetControls()->Add(xtpControlButton, IDS_PROTECT_MARK_AS_FINAL);
	pPopupBar->GetControls()->Add(xtpControlButton, IDS_PROTECT_ENCRYPT);


	UINT nIDs[] = {IDS_PROTECT_ENCRYPT};
	XTPImageManager()->SetIcons(IDC_BUTTON_PROTECTDOCUMENT, nIDs, 1, CSize(0, 0), xtpImageNormal);


	CXTPWindowRect rcButton(GetDlgItem(IDC_BUTTON_PROTECTDOCUMENT));
	pMainFrame->GetCommandBars()->TrackPopupMenu(pPopupBar, TPM_RETURNCMD | TPM_NONOTIFY, rcButton.left, rcButton.bottom, this);


	pPopupBar->InternalRelease();
}
예제 #8
0
void CMuleToolbarCtrl::Dump()
{
	TRACE("---\n");
	CRect rcWnd;
	GetWindowRect(&rcWnd);
	TRACE("Wnd =%4d,%4d-%4d,%4d (%4d x %4d)\n", rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, rcWnd.Width(), rcWnd.Height());

	CRect rcClnt;
	GetClientRect(&rcClnt);
	TRACE("Clnt=%4d,%4d-%4d,%4d (%4d x %4d)\n", rcClnt.left, rcClnt.top, rcClnt.right, rcClnt.bottom, rcClnt.Width(), rcClnt.Height());

	// Total size of all of the visible buttons and separators in the toolbar.
	CSize siz;
	GetMaxSize(&siz);
	TRACE("MaxSize=                  %4d x %4d\n", siz.cx, siz.cy);

	int iButtons = GetButtonCount();	// Count of the buttons currently in the toolbar.
	int iRows = GetRows();				// Number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style
	int iMaxTextRows = GetMaxTextRows();// Maximum number of text rows that can be displayed on a toolbar button.
	TRACE("ButtonCount=%d  Rows=%d  MaxTextRows=%d\n", iButtons, iRows, iMaxTextRows);

	// Current width and height of toolbar buttons, in pixels.
	DWORD dwButtonSize = GetButtonSize();
	TRACE("ButtonSize=%dx%d\n", LOWORD(dwButtonSize), HIWORD(dwButtonSize));

	// Padding for a toolbar control.
	DWORD dwPadding = SendMessage(TB_GETPADDING);
	TRACE("Padding=%dx%d\n", LOWORD(dwPadding), HIWORD(dwPadding));

	DWORD dwBitmapFlags = GetBitmapFlags(); // TBBF_LARGE=0x0001
	TRACE("BitmapFlags=%u\n", dwBitmapFlags);

	// Bounding rectangle of a button in a toolbar.
	TRACE("ItemRects:");
	for (int i = 0; i < iButtons; i++)
	{
		CRect rcButton(0,0,0,0);
		GetItemRect(i, &rcButton);
		TRACE(" %2dx%2d", rcButton.Width(), rcButton.Height());
	}
	TRACE("\n");

	// Bounding rectangle for a specified toolbar button.
	TRACE("Rects    :");
	for (int i = 0; i < iButtons; i++)
	{
		CRect rcButton(0,0,0,0);
		GetRect(IDC_TOOLBARBUTTON + i, &rcButton);
		TRACE(" %2dx%2d", rcButton.Width(), rcButton.Height());
	}
	TRACE("\n");

	TRACE("Info     :");
	for (int i = 0; i < iButtons; i++)
	{
		TCHAR szLabel[256];
		TBBUTTONINFO tbi = {0};
		tbi.cbSize = sizeof(tbi);
		tbi.dwMask |= TBIF_BYINDEX | TBIF_COMMAND | TBIF_IMAGE | TBIF_LPARAM | TBIF_SIZE | TBIF_STATE | TBIF_STYLE | TBIF_TEXT;
		tbi.cchText = _countof(szLabel);
		tbi.pszText = szLabel;
		GetButtonInfo(i, &tbi);
		szLabel[_countof(szLabel) - 1] = _T('\0');
		TRACE(" %2d ", tbi.cx);
	}
	TRACE("\n");
}
예제 #9
0
void CNewFilterGroupDlg::InitGUI()
{
	CFont* pDlgFont = GetFont();

	//1. Grammar Dialog layout
	m_pLangRuleDlg->CreateModeless(this);
	m_pLangRuleDlg->SetFont(pDlgFont);

	CRect rcLangRuleDlg;
	m_pLangRuleDlg->GetWindowRect(&rcLangRuleDlg);

	CSize szMax;
	CalcLabelSize(szMax);

	int nStartX = 7;
	int nStartY = 7;
	int nSpaceX = 5;
	int nSpaceY = 7;

	int nEditWidth = rcLangRuleDlg.Width() - 2 * nStartX - szMax.cx - nSpaceX;

	CRect rect;

	//Filter Group Label
	rect.left = nStartX;
	rect.top = nStartY;
	rect.right = rect.left + szMax.cx;
	rect.bottom = rect.top + szMax.cy;
	m_pFilterNameLabel->Create(lpFilterGroupName, WS_CHILD | WS_VISIBLE | SS_RIGHT, rect, this, IDC_STATIC);
	m_pFilterNameLabel->SetFont(pDlgFont);

	//Filter Group Edit
	rect.left = rect.right + nSpaceX;
	rect.right = rect.left + nEditWidth;	
	m_pFilterName->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL, rect, this, ID_FILTER_GROUP);
	m_pFilterName->ModifyStyleEx(0, WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY, SWP_DRAWFRAME);
	m_pFilterName->SetFont(pDlgFont);

	//Lang Rule Type Label
	rect.left = nStartX;
	rect.top = nStartY + nSpaceY + szMax.cy;
	rect.right = rect.left + szMax.cx;
	rect.bottom = rect.top + szMax.cy;
	m_pLangRuleTypeLabel->Create(lpLangRuleTypeName, WS_CHILD | WS_VISIBLE | SS_RIGHT, rect, this, IDC_STATIC);
	m_pLangRuleTypeLabel->SetFont(pDlgFont);

	//Lang Rule Type ComboBox
	rect.left = rect.right + nSpaceX;
	rect.right = rect.left + nEditWidth;
	m_pLangRuleType->Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|CBS_DROPDOWNLIST, rect, this, ID_LANG_RULE_TYPE);
	m_pLangRuleType->SetFont(pDlgFont);

	//Move the lang rule dialog to the correct position
	m_pLangRuleDlg->SetWindowPos(NULL, 0, rect.bottom + nSpaceY, rcLangRuleDlg.Width(), rcLangRuleDlg.Height(), SWP_NOZORDER | SWP_NOACTIVATE);

	rect.top = rect.bottom + nSpaceY + rcLangRuleDlg.Height() + nSpaceY;

	//3. OK, Cancel Button layout
	CRect rcButton(0, 0, 50, 14);
	MapDialogRect(&rcButton);
	int nButtonWidth = rcButton.Width();
	int nButtonHeight = rcButton.Height();
	int nButtonSpace = 14;

	int nButtonTotalWidth = nButtonWidth * 2 + nButtonSpace;

	//OK
	rcButton.left = (rcLangRuleDlg.Width() - nButtonTotalWidth) / 2;
	rcButton.top = rect.top;
	rcButton.right = rcButton.left + nButtonWidth;
	rcButton.bottom = rcButton.top + nButtonHeight;
	m_pOkButton->Create("OK", WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_DEFPUSHBUTTON, rcButton, this, IDOK);
	m_pOkButton->SetFont(pDlgFont);

	//Cancel
	rcButton.left = rcButton.right + nButtonSpace;
	rcButton.right = rcButton.left + nButtonWidth;
	m_pCancelButton->Create("Cancel", WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON, rcButton, this, IDCANCEL);
	m_pCancelButton->SetFont(pDlgFont);

	//Dialog reposition
	CRect rcWindow, rcClient;
	GetWindowRect(&rcWindow);
	GetClientRect(&rcClient);
	int nDlgHeight = rcButton.bottom + nButtonSpace;
	nDlgHeight += rcWindow.Height() - rcClient.Height();

	int nDlgWidth = rcLangRuleDlg.Width() + rcWindow.Width() - rcClient.Width();
	SetWindowPos(NULL, 0, 0, nDlgWidth, nDlgHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
예제 #10
0
void CQuizRunningDlg::OnSize(UINT nType, int cx, int cy)
{
	__super::OnSize(nType, cx, cy);
	if (m_subTitle.GetSafeHwnd() == NULL)
		return;

	INT cMargin = cy / 100;
	INT cMainWidth = cx * 2 / 3;
	INT cMainHeight = (cy - cMargin * 5) / 10;

	if (m_largeFont.m_hObject)
	{
		m_largeFont.DeleteObject();
		m_normalFont.DeleteObject();
		m_smallFont.DeleteObject();
	}

	LOGFONT lf;
	lf.lfHeight = cMainHeight * 3 / 5;
	lf.lfWidth = 0;
	lf.lfEscapement = 0; 
	lf.lfOrientation = 0;
	lf.lfWeight = FW_NORMAL;
	lf.lfItalic = FALSE;
	lf.lfUnderline = FALSE;
	lf.lfStrikeOut = FALSE;
	lf.lfCharSet = DEFAULT_CHARSET;
	lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf.lfQuality = CLEARTYPE_QUALITY;//ANTIALIASED_QUALITY;
	lf.lfPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE;
	_tcscpy(lf.lfFaceName, _T("Trebuchet MS"));
	m_largeFont.CreateFontIndirect(&lf);

	lf.lfHeight = cMainHeight * 1 / 3;
	m_normalFont.CreateFontIndirect(&lf);

	lf.lfHeight = cMainHeight * 1 / 4;
	m_smallFont.CreateFontIndirect(&lf);

	for (INT i = BT_Start; i < BT_Last; i++)
		m_pButtons[i]->SetFont(&m_normalFont);
	m_title.SetFont(&m_largeFont);
	m_subTitle.SetFont(&m_normalFont);
	m_info.SetFont(&m_smallFont);
	m_result.SetFont(&m_smallFont);
	m_progress.SetFont(&m_largeFont);


	INT cury = 0; 
	m_title.MoveWindow(&CRect(0, cury, cx, cury + cMainHeight));
	cury += cMainHeight; 
	m_subTitle.MoveWindow(&CRect(0, cury, cx, cury + cMainHeight / 2));
	cury += cMainHeight / 2;
	cury += cMargin;
	m_info.MoveWindow(&CRect(0, cury, cx / 2, cury + 2 * cMainHeight));
	m_result.MoveWindow(&CRect(cx / 2, cury, cx, cury + 2 * cMainHeight));
	//CRect rcMediaPlayer(mpDividerPos + cMargin, cury, cx - cMargin, cury + 4 * cMainHeight);
	cury += 2 * cMainHeight + 2 * cMargin;

	INT buttonLeft = (cx - cMainWidth) / 2;
	cMainHeight /= 2;
	CRect rcButton(buttonLeft, cury, buttonLeft + cMainWidth, cury + cMainHeight);
	//=== MediaPlayer
	GetDlgItem(IDC_MEDIAPLAYER)->MoveWindow(&rcButton);
	m_pPlayer->SetVisPosition(0, 0, rcButton.Width(), rcButton.Height());

	//=== Progress
	rcButton.OffsetRect(0, cMainHeight + 2 * cMargin);
	m_progress.MoveWindow(rcButton);

	//=== Buttons: Line 1
	rcButton.OffsetRect(0, cMainHeight + 2 * cMargin);
	m_pButtons[BT_Start]->MoveWindow(rcButton);
	m_pButtons[BT_Submit]->MoveWindow(rcButton);
	m_pButtons[BT_Answer1]->MoveWindow(rcButton);

	//=== Buttons: Line 2
	rcButton.OffsetRect(0, cMainHeight + cMargin);
	m_pButtons[BT_SelectPrev]->MoveWindow(rcButton);
	m_pButtons[BT_Answer2]->MoveWindow(rcButton);
	m_pButtons[BT_NewGame]->MoveWindow(rcButton);

	//=== Buttons: Line 3
	rcButton.OffsetRect(0, cMainHeight + cMargin);
	m_pButtons[BT_SelectNext]->MoveWindow(rcButton);
	m_pButtons[BT_Answer3]->MoveWindow(rcButton);

	//=== Buttons: Line 4
	rcButton.OffsetRect(0, cMainHeight + cMargin);
	m_pButtons[BT_Answer4]->MoveWindow(rcButton);

	//=== Buttons: Line 5
	rcButton.OffsetRect(0, cMainHeight + cMargin);
	m_pButtons[BT_AnswerNo]->MoveWindow(rcButton);

	//=== Buttons: Line 6
	rcButton.OffsetRect(0, cMainHeight + 3 * cMargin);
	m_pButtons[BT_EndGame]->MoveWindow(rcButton);
	m_pButtons[BT_Exit]->MoveWindow(rcButton);

}