本文整理匯總了C++中AfxThrowResourceException函數的典型用法代碼示例。如果您正苦於以下問題:C++ AfxThrowResourceException函數的具體用法?C++ AfxThrowResourceException怎麽用?C++ AfxThrowResourceException使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AfxThrowResourceException函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ZeroMemory
void CPianoCtrl::UpdateKeyLabelFont(CSize Size, DWORD dwStyle)
{
LOGFONT lf;
ZeroMemory(&lf, sizeof(lf));
lf.lfQuality = ANTIALIASED_QUALITY;
lf.lfPitchAndFamily = FF_SWISS; // sans serif
lf.lfWeight = FW_BOLD;
CSize MaxLabel(0, 0);
CClientDC dc(this);
CFont ExtFont; // font for measuring label text extents
lf.lfHeight = 50; // sufficient height for reasonable precision
if (!ExtFont.CreateFontIndirect(&lf)) // create text extent font
AfxThrowResourceException();
HGDIOBJ hPrevFont = dc.SelectObject(ExtFont); // select font
int nLabels = m_KeyLabel.GetSize();
for (int iLabel = 0; iLabel < nLabels; iLabel++) { // for each label
CSize sz = dc.GetTextExtent(m_KeyLabel[iLabel]);
if (sz.cx > MaxLabel.cx) // if label width exceeds maximum
MaxLabel.cx = sz.cx; // update maximum
if (sz.cy > MaxLabel.cy) // if label height exceeds maximum
MaxLabel.cy = sz.cy; // update maximum
}
dc.SelectObject(hPrevFont); // restore DC's default font
double FontAspect;
if (MaxLabel.cx) // if at least one label has non-zero width
FontAspect = double(MaxLabel.cy) / MaxLabel.cx; // get font aspect ratio
else // all zero widths
FontAspect = 0; // avoid divide by zero
double WhiteAvail = 2.0 / 3.0; // portion of white key available for label
// compute font height; truncate instead of rounding to err on side of caution
int FontHeight;
if (dwStyle & PS_VERTICAL) { // if vertical orientation
int WhiteMaxWidth = trunc((Size.cx - m_BlackKeySize.cx) * WhiteAvail);
FontHeight = trunc(min(MaxLabel.cx, WhiteMaxWidth) * FontAspect);
FontHeight = min(FontHeight, m_BlackKeySize.cy);
} else { // horizontal orientation
if (dwStyle & PS_ROTATE_LABELS) { // if rotated labels
int WhiteMaxHeight = trunc((Size.cy - m_BlackKeySize.cy) * WhiteAvail);
FontHeight = trunc(min(MaxLabel.cx, WhiteMaxHeight) * FontAspect);
FontHeight = min(FontHeight, m_BlackKeySize.cx);
lf.lfOrientation = 900; // rotate font 90 degrees counter-clockwise
lf.lfEscapement = 900;
} else { // normal labels
FontHeight = trunc((m_BlackKeySize.cx - OUTLINE_WIDTH * 2) * FontAspect);
int WhiteMaxHeight = trunc((Size.cy - m_BlackKeySize.cy) * WhiteAvail);
FontHeight = min(FontHeight, WhiteMaxHeight);
}
}
FontHeight = CLAMP(FontHeight, MIN_FONT_HEIGHT, MAX_FONT_HEIGHT);
lf.lfHeight = FontHeight; // font height, in logical pixels
m_KeyLabelFont.DeleteObject(); // delete previous font if any
if (!m_KeyLabelFont.CreateFontIndirect(&lf)) // create font
AfxThrowResourceException();
}
示例2: AfxThrowResourceException
int CPianoCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create key brushes
for (int iType = 0; iType < KEY_TYPES; iType++) { // for each key type
for (int iState = 0; iState < KEY_STATES; iState++) { // for each key state
if (!m_KeyBrush[iType][iState].CreateSolidBrush(m_KeyColor[iType][iState]))
AfxThrowResourceException();
}
}
if (!m_OutlineBrush.CreateSolidBrush(m_OutlineColor)) // create outline brush
AfxThrowResourceException();
return 0;
}
示例3: ASSERT
// dock bars will be created in the order specified by dwMRCDockBarMap
// this also controls which gets priority during layout
// this order can be changed by calling EnableDocking repetitively
// with the exact order of priority
//------------------------------------------------------------------------------
void CMRCFrameWndSizeDock::EnableDocking(DWORD dwDockStyle, CRuntimeClass *pFloatingClass)
// This is over-ridden primarily because we need to insert our own CDockBar class
// to handle the recalc layout, and this is the place they are created.
//------------------------------------------------------------------------------
{
// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);
m_pFloatingFrameClass = pFloatingClass; // protected member
for (int i = 0; i < 4; i++)
{
if (dwMRCDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY) // protected
{
CDockBar* pDock = (CDockBar*)GetControlBar(dwMRCDockBarMap[i][0]);
if (pDock == NULL)
{
pDock = new CSizeDockBar;
if (!pDock->Create(this,
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
dwMRCDockBarMap[i][1], dwMRCDockBarMap[i][0]))
{
AfxThrowResourceException();
}
}
}
}
}
示例4: AfxGetInstanceHandle
CFHDragWnd::CFHDragWnd()
{
// Register the window class if it has not already been registered.
WNDCLASS wndclass;
HINSTANCE hInst = AfxGetInstanceHandle();
if(!(::GetClassInfo(hInst, FHDRAGWND_CLASSNAME, &wndclass)))
{
// otherwise we need to register a new class
wndclass.style = CS_SAVEBITS ;
wndclass.lpfnWndProc = ::DefWindowProc;
wndclass.cbClsExtra = wndclass.cbWndExtra = 0;
wndclass.hInstance = hInst;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor( hInst, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = FHDRAGWND_CLASSNAME;
if (!AfxRegisterClass(&wndclass))
AfxThrowResourceException();
}
m_pFlatHeaderCtrl = NULL;
m_iItem = -1;
m_lphdiItem = NULL;
}
示例5: AfxGetInstanceHandle
BOOL CTimeViewer::RegisterWindowClass()
{
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
if (!(::GetClassInfo(hInst, TIMEVIEWER_CLASSNAME, &wndcls)))
{
// otherwise we need to register a new class
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = TIMEVIEWER_CLASSNAME;
if (!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
return FALSE;
}
}
return TRUE;
}
示例6: AfxThrowResourceException
CPen::CPen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
int nStyleCount, const DWORD* lpStyle)
{
if (!Attach(::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount,
lpStyle)))
AfxThrowResourceException();
}
示例7: m_pTreeListCtrl
CTreeListColumnDropWnd::CTreeListColumnDropWnd() :
m_pTreeListCtrl( NULL )
{
// register the window class
WNDCLASS wndclass;
HINSTANCE hInst = AfxGetInstanceHandle();
if(!(::GetClassInfo(hInst, TLCDROPWND_CLASSNAME, &wndclass)))
{
wndclass.style = CS_HREDRAW | CS_VREDRAW ; //CS_SAVEBITS ;
wndclass.lpfnWndProc = ::DefWindowProc;
wndclass.cbClsExtra = wndclass.cbWndExtra = 0;
wndclass.hInstance = hInst;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor( hInst, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TLCDROPWND_CLASSNAME;
if (!AfxRegisterClass(&wndclass))
AfxThrowResourceException();
}
if( g_lpfnUpdateLayeredWindow == NULL || g_lpfnSetLayeredWindowAttributes == NULL )
{
HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));
g_lpfnUpdateLayeredWindow = (lpfnUpdateLayeredWindow)GetProcAddress( hUser32, _T("UpdateLayeredWindow") );
g_lpfnSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress( hUser32, _T("SetLayeredWindowAttributes") );
if( g_lpfnUpdateLayeredWindow == NULL || g_lpfnSetLayeredWindowAttributes == NULL )
m_bLayeredWindows = FALSE;
else
m_bLayeredWindows = TRUE;
}
}
示例8: lstrcpyn
//--------------------------------------------------------------------------------------------------------------//
BOOL CFrmMain::PreCreateWindow(CREATESTRUCT& cs)
{
if (FALSE == CFrameWnd::PreCreateWindow(cs)) return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
lstrcpyn(AfxGetThreadState()->m_szTempClassName, c_szSingleInstanceId,
sizeof(AfxGetThreadState()->m_szTempClassName) / sizeof(TCHAR));
cs.lpszClass = AfxGetThreadState()->m_szTempClassName;
WNDCLASS wndcls = {0};
HINSTANCE hInst = NULL;
hInst = AfxGetInstanceHandle();
if (FALSE == ::GetClassInfo(hInst, cs.lpszClass, &wndcls))
{
wndcls.style = 0;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = NULL;
wndcls.hbrBackground = NULL;
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = cs.lpszClass;
if (!AfxRegisterClass(&wndcls)) AfxThrowResourceException();
}
else
{
ASSERT(wndcls.style == 0);
return TRUE;
}
return TRUE;
}
示例9: Input
/******************************************************************************
Function Name : RegisterWindowClass
Input(s) : -
Output : BOOL
Functionality : Register the Indicator window as a custom Window control.
Member of : CWaitIndicator
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created :
Modifications :
******************************************************************************/
BOOL CWaitIndicator::RegisterWindowClass(void)
{
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
if (!(::GetClassInfo(hInst, INDICATOR_CLASSNAME, &wndcls)))
{
// otherwise we need to register a new class
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW ;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = nullptr;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) (COLOR_ACTIVEBORDER + 1);
wndcls.lpszMenuName = nullptr;
wndcls.lpszClassName = INDICATOR_CLASSNAME;
if (!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
return FALSE;
}
}
return TRUE;
}
示例10: AfxThrowResourceException
void RWindowsImageList::CreateMask( int nWidth, int nHeight, COLORREF crMask )
{
// Create the image mask bitmap and screen compatible device
HDC hdcImageMask = ::CreateCompatibleDC( m_hdcImageList ) ;
HBITMAP hbmImageMask = ::CreateBitmap( nWidth, nHeight, 1, 1, NULL ) ;
if (!hdcImageMask || !hdcImageMask)
{
if (hdcImageMask)
{
::DeleteDC( hdcImageMask ) ;
}
if (hbmImageMask)
{
::DeleteObject( hbmImageMask ) ;
}
AfxThrowResourceException( ) ;
}
m_hdcImageMask = hdcImageMask ;
m_hbmImageMask = hbmImageMask ;
// Select the bitmaps into the screen compatible dc
m_hbmOldImageMask = (HBITMAP) ::SelectObject( m_hdcImageMask, m_hbmImageMask ) ;
COLORREF crBkColor = ::SetBkColor( m_hdcImageList, crMask ) ;
::BitBlt( m_hdcImageMask, 0, 0, nWidth, nHeight,
m_hdcImageList, 0, 0, SRCCOPY ) ;
::SetBkColor( m_hdcImageList, crBkColor ) ;
}
示例11: AfxGetInstanceHandle
/*
* Method preamble ************************************************************
*
* CLASS: TFXDataTip
* NAME: RegisterWnd
*
* DESCRIPTION: This method registers the window class used by the DataTip
* windows. This must be called after the class background
* brush has been constructed.
*
* PARAMETERS: none
*
* RETURN TYPE: void
*
******************************************************************************
* REVISION HISTORY
*
******************************************************************************
*/
void TFXDataTip::RegisterWnd( )
{
// check for prior registration
if (_registered) return;
// initialise the basic information before registration
HINSTANCE hInst = AfxGetInstanceHandle( );
// initialise the window class information
WNDCLASS wndcls;
wndcls.style = CS_SAVEBITS | CS_DBLCLKS;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = 0;
wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = *_brush;
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = _T("TFXDataTip");
// register the window class
if (!AfxRegisterClass(&wndcls))
AfxThrowResourceException();
_registered = TRUE;
}
示例12: ASSERT_VALID
void CGuiDocBarExten::BarsDocking(CFrameWnd * pFrame, DWORD dwDockStyle)
{
ASSERT_VALID(pFrame);
// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);
pFrame->EnableDocking(dwDockStyle);
for (int i = 0; i < 4; i++) {
if (dwDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY) {
CDockBar* pDock = (CDockBar*)pFrame->GetControlBar(dwDockBarMap[i][0]);
if( pDock == 0 || ! pDock->IsKindOf(RUNTIME_CLASS(CGuiDocBarExten)) ) {
BOOL bNeedDelete = ! pDock->m_bAutoDelete;
pDock->m_pDockSite->RemoveControlBar(pDock);
pDock->m_pDockSite = 0;
pDock->DestroyWindow();
if( bNeedDelete )
delete pDock;
pDock = 0;
}
if( pDock == 0 ) {
pDock = new CGuiDocBarExten;
ASSERT_VALID(pDock);
if ((!pDock) || (!pDock->Create(pFrame,
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
dwDockBarMap[i][1], dwDockBarMap[i][0]))) {
AfxThrowResourceException();
}
}
}
}
}
示例13: AfxGetInstanceHandle
BOOL CLabKnob::RegisterWindowClass()
{
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
HBRUSH background;
background = ::GetSysColorBrush(COLOR_BTNFACE);
if (!(::GetClassInfo(hInst, "MFCLabKnob", &wndcls)))
{
// otherwise we need to register a new class
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = background;
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = "MFCLabKnob";
if (!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
return FALSE;
}
}
return TRUE;
}
示例14: ASSERT
CWindowDC::CWindowDC(CWnd* pWnd)
{
ASSERT(pWnd == NULL || ::IsWindow(pWnd->m_hWnd));
if (!Attach(::GetWindowDC(m_hWnd = pWnd->GetSafeHwnd())))
AfxThrowResourceException();
}
示例15: AfxThrowResourceException
void CErrorsDialog::SelectSource(int nSel)
{
if (m_listErrorInfo.IsEmpty())
{
CString strError;
if( strError.LoadString(IDS_NOSPECIFIED_ERROR) == FALSE)
{
AfxThrowResourceException();
}
m_ctlDescription.SetWindowText(strError);
m_ctlGUID.SetWindowText(_T(""));
}
else
{
OLECHAR szGUID[40];
POSITION pos = m_listErrorInfo.FindIndex(nSel);
struct MYERRORINFO* pInfo = (MYERRORINFO*)m_listErrorInfo.GetAt(pos);
m_ctlDescription.SetWindowText(COLE2T(pInfo->bstrDescription));
::StringFromGUID2(pInfo->guid, szGUID, 40);
m_ctlGUID.SetWindowText(COLE2T(szGUID));
}
}