ATOM MyRegisterClass(CONST WNDCLASSW *wndClass) { if (g_IsNT) return RegisterClassW(wndClass); WNDCLASSA wndClassA; wndClassA.style = wndClass->style; wndClassA.lpfnWndProc = wndClass->lpfnWndProc; wndClassA.cbClsExtra = wndClass->cbClsExtra; wndClassA.cbWndExtra = wndClass->cbWndExtra; wndClassA.hInstance = wndClass->hInstance; wndClassA.hIcon = wndClass->hIcon; wndClassA.hCursor = wndClass->hCursor; wndClassA.hbrBackground = wndClass->hbrBackground; AString menuName; AString className; if (IS_INTRESOURCE(wndClass->lpszMenuName)) wndClassA.lpszMenuName = (LPCSTR)wndClass->lpszMenuName; else { menuName = GetSystemString(wndClass->lpszMenuName); wndClassA.lpszMenuName = menuName; } if (IS_INTRESOURCE(wndClass->lpszClassName)) wndClassA.lpszClassName = (LPCSTR)wndClass->lpszClassName; else { className = GetSystemString(wndClass->lpszClassName); wndClassA.lpszClassName = className; } return RegisterClassA(&wndClassA); }
bool CWindow::CreateEx(DWORD exStyle, LPCWSTR className, LPCWSTR windowName, DWORD style, int x, int y, int width, int height, HWND parentWindow, HMENU idOrHMenu, HINSTANCE instance, LPVOID createParam) { if (g_IsNT) { _window = ::CreateWindowExW(exStyle, className, windowName, style, x, y, width, height, parentWindow, idOrHMenu, instance, createParam); return (_window != NULL); } AString classNameA; LPCSTR classNameP; if (IS_INTRESOURCE(className)) classNameP = (LPCSTR)className; else { classNameA = GetSystemString(className); classNameP = classNameA; } AString windowNameA; LPCSTR windowNameP; if (IS_INTRESOURCE(windowName)) windowNameP = (LPCSTR)windowName; else { windowNameA = GetSystemString(windowName); windowNameP = windowNameA; } return CreateEx(exStyle, classNameP, windowNameP, style, x, y, width, height, parentWindow, idOrHMenu, instance, createParam); }
static BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR /*lParam*/) { g_uResNumber++; UINT uSize = 0; HRSRC hResInfo = FindResource(hModule, lpszName, lpszType); if (hResInfo) { uSize = SizeofResource(hModule, hResInfo); g_uTotalSize += uSize; } #if 0 TRACE(_T("%3u: "), g_uResNumber); if (IS_INTRESOURCE(lpszType)) { if ((DWORD)lpszType == (DWORD)RT_GROUP_ICON) TRACE(_T("RT_GROUP_ICON")); else if ((DWORD)lpszType == (DWORD)RT_ICON) TRACE(_T("RT_ICON")); else if ((DWORD)lpszType == (DWORD)RT_BITMAP) TRACE(_T("RT_BITMAP")); else TRACE(_T("type=%u"), (UINT)lpszType); } else TRACE(_T("type=\"%s\""), lpszType); TRACE(_T(" size=%5u"), uSize); if (IS_INTRESOURCE(lpszName)) TRACE(_T(" name=*%u"), (UINT)lpszName); else TRACE(_T(" name=\"%s\""), lpszName); TRACE(_T("\n")); #endif return TRUE; }
int WResLoadResourceX( PHANDLE_INFO hinfo, lpcstr idType, lpcstr idResource, lpstr *lpszBuffer, size_t *bufferSize ) /*************************************************************************/ { WResID *resource_type; WResID *resource_id; int rc; if( IS_INTRESOURCE( idResource ) ) { resource_id = WResIDFromNum( (uint_16)RESOURCE2INT( idResource ) ); } else { resource_id = WResIDFromStrF( idResource ); } if( IS_INTRESOURCE( idType ) ) { resource_type = WResIDFromNum( (uint_16)RESOURCE2INT( idType ) ); } else { resource_type = WResIDFromStrF( idType ); } rc = WResLoadResource2( MainDir, hinfo, resource_type, resource_id, lpszBuffer, bufferSize ); if( resource_type != NULL ) WResIDFree( resource_type ); if( resource_id != NULL ) WResIDFree( resource_id ); return( rc ); }
/*********************************************************************** * call_hook_AtoW */ static LRESULT call_hook_AtoW( HOOKPROC proc, INT id, INT code, WPARAM wparam, LPARAM lparam ) { LRESULT ret; UNICODE_STRING usBuffer; if (id != WH_CBT || code != HCBT_CREATEWND) ret = proc( code, wparam, lparam ); else { CBT_CREATEWNDA *cbtcwA = (CBT_CREATEWNDA *)lparam; CBT_CREATEWNDW cbtcwW; CREATESTRUCTW csW; LPWSTR nameW = NULL; LPWSTR classW = NULL; cbtcwW.lpcs = &csW; cbtcwW.hwndInsertAfter = cbtcwA->hwndInsertAfter; csW = *(CREATESTRUCTW *)cbtcwA->lpcs; if (!IS_INTRESOURCE(cbtcwA->lpcs->lpszName)) { RtlCreateUnicodeStringFromAsciiz(&usBuffer,cbtcwA->lpcs->lpszName); csW.lpszName = nameW = usBuffer.Buffer; } if (!IS_INTRESOURCE(cbtcwA->lpcs->lpszClass)) { RtlCreateUnicodeStringFromAsciiz(&usBuffer,cbtcwA->lpcs->lpszClass); csW.lpszClass = classW = usBuffer.Buffer; } ret = proc( code, wparam, (LPARAM)&cbtcwW ); cbtcwA->hwndInsertAfter = cbtcwW.hwndInsertAfter; HeapFree( GetProcessHeap(), 0, nameW ); HeapFree( GetProcessHeap(), 0, classW ); } return ret; }
// Moves every item right and gives it the WS_EX_RIGHT extended style void CDialogTemplate::ConvertToRTL() { for (unsigned int i = 0; i < m_vItems.size(); i++) { bool addExStyle = false; // Button if (int(m_vItems[i]->szClass) == 0x80) { m_vItems[i]->dwStyle ^= BS_LEFTTEXT; m_vItems[i]->dwStyle ^= BS_RIGHT; m_vItems[i]->dwStyle ^= BS_LEFT; if ((m_vItems[i]->dwStyle & (BS_LEFT|BS_RIGHT)) == (BS_LEFT|BS_RIGHT)) { m_vItems[i]->dwStyle ^= BS_LEFT; m_vItems[i]->dwStyle ^= BS_RIGHT; if (m_vItems[i]->dwStyle & (BS_RADIOBUTTON|BS_CHECKBOX|BS_USERBUTTON)) { m_vItems[i]->dwStyle |= BS_RIGHT; } } } // Edit else if (int(m_vItems[i]->szClass) == 0x81) { if ((m_vItems[i]->dwStyle & ES_CENTER) == 0) { m_vItems[i]->dwStyle ^= ES_RIGHT; } } // Static else if (int(m_vItems[i]->szClass) == 0x82) { if ((m_vItems[i]->dwStyle & SS_TYPEMASK) == SS_LEFT || (m_vItems[i]->dwStyle & SS_TYPEMASK) == SS_LEFTNOWORDWRAP) { m_vItems[i]->dwStyle &= ~SS_TYPEMASK; m_vItems[i]->dwStyle |= SS_RIGHT; } else if ((m_vItems[i]->dwStyle & SS_TYPEMASK) == SS_ICON) { m_vItems[i]->dwStyle |= SS_CENTERIMAGE; } } else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !strcmpi(m_vItems[i]->szClass, "RichEdit20A")) { if ((m_vItems[i]->dwStyle & ES_CENTER) == 0) { m_vItems[i]->dwStyle ^= ES_RIGHT; } } else if (!IS_INTRESOURCE(m_vItems[i]->szClass) && !strcmpi(m_vItems[i]->szClass, "SysTreeView32")) { m_vItems[i]->dwStyle |= TVS_RTLREADING; addExStyle = true; } else addExStyle = true; if (addExStyle) m_vItems[i]->dwExtStyle |= WS_EX_RIGHT; m_vItems[i]->dwExtStyle |= WS_EX_RTLREADING; m_vItems[i]->sX = m_sWidth - m_vItems[i]->sWidth - m_vItems[i]->sX; } m_dwExtStyle |= WS_EX_RIGHT | WS_EX_RTLREADING; }
/*********************************************************************** * OleUIPasteSpecialA (OLEDLG.4) */ UINT WINAPI OleUIPasteSpecialA(LPOLEUIPASTESPECIALA psA) { OLEUIPASTESPECIALW ps; UINT ret; TRACE("(%p)\n", psA); memcpy(&ps, psA, psA->cbStruct); ps.lpszCaption = strdupAtoW(psA->lpszCaption); if(!IS_INTRESOURCE(ps.lpszTemplate)) ps.lpszTemplate = strdupAtoW(psA->lpszTemplate); if(psA->cPasteEntries > 0) { DWORD size = psA->cPasteEntries * sizeof(ps.arrPasteEntries[0]); UINT i; ps.arrPasteEntries = HeapAlloc(GetProcessHeap(), 0, size); memcpy(ps.arrPasteEntries, psA->arrPasteEntries, size); for(i = 0; i < psA->cPasteEntries; i++) { ps.arrPasteEntries[i].lpstrFormatName = strdupAtoW(psA->arrPasteEntries[i].lpstrFormatName); ps.arrPasteEntries[i].lpstrResultText = strdupAtoW(psA->arrPasteEntries[i].lpstrResultText); } } ret = OleUIPasteSpecialW(&ps); if(psA->cPasteEntries > 0) { UINT i; for(i = 0; i < psA->cPasteEntries; i++) { HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.arrPasteEntries[i].lpstrFormatName); HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.arrPasteEntries[i].lpstrResultText); } HeapFree(GetProcessHeap(), 0, ps.arrPasteEntries); } if(!IS_INTRESOURCE(ps.lpszTemplate)) HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.lpszTemplate); HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.lpszCaption); /* Copy back the output fields */ psA->dwFlags = ps.dwFlags; psA->lpSrcDataObj = ps.lpSrcDataObj; psA->nSelectedIndex = ps.nSelectedIndex; psA->fLink = ps.fLink; psA->hMetaPict = ps.hMetaPict; psA->sizel = ps.sizel; return ret; }
//-------------------------------------------------------------------------------------- int DialogResourceManager::AddTexture( LPCWSTR strResourceName, HMODULE hResourceModule ) { // See if this texture already exists for( int i=0; i < (int)m_TextureCache.size(); i++ ) { TextureNode* pTextureNode = m_TextureCache.at(i); if( !pTextureNode->bFileSource && // Sources must match pTextureNode->hResourceModule == hResourceModule ) // Module handles must match { if( IS_INTRESOURCE( strResourceName ) ) { // Integer-based ID if( (INT_PTR)strResourceName == pTextureNode->nResourceID ) return i; } else { // String-based ID size_t nLen = 0; StringCchLength( strResourceName, MAX_PATH, &nLen ); if( 0 == _wcsnicmp( pTextureNode->strFilename, strResourceName, nLen ) ) return i; } } } // Add a new texture and try to create it TextureNode* pNewTextureNode = new TextureNode(); if( pNewTextureNode == NULL ) return -1; ZeroMemory( pNewTextureNode, sizeof(TextureNode) ); pNewTextureNode->hResourceModule = hResourceModule; if( IS_INTRESOURCE( strResourceName ) ) { pNewTextureNode->nResourceID = (int)(size_t)strResourceName; } else { pNewTextureNode->nResourceID = 0; StringCchCopy( pNewTextureNode->strFilename, MAX_PATH, strResourceName ); } m_TextureCache.push_back( pNewTextureNode ); int iTexture = (int)m_TextureCache.size()-1; // If a device is available, try to create immediately if( m_pd3d9Device ) CreateTexture9( iTexture ); return iTexture; }
BOOL CALLBACK CResModule::EnumResWriteLangCallback(HMODULE /*hModule*/, LPCTSTR lpszType, LPTSTR lpszName, WORD wLanguage, LONG_PTR lParam) { BOOL bRes = FALSE; CResModule* lpResModule = (CResModule*)lParam; int count = 0; do { lpResModule->m_hUpdateRes = BeginUpdateResource(lpResModule->sDestFile.c_str(), FALSE); if (lpResModule->m_hUpdateRes == NULL) Sleep(100); count++; } while ((lpResModule->m_hUpdateRes == NULL)&&(count < 5)); if (lpszType == RT_STRING) { if (IS_INTRESOURCE(lpszName)) { bRes = lpResModule->ReplaceString(LOWORD(lpszName), wLanguage); } } else if (lpszType == RT_MENU) { if (IS_INTRESOURCE(lpszName)) { bRes = lpResModule->ReplaceMenu(LOWORD(lpszName), wLanguage); } } else if (lpszType == RT_DIALOG) { if (IS_INTRESOURCE(lpszName)) { bRes = lpResModule->ReplaceDialog(LOWORD(lpszName), wLanguage); } } else if (lpszType == RT_ACCELERATOR) { if (IS_INTRESOURCE(lpszName)) { bRes = lpResModule->ReplaceAccelerator(LOWORD(lpszName), wLanguage); } } if (!EndUpdateResource(lpResModule->m_hUpdateRes, !bRes)) MYERROR; return bRes; }
CString CXTPTaskDialogFrame::GetFrameTitle() const { CString strWindowTitle; if (m_pConfig->pszWindowTitle != NULL) { if (IS_INTRESOURCE(m_pConfig->pszWindowTitle)) { XTPLoadStringInst(m_pConfig->hInstance, (UINT)(UINT_PTR)m_pConfig->pszWindowTitle, &strWindowTitle); } else { strWindowTitle = m_pConfig->pszWindowTitle; } } if (strWindowTitle.IsEmpty()) { TCHAR szModuleName[_MAX_PATH]; ::GetModuleFileName(AfxGetInstanceHandle(), szModuleName, _MAX_PATH); TCHAR szFileName[_MAX_FNAME], szExt[_MAX_EXT]; SPLITPATH_S(szModuleName, NULL, NULL, szFileName, szExt); strWindowTitle.Format(_T("%s%s"), szFileName, szExt); } return strWindowTitle; }
static void dump_pastespecial(const OLEUIPASTESPECIALW *ps) { UINT i; dump_ps_flags(ps->dwFlags); TRACE("hwnd %p caption %s hook %p custdata %lx\n", ps->hWndOwner, debugstr_w(ps->lpszCaption), ps->lpfnHook, ps->lCustData); if(IS_INTRESOURCE(ps->lpszTemplate)) TRACE("hinst %p template %04x hresource %p\n", ps->hInstance, (WORD)(ULONG_PTR)ps->lpszTemplate, ps->hResource); else TRACE("hinst %p template %s hresource %p\n", ps->hInstance, debugstr_w(ps->lpszTemplate), ps->hResource); TRACE("dataobj %p arrpasteent %p cpasteent %d arrlinktype %p clinktype %d\n", ps->lpSrcDataObj, ps->arrPasteEntries, ps->cPasteEntries, ps->arrLinkTypes, ps->cLinkTypes); TRACE("cclsidex %d lpclsidex %p nselect %d flink %d hmetapict %p size(%d,%d)\n", ps->cClsidExclude, ps->lpClsidExclude, ps->nSelectedIndex, ps->fLink, ps->hMetaPict, ps->sizel.cx, ps->sizel.cy); for(i = 0; i < ps->cPasteEntries; i++) { TRACE("arrPasteEntries[%d]: cFormat %08x pTargetDevice %p dwAspect %d lindex %d tymed %d\n", i, ps->arrPasteEntries[i].fmtetc.cfFormat, ps->arrPasteEntries[i].fmtetc.ptd, ps->arrPasteEntries[i].fmtetc.dwAspect, ps->arrPasteEntries[i].fmtetc.lindex, ps->arrPasteEntries[i].fmtetc.tymed); TRACE("\tformat name %s result text %s flags %04x\n", debugstr_w(ps->arrPasteEntries[i].lpstrFormatName), debugstr_w(ps->arrPasteEntries[i].lpstrResultText), ps->arrPasteEntries[i].dwFlags); } for(i = 0; i < ps->cLinkTypes; i++) TRACE("arrLinkTypes[%d] %08x\n", i, ps->arrLinkTypes[i]); for(i = 0; i < ps->cClsidExclude; i++) TRACE("lpClsidExclude[%d] %s\n", i, debugstr_guid(&ps->lpClsidExclude[i])); }
HCURSOR SResProviderMgr::LoadCursor( LPCTSTR pszResName ,BOOL bFromFile /*= FALSE*/) { SAutoLock lock(m_cs); if(IS_INTRESOURCE(pszResName)) return ::LoadCursor(NULL, pszResName); else { LPCTSTR pszCursorID=SysCursorName2ID(pszResName); if(pszCursorID) return ::LoadCursor(NULL, pszCursorID); } const CURSORMAP::CPair * pPair = m_mapCachedCursor.Lookup(pszResName); if(pPair) return pPair->m_value; HCURSOR hRet = NULL; if(bFromFile) { hRet = SResLoadFromFile::LoadCursor(pszResName); }else { IResProvider *pResProvider=GetMatchResProvider(KTypeCursor,pszResName); if(pResProvider) hRet =pResProvider->LoadCursor(pszResName); } if(hRet) { m_mapCachedCursor[pszResName]=hRet; } return hRet; }
/* * @implemented */ HWND WINAPI FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow) { LPWSTR titleW = NULL; HWND hwnd = 0; if (lpszWindow) { DWORD len = MultiByteToWideChar( CP_ACP, 0, lpszWindow, -1, NULL, 0 ); if (!(titleW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0; MultiByteToWideChar( CP_ACP, 0, lpszWindow, -1, titleW, len ); } if (!IS_INTRESOURCE(lpszClass)) { WCHAR classW[256]; if (MultiByteToWideChar( CP_ACP, 0, lpszClass, -1, classW, sizeof(classW)/sizeof(WCHAR) )) hwnd = FindWindowExW( hwndParent, hwndChildAfter, classW, titleW ); } else { hwnd = FindWindowExW( hwndParent, hwndChildAfter, (LPCWSTR)lpszClass, titleW ); } HeapFree( GetProcessHeap(), 0, titleW ); return hwnd; }
void CColorDialog::Dump( CDumpContext &dc ) const /***********************************************/ { CCommonDialog::Dump( dc ); dc << "m_cc.lStructSize = " << m_cc.lStructSize << "\n"; dc << "m_cc.hwndOwner = " << m_cc.hwndOwner << "\n"; dc << "m_cc.hInstance = " << m_cc.hInstance << "\n"; dc << "m_cc.rgbResult = "; dc.DumpAsHex( m_cc.rgbResult ); dc << "\n"; dc << "m_cc.lpCustColors = " << m_cc.lpCustColors << "\n"; dc << "m_cc.Flags = "; dc.DumpAsHex( m_cc.Flags ); dc << "\n"; dc << "m_cc.lCustData = "; dc.DumpAsHex( m_cc.lCustData ); dc << "\n"; if( m_cc.lpfnHook == AfxCommDlgProc ) { dc << "m_cc.lpfnHook = AfxCommDlgProc\n"; } else { dc << "m_cc.lpfnHook = " << m_cc.lpfnHook << "\n"; } if( IS_INTRESOURCE( m_cc.lpTemplateName ) ) { dc << "m_cc.lpTemplateName = " << (UINT)m_cc.lpTemplateName << "\n"; } else { dc << "m_cc.lpTemplateName = " << m_cc.lpTemplateName << "\n"; } }
CTaskDialog::HeapResString::HeapResString(HINSTANCE hInstance, LPCWSTR lpwsz) : b_heap(true) , lpwsz_(0) { if (IS_INTRESOURCE(lpwsz)) { // load entire resource string in a heap-allocated buffer #pragma warning (push) #pragma warning (disable: 4311) DWORD dwSize = 128; DWORD dwLen = 0; wsz_ = reinterpret_cast<WCHAR*>(::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, (dwSize + 1) * sizeof(WCHAR))); while ((dwLen = ::LoadString(hInstance, reinterpret_cast<UINT>(lpwsz), wsz_, dwSize)) == dwSize - 1) { dwSize *= 1.50; wsz_ = reinterpret_cast<WCHAR*>(::HeapReAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, wsz_, (dwSize + 1) * sizeof(WCHAR))); } #pragma warning (pop) } else { b_heap = false; lpwsz_ = lpwsz; } }
// @pymethod <o PyCPropertyPage>|win32ui|CreatePropertyPage|Creates a property page object. PyObject *PyCPropertyPage::create( PyObject *self, PyObject *args ) { TCHAR *Template=NULL; PyObject *obTemplate = NULL; int idCaption = 0; if (!PyArg_ParseTuple(args,"O|i", &obTemplate, // @pyparm <o PyResourceId>|resource||String template name or inteter resource ID to use for the page. &idCaption)) // @pyparm int|caption|0|The ID if the string resource to use for the caption. return NULL; CPythonPropertyPage *pPP; if (!PyWinObject_AsResourceId(obTemplate, &Template, FALSE)) return NULL; if (IS_INTRESOURCE(Template)){ if (!PropSheetCheckForPageCreate((UINT)Template)) return NULL; GUI_BGN_SAVE; pPP = new CPythonPropertyPage((UINT)Template, idCaption); GUI_END_SAVE; } else{ if (!PropSheetCheckForPageCreate(Template)) return NULL; GUI_BGN_SAVE; pPP = new CPythonPropertyPage(Template, idCaption); GUI_END_SAVE; } PyWinObject_FreeResourceId(Template); PyCPropertyPage *ret = (PyCPropertyPage *)ui_assoc_object::make( PyCPropertyPage::type, pPP); return ret; }
// @pymethod <o PyCPropertySheet>|win32ui|CreatePropertySheet|Creates a property sheet object. PyObject *PyCPropertySheet::create( PyObject *self, PyObject *args ) { PyObject *obParent = NULL, *obCaption; TCHAR *Caption; CWnd *pParent = NULL; int iSelect = 0; if (!PyArg_ParseTuple(args,"O|Oi", &obCaption, // @pyparm <o PyResourceId>|caption||The caption for the property sheet, or id of the caption &obParent, // @pyparm <o PyCWnd>|parent|None|The parent window of the property sheet. &iSelect)) // @pyparm int|select|0|The index of the first page to be selected. return NULL; if (obParent) { if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type)) RETURN_TYPE_ERR("parameter 2 must be a PyCWnd object"); pParent = (CWnd *)PyCWnd::GetPythonGenericWnd(obParent); } CPythonPropertySheet *pPS; if (!PyWinObject_AsResourceId(obCaption, &Caption, FALSE)) return NULL; if (IS_INTRESOURCE(Caption)){ GUI_BGN_SAVE; pPS = new CPythonPropertySheet(MAKEINTRESOURCE(Caption), pParent, iSelect); GUI_END_SAVE; } else{ GUI_BGN_SAVE; pPS = new CPythonPropertySheet(Caption, pParent, iSelect); GUI_END_SAVE; } PyWinObject_FreeResourceId(Caption); PyCPropertySheet *ret = (PyCPropertySheet *)ui_assoc_object::make( PyCPropertySheet::type, pPS); return ret; }
string16 ResourceBundle::GetLocalizedString(int message_id) { // 如果没有本地纯资源DLL, 返回一个空字符串(比崩溃好). if(!locale_resources_data_) { base::StackTrace().PrintBacktrace(); // See http://crbug.com/21925. LOG(WARNING) << "locale resources are not loaded"; return string16(); } DCHECK(IS_INTRESOURCE(message_id)); // Get a reference directly to the string resource. HINSTANCE hinstance = locale_resources_data_; const STRINGRESOURCEIMAGE* image = GetStringResourceImage(hinstance, message_id); if(!image) { base::StackTrace().PrintBacktrace(); // See http://crbug.com/21925. NOTREACHED() << "unable to find resource: " << message_id; return std::wstring(); } // Copy into a string16 and return. return string16(image->achString, image->nLength); }
wxIcon GetApplicationIcon() { HMODULE hParentExe = GetModuleHandle(NULL); if ( !hParentExe ) return wxNullIcon; LPTSTR iconName = 0; EnumResourceNames(hParentExe, RT_GROUP_ICON, GetFirstIconProc, (LONG_PTR)&iconName); if ( GetLastError() != ERROR_SUCCESS && GetLastError() != ERROR_RESOURCE_ENUM_USER_STOP ) return wxNullIcon; HANDLE hIcon = LoadImage(hParentExe, iconName, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR); if ( !IS_INTRESOURCE(iconName) ) free(iconName); if ( !hIcon ) return wxNullIcon; wxIcon icon; icon.SetHICON(static_cast<WXHICON>(hIcon)); icon.SetWidth(48); icon.SetHeight(48); return icon; }
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam ) { WCHAR szName[100]; int index; HICON hIcon; PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam; if (IS_INTRESOURCE(lpszName)) swprintf(szName, L"%u", lpszName); else wcscpy(szName, (WCHAR*)lpszName); hIcon = LoadIconW(pIconContext->hLibrary, (LPCWSTR)lpszName); if (hIcon == NULL) return TRUE; index = SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)szName); if (index != LB_ERR) SendMessageW(pIconContext->hDlgCtrl, LB_SETITEMDATA, index, (LPARAM)hIcon); return TRUE; }
// @pymethod |PyCDialogBar|CreateWindow|Creates the window for the <o PyCDialogBar> object. static PyObject *PyCDialogBar_CreateWindow(PyObject *self, PyObject *args) { TCHAR *szTemplate; UINT style, id; PyObject *obParent, *obTemplate; // @pyparm <o PyCWnd>|parent||The parent window // @pyparm <o PyResourceId>|template||Template name or integer resource id // @pyparm int|style||The style for the window // @pyparm int|id||The ID of the window if (!PyArg_ParseTuple(args, "OOii", &obParent, &obTemplate, &style, &id)) return NULL; CDialogBar *pDialog = PyCDialogBar::GetDialogBar(self); if (pDialog==NULL) return NULL; CWnd *pParent = NULL; if (obParent != Py_None) { pParent = PyCWnd::GetPythonGenericWnd(obParent, &PyCWnd::type); if (pParent==NULL) RETURN_TYPE_ERR("The parent window is not a valid PyCWnd"); } if (!PyWinObject_AsResourceId(obTemplate, &szTemplate, FALSE)) return NULL; BOOL rc; GUI_BGN_SAVE; if (IS_INTRESOURCE(szTemplate)) rc=pDialog->Create(pParent, MAKEINTRESOURCE(szTemplate), style, id); else rc=pDialog->Create(pParent, szTemplate, style, id); GUI_END_SAVE; PyWinObject_FreeResourceId(szTemplate); if (!rc) RETURN_ERR("CDialogBar::Create failed"); RETURN_NONE; }
/********************************************************************** * find_entry_by_name * * Find an entry by name in a resource directory */ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_name( const IMAGE_RESOURCE_DIRECTORY *dir, LPCWSTR name, const void *root, int want_dir ) { const IMAGE_RESOURCE_DIRECTORY_ENTRY *entry; const IMAGE_RESOURCE_DIR_STRING_U *str; int min, max, res, pos, namelen; if (IS_INTRESOURCE(name)) return find_entry_by_id( dir, LOWORD(name), root, want_dir ); entry = (const IMAGE_RESOURCE_DIRECTORY_ENTRY *)(dir + 1); namelen = strlenW(name); min = 0; max = dir->NumberOfNamedEntries - 1; while (min <= max) { pos = (min + max) / 2; str = (const IMAGE_RESOURCE_DIR_STRING_U *)((const char *)root + entry[pos].u.s.NameOffset); res = strncmpW( name, str->NameString, str->Length ); if (!res && namelen == str->Length) { if (!entry[pos].u2.s2.DataIsDirectory == !want_dir) { TRACE("root %p dir %p name %s ret %p\n", root, dir, debugstr_w(name), (const char*)root + entry[pos].u2.s2.OffsetToDirectory); return (const IMAGE_RESOURCE_DIRECTORY *)((const char *)root + entry[pos].u2.s2.OffsetToDirectory); } break; } if (res < 0) max = pos - 1; else min = pos + 1; } TRACE("root %p dir %p name %s not found\n", root, dir, debugstr_w(name) ); return NULL; }
static void LocalizedMessageBox(LPCTSTR lpMessage, LPCTSTR lpTitle, DWORD dwFlags) { HMODULE hModule; TCHAR szTitle[256]; TCHAR szMessage[256]; hModule = GetModuleHandle(NULL); if (IS_INTRESOURCE(lpMessage)) { LoadString(hModule, (UINT)lpMessage, szMessage, sizeof(szMessage)/sizeof(szMessage[0])); lpMessage = szMessage; } if (IS_INTRESOURCE(lpTitle)) { LoadString(hModule, (UINT)lpTitle, szTitle, sizeof(szTitle)/sizeof(szTitle[0])); lpTitle = szTitle; } MessageBox(NULL, lpMessage, lpTitle, dwFlags); }
BOOL CALLBACK GetFirstIconProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam) { if (IS_INTRESOURCE(lpszName)) *((LPTSTR*)lParam) = lpszName; else *((LPTSTR*)lParam) = _tcsdup(lpszName); return FALSE; // stop on the first icon found }
static BOOL CALLBACK EnumResLangProc( HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam ) { if (IS_INTRESOURCE(lpszName)) { std::vector<std::pair<int,WORD>> &oldStrings=*(std::vector<std::pair<int,WORD>>*)lParam; oldStrings.push_back(std::pair<int,WORD>(PtrToInt(lpszName),wIDLanguage)); } return TRUE; }
/* MAKE_EXPORT LoadBitmapW_new=LoadBitmapW */ HBITMAP WINAPI LoadBitmapW_new(HINSTANCE hInstance, LPCWSTR lpBitmapNameW) { if(IS_INTRESOURCE(lpBitmapNameW)) return LoadBitmapA(hInstance, (LPCSTR)lpBitmapNameW); ALLOC_WtoA(lpBitmapName); return LoadBitmapA(hInstance, lpBitmapNameA); }
/* MAKE_EXPORT LoadCursorW_new=LoadCursorW */ HCURSOR WINAPI LoadCursorW_new(HINSTANCE hInstance, LPCWSTR lpCursorNameW) { if(IS_INTRESOURCE(lpCursorNameW)) return LoadCursorA(hInstance, (LPCSTR)lpCursorNameW); ALLOC_WtoA(lpCursorName); return LoadCursorA(hInstance, lpCursorNameA); }
/* MAKE_EXPORT LoadIconW_new=LoadIconW */ HICON WINAPI LoadIconW_new(HINSTANCE hInstance, LPCWSTR lpIconNameW) { if(IS_INTRESOURCE(lpIconNameW)) return LoadIconA(hInstance, (LPCSTR)lpIconNameW); ALLOC_WtoA(lpIconName); return LoadIconA(hInstance, lpIconNameA); }
/* MAKE_EXPORT LoadImageW_new=LoadImageW */ HANDLE WINAPI LoadImageW_new(HINSTANCE hinst, LPCWSTR lpszNameW, UINT uType, int cxDesired, int cyDesired, UINT fuLoad) { if(IS_INTRESOURCE(lpszNameW)) return LoadImageA(hinst, (LPCSTR)lpszNameW, uType, cxDesired, cyDesired, fuLoad); ALLOC_WtoA(lpszName); return LoadImageA(hinst, lpszNameA, uType, cxDesired, cyDesired, fuLoad); }
HRESULT csMenu::InvokeCommand(CMINVOKECOMMANDINFO *pici) { if( IS_INTRESOURCE(pici->lpVerb) == FALSE ) { return E_INVALIDARG; } const UINT cmd = (ULONG_PTR)pici->lpVerb; return executeCommand(cmd, _files) ? S_OK : E_INVALIDARG; }