当前位置: 首页>>代码示例>>C++>>正文


C++ AfxThrowResourceException函数代码示例

本文整理汇总了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();
}
开发者ID:victimofleisure,项目名称:ChordEase,代码行数:54,代码来源:PianoCtrl.cpp

示例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;
}
开发者ID:victimofleisure,项目名称:ChordEase,代码行数:15,代码来源:PianoCtrl.cpp

示例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();
                    }
                }
        }
    }
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:32,代码来源:FRAMEWND.CPP

示例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;
}
开发者ID:GFFavourite,项目名称:Script.NET,代码行数:26,代码来源:FlatHeaderCtrl.cpp

示例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;
}
开发者ID:yongxiu,项目名称:sudoku,代码行数:28,代码来源:TimeViewer.cpp

示例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();
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:7,代码来源:wingdi.cpp

示例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;
  }
}
开发者ID:derekqian,项目名称:GPUSim_ATTILA,代码行数:35,代码来源:TreeListColumnDropWnd.cpp

示例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;
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:36,代码来源:FrmMain.cpp

示例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;
}
开发者ID:BlackVodka,项目名称:busmaster,代码行数:38,代码来源:WaitIndicator.cpp

示例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 ) ;
}
开发者ID:jimmccurdy,项目名称:ArchiveGit,代码行数:34,代码来源:WindowsImageList.cpp

示例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;
}
开发者ID:SnipeDragon,项目名称:gamecq,代码行数:47,代码来源:Tfxdatatip.cpp

示例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();
				}
			}
		}
	}
}
开发者ID:neil-yi,项目名称:ffsource,代码行数:34,代码来源:GuiDocBarExten.cpp

示例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;
}
开发者ID:fville,项目名称:MFCLabWidget,代码行数:29,代码来源:LabKnob.cpp

示例14: ASSERT

CWindowDC::CWindowDC(CWnd* pWnd)
{
	ASSERT(pWnd == NULL || ::IsWindow(pWnd->m_hWnd));

	if (!Attach(::GetWindowDC(m_hWnd = pWnd->GetSafeHwnd())))
		AfxThrowResourceException();
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:7,代码来源:wingdi.cpp

示例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));
	}
}
开发者ID:jetlive,项目名称:skiaming,代码行数:25,代码来源:ErrorDlg.cpp


注:本文中的AfxThrowResourceException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。