static LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_CREATE: globals.hTree = CreateWindowW(WC_TREEVIEWW, NULL, WS_CHILD|WS_VISIBLE|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT, 0, 0, 0, 0, hWnd, (HMENU)TREE_WINDOW, globals.hMainInst, NULL); AddTreeEx(); break; case WM_NOTIFY: if((int)wParam != TREE_WINDOW) break; switch(((LPNMHDR)lParam)->code) { case TVN_ITEMEXPANDINGW: CreateInst(((NMTREEVIEWW *)lParam)->itemNew.hItem, NULL); break; case TVN_SELCHANGEDW: RefreshMenu(((NMTREEVIEWW *)lParam)->itemNew.hItem); RefreshDetails(((NMTREEVIEWW *)lParam)->itemNew.hItem); break; } break; case WM_SIZE: MoveWindow(globals.hTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); break; default: return DefWindowProcW(hWnd, uMsg, wParam, lParam); } return 0; }
SharedPointer < Type > ResourceManager < Type > ::Create( const MapilTChar* pKeyStr ) { SharedPointer < Type > newResource = CreateInst(); #ifdef LIB_STL std::map < std::basic_string < MapilTChar >, SharedPointer < Type > > ::iterator it = m_Holder.find( pKeyStr ); // Not found. if( it == m_Holder.end() ){ newResource = CreateInst(); m_Holder.insert( std::pair < std::basic_string < MapilTChar >, SharedPointer < Type > > ( pKeyStr, newResource ) ); } // Found. else{ newResource = it->second; } //m_Holder.insert( std::pair < std::basic_string < MapilTChar >, SharedPointer < Type > > ( pKeyStr, newResource ) ); #endif return newResource; }
static int MenuCommand(WPARAM wParam, HWND hWnd) { BOOL vis; HTREEITEM hSelect; WCHAR wszAbout[MAX_LOAD_STRING]; WCHAR wszAboutVer[MAX_LOAD_STRING]; switch(wParam) { case IDM_ABOUT: LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout, sizeof(wszAbout)/sizeof(wszAbout[0])); LoadStringW(globals.hMainInst, IDS_ABOUTVER, wszAboutVer, sizeof(wszAboutVer)/sizeof(wszAboutVer[0])); ShellAboutW(hWnd, wszAbout, wszAboutVer, NULL); break; case IDM_COPYCLSID: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CopyClsid(hSelect); break; case IDM_HTMLTAG: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CopyHTMLTag(hSelect); break; case IDM_CREATEINST: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CreateInst(hSelect, NULL); SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect); break; case IDM_CREATEINSTON: if(DialogBoxW(0, MAKEINTRESOURCEW(DLG_CREATEINSTON), hWnd, CreateInstOnProc) == IDCANCEL) break; hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); CreateInst(hSelect, globals.wszMachineName); SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect); break; case IDM_RELEASEINST: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); ReleaseInst(hSelect); RefreshMenu(hSelect); RefreshDetails(hSelect); break; case IDM_EXPERT: globals.bExpert = !globals.bExpert; CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), globals.bExpert ? MF_CHECKED : MF_UNCHECKED); EmptyTree(); if(globals.bExpert) AddTreeEx(); else AddTree(); hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT); SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect); RefreshMenu(hSelect); break; case IDM_FLAG_INSERV: vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_INHANDL: vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_LOCSERV: vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_REMSERV: vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_REFRESH: EmptyTree(); if(globals.bExpert) AddTreeEx(); else AddTree(); hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT); SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect); RefreshMenu(hSelect); break; case IDM_REGEDIT: { STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR app[MAX_PATH]; GetWindowsDirectoryW( app, MAX_PATH - sizeof(wszRegEdit)/sizeof(WCHAR) ); lstrcatW( app, wszRegEdit ); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); if (CreateProcessW(app, app, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } break; } case IDM_STATUSBAR: vis = IsWindowVisible(globals.hStatusBar); ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW); CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); ResizeChild(); break; case IDM_SYSCONF: DialogBoxW(0, MAKEINTRESOURCEW(DLG_SYSCONF), hWnd, SysConfProc); break; case IDM_TOOLBAR: vis = IsWindowVisible(globals.hToolBar); ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW); CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); ResizeChild(); break; case IDM_TYPELIB: { static const WCHAR filterW[] = {'%','s','%','c','*','.','t','l','b',';','*','.','o','l','b',';','*','.','d','l','l',';','*','.','o','c','x',';','*','.','e','x','e','%','c','%','s','%','c','*','.','*','%','c',0}; OPENFILENAMEW ofn; static WCHAR wszTitle[MAX_LOAD_STRING]; static WCHAR wszName[MAX_LOAD_STRING]; WCHAR filter_typelib[MAX_LOAD_STRING], filter_all[MAX_LOAD_STRING], filter[MAX_PATH]; LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0])); LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_TYPELIB, filter_typelib, sizeof(filter_typelib)/sizeof(WCHAR)); LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_ALL, filter_all, sizeof(filter_all)/sizeof(WCHAR)); snprintfW( filter, MAX_PATH, filterW, filter_typelib, 0, 0, filter_all, 0, 0 ); InitOpenFileName(hWnd, &ofn, filter, wszTitle, wszName); if(GetOpenFileNameW(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName); break; } case IDM_VIEW: hSelect = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM, TVGN_CARET, 0); if(IsInterface(hSelect)) InterfaceViewer(hSelect); else CreateTypeLibWindow(globals.hMainInst, NULL); break; case IDM_EXIT: DestroyWindow(hWnd); break; } return 0; }
static int MenuCommand(WPARAM wParam, HWND hWnd) { BOOL vis; HTREEITEM hSelect; WCHAR wszAbout[MAX_LOAD_STRING]; WCHAR wszAboutVer[MAX_LOAD_STRING]; switch(wParam) { case IDM_ABOUT: LoadString(globals.hMainInst, IDS_ABOUT, wszAbout, sizeof(WCHAR[MAX_LOAD_STRING])); LoadString(globals.hMainInst, IDS_ABOUTVER, wszAboutVer, sizeof(WCHAR[MAX_LOAD_STRING])); ShellAbout(hWnd, wszAbout, wszAboutVer, NULL); break; case IDM_COPYCLSID: hSelect = TreeView_GetSelection(globals.hTree); CopyClsid(hSelect); break; case IDM_HTMLTAG: hSelect = TreeView_GetSelection(globals.hTree); CopyHTMLTag(hSelect); break; case IDM_CREATEINST: hSelect = TreeView_GetSelection(globals.hTree); CreateInst(hSelect, NULL); SendMessage(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect); break; case IDM_CREATEINSTON: if(DialogBox(0, MAKEINTRESOURCE(DLG_CREATEINSTON), hWnd, CreateInstOnProc) == IDCANCEL) break; hSelect = TreeView_GetSelection(globals.hTree); CreateInst(hSelect, globals.wszMachineName); SendMessage(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect); break; case IDM_RELEASEINST: hSelect = TreeView_GetSelection(globals.hTree); ReleaseInst(hSelect); RefreshMenu(hSelect); RefreshDetails(hSelect); break; case IDM_EXPERT: globals.bExpert = !globals.bExpert; CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), globals.bExpert ? MF_CHECKED : MF_UNCHECKED); EmptyTree(); if(globals.bExpert) AddTreeEx(); else AddTree(); hSelect = TreeView_GetChild(globals.hTree, TVI_ROOT); SendMessage(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect); RefreshMenu(hSelect); break; case IDM_FLAG_INSERV: vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_INHANDL: vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_LOCSERV: vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_FLAG_REMSERV: vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER; globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER); globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER); if(!globals.dwClsCtx) globals.dwClsCtx = vis; else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); break; case IDM_REFRESH: EmptyTree(); if(globals.bExpert) AddTreeEx(); else AddTree(); hSelect = TreeView_GetChild(globals.hTree, TVI_ROOT); SendMessage(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect); RefreshMenu(hSelect); break; case IDM_REGEDIT: { STARTUPINFO si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si)); si.cb = sizeof(si); CreateProcess(NULL, wszRegEdit, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); break; } case IDM_STATUSBAR: vis = IsWindowVisible(globals.hStatusBar); ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW); CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); ResizeChild(); break; case IDM_SYSCONF: DialogBox(0, MAKEINTRESOURCE(DLG_SYSCONF), hWnd, SysConfProc); break; case IDM_TOOLBAR: vis = IsWindowVisible(globals.hToolBar); ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW); CheckMenuItem(GetMenu(hWnd), LOWORD(wParam), vis ? MF_UNCHECKED : MF_CHECKED); ResizeChild(); break; case IDM_TYPELIB: { OPENFILENAME ofn; static WCHAR wszTitle[MAX_LOAD_STRING]; static WCHAR wszName[MAX_LOAD_STRING]; static WCHAR wszFilter[MAX_LOAD_STRING]; LoadString(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)); LoadString(globals.hMainInst, IDS_OPEN_TYPELIB_FILTER, wszFilter, sizeof(wszFilter)); InitOpenFileName(hWnd, &ofn, wszFilter, wszTitle, wszName); if(GetOpenFileName(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName); break; } case IDM_VIEW: hSelect = TreeView_GetSelection(globals.hTree); if(IsInterface(hSelect)) InterfaceViewer(hSelect); else CreateTypeLibWindow(globals.hMainInst, NULL); break; case IDM_EXIT: DestroyWindow(hWnd); break; } return 0; }