本文整理汇总了C++中AfxFindResourceHandle函数的典型用法代码示例。如果您正苦于以下问题:C++ AfxFindResourceHandle函数的具体用法?C++ AfxFindResourceHandle怎么用?C++ AfxFindResourceHandle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AfxFindResourceHandle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void CToolBarEx::SetIconOptions( EIconOptions eIconOptions, bool bUpdate /*=true*/ )
{
ASSERT( ::IsWindow( m_hWnd ) );
ASSERT( IsIconOptionAvailable( eIconOptions ) );
m_eIconOptions = eIconOptions;
// Set image list(s) and icon size for selected icon options
CToolBarCtrl& tbCtrl = GetToolBarCtrl();
tbCtrl.SetImageList( 0 );
tbCtrl.SetHotImageList( 0 );
tbCtrl.SetDisabledImageList( 0 );
CSize szIcon = ( eIconOptions == ioSmallIcons ) ? m_szImageSmall : m_szImageLarge;
VERIFY( tbCtrl.SetBitmapSize( szIcon ) );
UINT nIDCold = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallCold : m_nIDLargeCold;
UINT nIDHot = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallHot : m_nIDLargeHot;
UINT nIDDisabled = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallDisabled : m_nIDLargeDisabled;
ASSERT( nIDCold != ( UINT )-1 ); // at least there must be "cold" imagelist
LPCTSTR lpResName = MAKEINTRESOURCE( nIDCold );
HINSTANCE hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );
m_imageListCold.DeleteImageList();
VERIFY( m_imageListCold.Attach( ImageList_LoadImage( hInst, lpResName,
szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
tbCtrl.SetImageList( &m_imageListCold );
if ( nIDHot != ( UINT )-1 ) // "hot" imagelist is optional
{
lpResName = MAKEINTRESOURCE( nIDHot );
hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );
m_imageListHot.DeleteImageList();
VERIFY( m_imageListHot.Attach( ImageList_LoadImage( hInst, lpResName,
szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
tbCtrl.SetHotImageList( &m_imageListHot );
}
if ( nIDDisabled != ( UINT )-1 ) // "disabled" imagelist is optional
{
lpResName = MAKEINTRESOURCE( nIDDisabled );
hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );
m_imageListDisabled.DeleteImageList();
VERIFY( m_imageListDisabled.Attach( ImageList_LoadImage( hInst, lpResName,
szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
tbCtrl.SetDisabledImageList( &m_imageListDisabled );
}
// If requested, reflect changes immediately
if ( bUpdate )
{
ReloadButtons();
UpdateParentBandInfo();
}
}
示例2: AfxFindResourceHandle
bool MTrayIcon::AddIcon (unsigned int icon_id, const CString &tip, const CWnd &target)
{
HINSTANCE inst;
HANDLE icon;
inst = AfxFindResourceHandle(MAKEINTRESOURCE(icon_id), RT_GROUP_ICON);
icon = LoadImage(inst, MAKEINTRESOURCE(icon_id), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
m_nid.hWnd = target;
m_nid.uID = icon_id;
m_nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
//m_nid.uCallbackMessage = WM_TASKBAR; // my user message
m_nid.hIcon = (HICON)icon;
if (tip.GetLength() > 0) {
lstrcpyn(m_nid.szTip, tip, sizeof(m_nid.szTip));
}
else {
m_nid.szTip[0] = '\0';
}
Shell_NotifyIcon(NIM_ADD, &m_nid);
return true; // No errors.
}
示例3: AfxFindResourceHandle
BOOL CMPCPngImage::Load(LPCTSTR lpszResourceName, HINSTANCE hinstRes)
{
if (hinstRes == nullptr) {
hinstRes = AfxFindResourceHandle(lpszResourceName, _T("PNG"));
}
HRSRC hRsrc = ::FindResource(hinstRes, lpszResourceName, _T("PNG"));
if (hRsrc == nullptr) {
// Fallback to the instance handle
hinstRes = AfxGetInstanceHandle();
hRsrc = ::FindResource(hinstRes, lpszResourceName, _T("PNG"));
if (hRsrc == nullptr) {
return FALSE;
}
}
HGLOBAL hGlobal = LoadResource(hinstRes, hRsrc);
if (hGlobal == nullptr) {
return FALSE;
}
LPVOID lpBuffer = ::LockResource(hGlobal);
if (lpBuffer == nullptr) {
FreeResource(hGlobal);
return FALSE;
}
BOOL bRes = LoadFromBuffer((LPBYTE) lpBuffer, (UINT) ::SizeofResource(hinstRes, hRsrc));
UnlockResource(hGlobal);
FreeResource(hGlobal);
return bRes;
}
示例4: AfxFindResourceHandle
// This function associates a menu to the button.
// The menu will be displayed clicking the button.
//
// Parameters:
// [IN] nMenu
// ID number of the menu resource.
// Pass NULL to remove any menu from the button.
// [IN] hParentWnd
// Handle to the window that owns the menu.
// This window receives all messages from the menu.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD CButtonST::SetMenu(UINT nMenu, HWND hParentWnd, BOOL bRepaint)
{
HINSTANCE hInstResource = NULL;
// Destroy any previous menu
if (m_hMenu)
{
::DestroyMenu(m_hMenu);
m_hMenu = NULL;
m_hParentWndMenu = NULL;
m_bMenuDisplayed = FALSE;
} // if
// Load menu
if (nMenu)
{
// Find correct resource handle
hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(nMenu), RT_MENU);
// Load menu resource
m_hMenu = ::LoadMenu(hInstResource, MAKEINTRESOURCE(nMenu));
m_hParentWndMenu = hParentWnd;
// If something wrong
if (m_hMenu == NULL) return BTNST_INVALIDRESOURCE;
} // if
// Repaint the button
if (bRepaint) Invalidate();
return BTNST_OK;
} // End of SetMenu
示例5: AfxFindResourceHandle
_AFX_OCC_DIALOG_INFO* CFormView::GetOccDialogInfo()
{
#ifndef _AFX_NO_OCC_SUPPORT
if (m_pOccDialogInfo == NULL && m_lpszTemplateName != NULL)
{
LPCDLGTEMPLATE lpDialogTemplate = NULL;
HINSTANCE hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(hInst, hResource);
if (hTemplate != NULL)
{
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);
if (lpDialogTemplate != NULL)
{
COccManager* pOccManager = afxOccManager;
if (pOccManager != NULL)
{
_AFX_OCC_DIALOG_INFO *pOccDialogInfo = new _AFX_OCC_DIALOG_INFO;
lpDialogTemplate = pOccManager->PreCreateDialog(pOccDialogInfo,
lpDialogTemplate);
m_pOccDialogInfo = pOccDialogInfo;
}
}
}
}
#endif
return m_pOccDialogInfo;
}
示例6: RemoveSystemTrayIcon
/**
* set the old icon in system tray
*/
void CPocketSMDlg::SetOldTrayIcon()
{
RemoveSystemTrayIcon();
// handle to icon
HICON hIcon;
HINSTANCE hInst =
AfxFindResourceHandle(MAKEINTRESOURCE(IDR_MAINFRAME),
RT_GROUP_ICON);
hIcon = (HICON)LoadImage( hInst,
MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON,
16,
16,
LR_DEFAULTCOLOR);
// set NOTIFYCONDATA structure
m_nidIconData.cbSize = sizeof(NOTIFYICONDATA);
m_nidIconData.hWnd = m_hWnd;
m_nidIconData.uID = IDR_MAINFRAME;
m_nidIconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
m_nidIconData.uCallbackMessage = WM_ICON_NOTIFY; // my user message
m_nidIconData.hIcon = hIcon;
m_nidIconData.szTip[0] = '\0';
// call to Shell_NotifyIcon with NIM_ADD parameter
Shell_NotifyIcon(NIM_ADD, &m_nidIconData);
// free icon
if (hIcon)
DestroyIcon(hIcon);
}
示例7: ASSERT
bool CDockingBar::Create(CWnd* parent, CFramePages* pages, bool show)
{
ASSERT(parent);
ASSERT(pages);
pages_ = pages;
if (wnd_class_.IsEmpty())
wnd_class_ = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW));
CDC dc;
dc.CreateIC(_T("DISPLAY"), 0, 0, 0);
dc.SelectStockObject(DEFAULT_GUI_FONT);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
int line_height= tm.tmHeight + tm.tmInternalLeading + tm.tmExternalLeading;
int bar_height= ((line_height + 6) & ~1) + 1; // ensure height is odd
// create docking bar; width will be reset by frame wnd
if (!CWnd::CreateEx(0, wnd_class_, _T(""), WS_CHILD | (show ? WS_VISIBLE : 0) | WS_CLIPCHILDREN,
CRect(0, 0, 200, bar_height), parent, -1))
return false;
HINSTANCE inst= AfxFindResourceHandle(MAKEINTRESOURCE(IDB_DOCK_BAR), RT_BITMAP);
image_list_.Attach(ImageList_LoadImage(inst, MAKEINTRESOURCE(IDB_DOCK_BAR),
16, 0, RGB(192,192,192), IMAGE_BITMAP, LR_CREATEDIBSECTION));
image_list_.SetBkColor(CLR_NONE);
Refresh(true);
return true;
}
示例8: AfxFindResourceHandle
void CSkinBtn::SetIcons(CString strMouseOut,CString strMouseIn,BOOL bDrawIcon)
{
// m_hMouseOutIcon.Load(strMouseOut);
// m_hMouseInIcon.Load(strMouseIn);
HICON hIconIn = NULL;
HICON hIconOut = NULL;
HINSTANCE hInstResource = NULL;
// Find correct resource handle
hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(hIconIn), RT_GROUP_ICON);
// Set icon when the mouse is IN the button
hIconIn = (HICON)::LoadImage(hInstResource, strMouseIn, IMAGE_ICON, 0, 0, 0);
// Set icon when the mouse is OUT the button
if (strMouseOut)
{
// if (hIconOut == (int)BTNST_AUTO_GRAY)
// hIconOut = BTNST_AUTO_GRAY;
// else
hIconOut = (HICON)::LoadImage(hInstResource, strMouseOut, IMAGE_ICON, 0, 0, 0);
} // if
m_IconIn = hIconIn;
m_IconOut = hIconOut;
m_IconDraw = bDrawIcon;
}
示例9: Attach
BOOL CImageList::Create(LPCTSTR lpszBitmapID, int cx, int nGrow,
COLORREF crMask)
{
return Attach(ImageList_LoadBitmap(
AfxFindResourceHandle(lpszBitmapID, RT_BITMAP),
lpszBitmapID, cx, nGrow, crMask));
}
示例10: ASSERT
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
ASSERT(HIWORD(lpszTemplateName) == 0 ||
AfxIsValidString(lpszTemplateName));
m_lpszTemplateName = lpszTemplateName; // used for help
if (HIWORD(m_lpszTemplateName) == 0 && m_nIDHelp == 0)
m_nIDHelp = LOWORD((DWORD)m_lpszTemplateName);
#ifdef _DEBUG
if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
{
ASSERT(FALSE); // invalid dialog template name
PostNcDestroy(); // cleanup if Create fails too soon
return FALSE;
}
#endif //_DEBUG
HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(hInst, hResource);
BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
FreeResource(hTemplate);
return bResult;
}
示例11: AfxFindResourceHandle
BOOL CExtButton::SetBtnCursor(int nCursorId)
{
HINSTANCE hInstResource;
if( m_hCursor != NULL )
::DestroyCursor(m_hCursor);
m_hCursor = NULL;
if( nCursorId != -1 )
{
hInstResource =
AfxFindResourceHandle(
MAKEINTRESOURCE(nCursorId),
RT_GROUP_CURSOR
);
m_hCursor =
(HCURSOR)::LoadImage(
hInstResource,
MAKEINTRESOURCE(nCursorId),
IMAGE_CURSOR,
0,
0,
0
);
if( m_hCursor == NULL )
return FALSE;
}
return TRUE;
}
示例12: AfxFindResourceHandle
CChildFrame::CChildFrame()
{
// TODO: add member initialization code here
m_hChildFrameIcon = NULL;
HINSTANCE hInstResource =
AfxFindResourceHandle(
MAKEINTRESOURCE(IDR_MDITYPE),
RT_GROUP_ICON
);
ASSERT( hInstResource != NULL );
if( hInstResource != NULL )
{
m_hChildFrameIcon =
(HICON)::LoadImage(
hInstResource,
MAKEINTRESOURCE(IDR_MDITYPE),
IMAGE_ICON,
16,
16,
0
);
ASSERT( m_hChildFrameIcon != NULL );
}
}
示例13: ScreenToClient
BOOL CPreviewView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (nHitTest != HTCLIENT)
return CScrollView::OnSetCursor(pWnd, nHitTest, message);
CPoint point;
::GetCursorPos(&point);
ScreenToClient(&point); // client coordinates of mouse position
UINT nPage;
if (m_nZoomState != ZOOM_IN && FindPageRect(point, nPage))
{ // On a page and not zoomed all the way in
if (m_hMagnifyCursor == NULL)
{
HINSTANCE hInst = AfxFindResourceHandle(
MAKEINTRESOURCE(AFX_IDC_MAGNIFY), RT_GROUP_CURSOR);
m_hMagnifyCursor = ::LoadCursor(hInst,
MAKEINTRESOURCE(AFX_IDC_MAGNIFY));
}
::SetCursor(m_hMagnifyCursor);
}
else
{
::SetCursor(::LoadCursor(NULL, IDC_ARROW));
}
return 0;
}
示例14: AfxFindResourceHandle
BOOL CButtonST::SetBtnCursor(int nCursorId)
{
HINSTANCE hInstResource;
// Destroy any previous cursor
if (m_hCursor != NULL)
{
::DestroyCursor(m_hCursor);
}
m_hCursor = NULL;
// If we want a cursor
if (nCursorId != NULL)
{
hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(nCursorId),
RT_GROUP_CURSOR);
// Load icon resource
m_hCursor = (HCURSOR)::LoadImage(hInstResource/*AfxGetApp()->m_hInstance*/,
MAKEINTRESOURCE(nCursorId), IMAGE_CURSOR, 0, 0, 0);
// If something wrong then return FALSE
if (m_hCursor == NULL)
{
return FALSE;
}
}
return TRUE;
} // End of SetBtnCursor
示例15: sizeof
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
int iIndicatCount = sizeof(indicators)/sizeof(UINT);
if (!m_wndStatusBar.Create(this)
|| !m_wndStatusBar.SetIndicators(indicators,
iIndicatCount))
return -1;
m_wndStatusBar.SetPaneStyle(0, m_wndStatusBar.GetPaneStyle(0) | SBPS_STRETCH);
int i;
for (i = 1; i < iIndicatCount; i++)
{
m_wndStatusBar.SetPaneInfo(i, indicators[i], m_wndStatusBar.GetPaneStyle(i), 16);
m_wndStatusBar.SetPaneText(i, NULL);
}
m_progress.Create(this, NULL, 100, 1, TRUE);
UINT icons [] = {IDI_MODIFIED,IDI_READONLY,IDI_REPORT,IDI_MULTIDISK, IDI_EXCEPT};
ASSERT(sizeof (m_icons) / sizeof (HICON) == sizeof (icons) / sizeof (UINT));
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(IDR_MAINFRAME),RT_GROUP_ICON);
for (i = 0; i < sizeof (m_icons) / sizeof (HICON); i++)
m_icons[i] = (HICON)LoadImage(hInst,MAKEINTRESOURCE(icons[i]),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
return 0;
}