void CPageDisplay::ClearCheckButton()
{
	CButton* button;
	CRect button_rect;
	CPoint point;

	// When displaying the popup menu, if the user clicks outside the popup and
	// not on the button that poped the popup up, Windows handles removing the
	// menu.  We have to handle unchecking the button.

	button = (CButton*)GetDlgItem( BResultType1 + selected_button );
	button->GetWindowRect( &button_rect );
	GetCursorPos( &point );

	// Note that we only reset the state of the check button if the cursor is
	// not within the button's bounding rectangle.  If the cursor is within
	// the bounding rectangle, the user clicked the button a second time.  The
	// Button handler will take care of unchecking the button, and will not
	// display the menu.  This allows the button to toggle the menu.

	if ( button->GetCheck() && !button_rect.PtInRect( point ) )
		button->SetCheck( FALSE );

	// If the Big Meter display is open, the WM_EXITMENULOOP message may have
	// been intended for that dialog box.  Uncheck its ResultType button.

	if ( m_dlgBigMeter.is_displayed )
		m_dlgBigMeter.ClearCheckButton();
}
Beispiel #2
0
void CMyCommView::OnBtsendkey() 
{
    // TODO: Add your control notification handler code here
    CRect rect;
    CPoint point;
    CButton * mybt = (CButton *)GetDlgItem(IDC_BTSENDKEY);
    mybt->GetWindowRect(rect);
    point.x = rect.right;
    point.y = rect.bottom;

    CMenu menu;
    VERIFY( menu.LoadMenu( IDR_MENU_SNEDKEY ) );
    CMenu* popup = menu.GetSubMenu(0);
    ASSERT( popup != NULL );
            popup->TrackPopupMenu(TPM_RIGHTALIGN| TPM_RIGHTBUTTON, point.x, point.y, this ); 
}
void CWelcomeWnd::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	// get our own DC instead, with no restrictions
	CDC* pDC = GetDC();

	// realize the palette
	CPalette* pOldPalette = pDC->SelectPalette(m_bitmap.GetPalette(), FALSE);
	pDC->RealizePalette();

	// And draw the bitmap
	BITMAP bmInfo;
	if (m_bitmap.m_hObject == NULL)
		return;
	m_bitmap.GetObject(sizeof(BITMAP),&bmInfo);
	CDC newDC;
	newDC.CreateCompatibleDC(pDC);
	CBitmap* pOldBitmap = newDC.SelectObject(&m_bitmap);
	pDC->BitBlt(0,0,bmInfo.bmWidth,bmInfo.bmHeight,&newDC,0,0,SRCCOPY);

	//
	(void)newDC.SelectObject(pOldBitmap);
	newDC.DeleteDC();
	pDC->SelectPalette(pOldPalette, FALSE);
	ReleaseDC(pDC);

	// draw the 'OK' button
	CRect winRect, rect;
	GetClientRect(&winRect);
	CButton* pBtn = (CButton*) GetDlgItem(IDOK);
	pBtn->GetWindowRect(&rect);
	ScreenToClient(&rect);
	int nWidth = rect.Width();
	int nHeight = rect.Height();
	rect.bottom = winRect.bottom - 24;
	rect.top = rect.bottom - nHeight;
	rect.left = (winRect.right - nWidth) / 2;
	rect.right = rect.left + nWidth;
	pBtn->MoveWindow(&rect);
	pBtn->ShowWindow(SW_SHOW);
}
/* #FN#
   Performs special processing when the dialog box is initialized */
BOOL
/* #AS#
   TRUE unless you set the focus to a control */
CWarningDlg::
OnInitDialog()
{
	CDialog::OnInitDialog();

	if( !m_bCancel )
	{
		CRect rcCtrl;

		CButton *pButton = (CButton *)GetDlgItem( IDCANCEL );
		ASSERT(NULL != pButton);

		pButton->GetWindowRect( rcCtrl );
		ScreenToClient( rcCtrl );
		pButton->ShowWindow( SW_HIDE );

		pButton = (CButton *)GetDlgItem( IDOK );
		ASSERT(NULL != pButton);

		pButton->SetWindowPos( NULL,
			rcCtrl.TopLeft().x,
			rcCtrl.TopLeft().y,
			0, 0,
			SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS );
	}

	if( '\0' == *m_szWarningText )
		_LoadStringLx( -1 != m_nWarningID ? m_nWarningID : IDS_WARN_ERROR, m_szWarningText );

	SetDlgItemText( IDC_WARNING_TEXT, m_szWarningText );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
} /* #OF# CWarningDlg::OnInitDialog */
void CXTPColorDialog::CalculateRects()
{
	CRect rcBtnOK;
	CRect rcBtnCancel;
	CRect rcTabCtrl;
	CRect rcItem;

	// get the tab control size.
	CTabCtrl* pTabCtrl = GetTabControl();
	pTabCtrl->GetWindowRect(&rcTabCtrl);
	ScreenToClient(&rcTabCtrl);

	// get the size of the first tab item.
	pTabCtrl->GetItemRect(0, &rcItem);

	// get the OK button size.
	CButton* pBtnOK = (CButton*)GetDlgItem(IDOK);
	pBtnOK->GetWindowRect(&rcBtnOK);
	ScreenToClient(&rcBtnOK);

	// get the Cancel button size.
	CButton* pBtnCancel = (CButton*)GetDlgItem(IDCANCEL);
	pBtnCancel->GetWindowRect(&rcBtnCancel);
	ScreenToClient(&rcBtnCancel);
	rcBtnCancel.OffsetRect(-15, 0);

	// resize the tab control
	rcTabCtrl.right = rcBtnCancel.left - 5;
	rcTabCtrl.bottom = rcBtnCancel.top - 15;
	pTabCtrl->MoveWindow(&rcTabCtrl);

	// reposition the OK button.
	rcBtnOK = rcBtnCancel;
	rcBtnOK.top = rcTabCtrl.top + rcItem.Height() + 1;
	rcBtnOK.bottom = rcBtnOK.top + rcBtnCancel.Height();
	pBtnOK->MoveWindow(&rcBtnOK);

	// reposition the Cancel button.
	rcBtnCancel = rcBtnOK;
	rcBtnCancel.top = rcBtnOK.bottom + 5;
	rcBtnCancel.bottom = rcBtnCancel.top + rcBtnOK.Height();
	pBtnCancel->MoveWindow(&rcBtnCancel);

	// reposition the hex display
	if (::IsWindow(m_wndHexEdit.m_hWnd))
	{
		CRect rcWnd;
		rcWnd = rcBtnCancel;
		rcWnd.top = rcBtnCancel.bottom + 5;
		rcWnd.bottom = rcWnd.top + 18;
		m_wndHexEdit.MoveWindow(&rcWnd);
	}

	// reposition the eye dropper.
	if (::IsWindow(m_wndEyeDropper.m_hWnd))
	{
		CRect rcWnd;
		m_wndEyeDropper.GetWindowRect(&rcWnd);

		CSize size = rcWnd.Size();
		rcWnd.right = rcBtnOK.right;
		rcWnd.left = rcBtnOK.right - size.cx;
		rcWnd.bottom = rcTabCtrl.bottom;
		rcWnd.top = rcTabCtrl.bottom - size.cy;

		m_wndEyeDropper.MoveWindow(&rcWnd);
	}

	// resize the property sheet.
	CXTPWindowRect rcWindow(this);
	ClientToScreen(&rcTabCtrl);
	rcWindow.bottom = rcTabCtrl.bottom + 10;
	rcWindow.right -= 15;
	MoveWindow(&rcWindow);
}
void CResizableSheetEx::PresetLayout()
{
	if (IsWizard() || IsWizard97())	// wizard mode
	{
		// hide tab control
		GetTabControl()->ShowWindow(SW_HIDE);

		AddAnchor(ID_WIZLINE, BOTTOM_LEFT, BOTTOM_RIGHT);

		if (IsWizard97())	// add header line for wizard97 dialogs
			AddAnchor(ID_WIZLINEHDR, TOP_LEFT, TOP_RIGHT);
	}
	else	// tab mode
	{
		AddAnchor(AFX_IDC_TAB_CONTROL, TOP_LEFT, BOTTOM_RIGHT);
	}

	// add a callback for active page (which can change at run-time)
	m_nCallbackID = AddAnchorCallback();

	// use *total* parent size to have correct margins
	CRect rectPage, rectSheet;
	GetTotalClientRect(&rectSheet);

	GetActivePage()->GetWindowRect(&rectPage);
	::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectPage, 2);

	// pre-calculate margins
	m_sizePageTL = rectPage.TopLeft() - rectSheet.TopLeft();
	m_sizePageBR = rectPage.BottomRight() - rectSheet.BottomRight();

	// add all possible buttons, if they exist
	for (int i = 0; i < _propButtonsCount; i++)
	{
		CButton* dlgBtn = reinterpret_cast<CButton*>(GetDlgItem(_propButtons[i]));
		if (dlgBtn != NULL)
		{
			CRect rcBtn;
			CString sBtn;

			dlgBtn->GetWindowRect(rcBtn);
			ScreenToClient(rcBtn);

			HBITMAP hBmp = NULL;
			switch(_propButtons[i])
			{
			case ID_WIZBACK:
				dlgBtn->SetWindowPos(NULL, rcBtn.left - 16, rcBtn.top - 8, rcBtn.Width(), rcBtn.Height() + 4, SWP_NOZORDER | SWP_NOREDRAW);
				sBtn.LoadString(IDS_BACK);
				//sBtn.Insert(0, _T("  "));
				dlgBtn->SetWindowText(sBtn);
				m_BtnNavBack.SubclassDlgItem(_propButtons[i], this);
				m_BtnNavBack.SetIcon(IDI_ICON_NAV_BACK);

				rcBtn.right = rcBtn.Width() * 2 + 10;
				rcBtn.left = 5;
				rcBtn.top -= 10;
				rcBtn.bottom -= 3;

				m_BtnDonate.Create(_T("Help keep us strong!"), WS_CHILD | WS_VISIBLE | WS_GROUP, rcBtn, this, ID_WIZDONATE);
				m_BtnDonate.SetIcon(IDI_ICON_DONATE);
				m_BtnDonate.SetAlign(CButtonST::ST_ALIGN_HORIZ);
				m_BtnDonate.SetDisplayStyle(CButtonST::DISP_FLAT);
				m_BtnDonate.SetFont(GetFont(), FALSE);

				AddAnchor(ID_WIZDONATE, BOTTOM_LEFT);
				AddAnchor(_propButtons[i], BOTTOM_RIGHT);
				break;
			case ID_WIZNEXT:
				dlgBtn->SetWindowPos(NULL, rcBtn.left - 14, rcBtn.top - 8, rcBtn.Width(), rcBtn.Height() + 4, SWP_NOZORDER | SWP_NOREDRAW);
				sBtn.LoadString(IDS_NEXT);
				//sBtn.Append(_T("  "));
				dlgBtn->SetWindowText(sBtn);
				m_BtnNavNext.SubclassDlgItem(_propButtons[i], this);
				m_BtnNavNext.SetIcon(IDI_ICON_NAV_NEXT);
				m_BtnNavNext.SetAlign(CButtonST::ST_ALIGN_HORIZ_RIGHT);
				AddAnchor(_propButtons[i], BOTTOM_RIGHT);
				break;
			case IDCANCEL:
				dlgBtn->SetWindowPos(NULL, rcBtn.left - 14, rcBtn.top - 8, rcBtn.Width(), rcBtn.Height() + 4, SWP_NOZORDER | SWP_NOREDRAW);
				sBtn.LoadString(IDS_CANCEL);
				//sBtn.Append(_T("  "));
				dlgBtn->SetWindowText(sBtn);
				m_BtnNavCancel.SubclassDlgItem(_propButtons[i], this);
				m_BtnNavCancel.SetIcon(IDI_ICON_NAV_CANCEL);
				m_BtnNavCancel.SetAlign(CButtonST::ST_ALIGN_HORIZ_RIGHT);
				AddAnchor(_propButtons[i], BOTTOM_RIGHT);
				break;
			case ID_WIZFINISH:
				dlgBtn->SetWindowPos(NULL, rcBtn.left - 14, rcBtn.top - 8, rcBtn.Width(), rcBtn.Height() + 4, SWP_NOZORDER | SWP_NOREDRAW);
				sBtn.LoadString(IDS_FINISH);
				//sBtn.Append(_T("  "));
				dlgBtn->SetWindowText(sBtn);
				m_BtnNavFinish.SubclassDlgItem(_propButtons[i], this);
				m_BtnNavFinish.SetIcon(IDI_ICON_NAV_FINISH);
				m_BtnNavFinish.SetAlign(CButtonST::ST_ALIGN_HORIZ_RIGHT);
				AddAnchor(_propButtons[i], BOTTOM_RIGHT);
				break;
			}
		}
	}
}