/*! フォルダ履歴メニューの作成 @param 追加するメニューのハンドル @param pCMenuDrawer [in] (out?) メニュー作成で用いるMenuDrawer @author Norio Nakantani @return メニューのハンドル */ HMENU CMRUFolder::CreateMenu( HMENU hMenuPopUp, CMenuDrawer* pCMenuDrawer ) const { TCHAR szMenu[_MAX_PATH * 2 + 10]; // メニューキャプション int i; bool bFavorite; NONCLIENTMETRICS met; met.cbSize = CCSIZEOF_STRUCT(NONCLIENTMETRICS, lfMessageFont); ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, met.cbSize, &met, 0); CDCFont dcFont(met.lfMenuFont); CFileNameManager::getInstance()->TransformFileName_MakeCache(); for( i = 0; i < m_cRecentFolder.GetItemCount(); ++i ) { // 「共通設定」→「全般」→「ファイルの履歴MAX」を反映 if ( i >= m_cRecentFolder.GetViewCount() ) break; const TCHAR* pszFolder = m_cRecentFolder.GetItemText( i ); bFavorite = m_cRecentFolder.IsFavorite( i ); bool bFavoriteLabel = bFavorite && !m_pShareData->m_Common.m_sWindow.m_bMenuIcon; CFileNameManager::getInstance()->GetMenuFullLabel( szMenu, _countof(szMenu), true, pszFolder, -1, false, CODE_NONE, bFavoriteLabel, i, true, dcFont.GetHDC() ); // メニューに追加 pCMenuDrawer->MyAppendMenu( hMenuPopUp, MF_BYPOSITION | MF_STRING, IDM_SELOPENFOLDER + i, szMenu, _T(""), TRUE, bFavorite ? F_FAVORITE : -1 ); } return hMenuPopUp; }
HWND WINAPI CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,INT iNumButtons) { return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, 0, 0, 0, 0, CCSIZEOF_STRUCT(TBBUTTON, dwData)); }
int CDebugHelper::FormatSymbolFromAddress(HANDLE hProcess,DWORD64 Address, const MODULEENTRY32 *pModuleEntries,int NumModuleEntries, PSYMBOL_INFO pSymbolInfo,char *pszText) { const char *pszModule; pszModule="\?\?\?"; #if 0 if (m_pSymGetModuleBase!=NULL && m_pSymGetModuleInfo!=NULL) { DWORD64 ModuleBase=m_pSymGetModuleBase(s.hProcess,s.Stack.StackFrame.AddrReturn.Offset); if (ModuleBase!=0) { IMAGEHLP_MODULE64 ModuleInfo; ModuleInfo.SizeOfStruct=CCSIZEOF_STRUCT(IMAGEHLP_MODULE64,LoadedImageName); if (m_pSymGetModuleInfo(hProcess,ModuleBase,&ModuleInfo)) { pszModule=::PathFindFileNameA(ModuleInfo.ImageName); } } } #else int i; for (i=0;i<NumModuleEntries;i++) { if (Address>=(DWORD64)pModuleEntries[i].modBaseAddr && Address<(DWORD64)pModuleEntries[i].modBaseAddr+pModuleEntries[i].modBaseSize) { pszModule=pModuleEntries[i].szModule; break; } } #endif DWORD64 Displacement; int Length; if (m_pSymFromAddr(hProcess,Address,&Displacement,pSymbolInfo)) { Length=::wsprintfA(pszText,"%p %s : %s + %08x\r\n", (void*)Address,pszModule, pSymbolInfo->Name,(DWORD)Displacement); } else if (i<NumModuleEntries) { Length=::wsprintfA(pszText,"%p %s + %08x\r\n", (void*)Address,pszModule, (DWORD)(Address-(DWORD64)pModuleEntries[i].modBaseAddr)); } else { Length=::wsprintfA(pszText,"%p %s\r\n", (void*)Address,pszModule); } return Length; }
BOOL TToolTip::AddToolTipInternal(HWND hDlg, UINT nIDCtrl, LPCTSTR szTip, LPARAM lParam) { TTTOOLINFO ti; TCHAR szClassName[0x80]; DWORD dwStyle; HWND hWndChild; BOOL bResult = FALSE; // Only if we actually have a tooltip if(hWndToolTip != NULL) { // If the child window is not valid, do nothing hWndChild = GetDlgItem(hDlg, nIDCtrl); if(hWndChild != NULL) { // If the child window is a static text without SS_NOTIFY, // the tooltip would not activate. We need to set the SS_NOTIFY flag GetClassName(hWndChild, szClassName, _maxchars(szClassName)); if(!_tcsicmp(szClassName, WC_STATIC)) { dwStyle = GetWindowLong(hWndChild, GWL_STYLE); if((dwStyle & SS_NOTIFY) == 0) SetWindowLong(hWndChild, GWL_STYLE, dwStyle | SS_NOTIFY); } // Note: Make sure we put the size for COMCTL32.dll version 4.70 ZeroMemory(&ti, sizeof(TTTOOLINFO)); ti.cbSize = CCSIZEOF_STRUCT(TTTOOLINFO, lParam); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.hwnd = hDlg; ti.uId = (UINT_PTR)hWndChild; ti.hinst = g_hInst; ti.lpszText = (LPTSTR)szTip; ti.lParam = lParam; bResult = (BOOL)SendMessage(hWndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); } } return bResult; }
/* ツールバー作成 @date @@@ 2002.01.03 YAZAKI m_tbMyButtonなどをCShareDataからCMenuDrawerへ移動したことによる修正。 @date 2005.08.29 aroka ツールバーの折り返し @date 2006.06.17 ryoji ビジュアルスタイルが有効の場合はツールバーを Rebar に入れてサイズ変更時のちらつきを無くす */ void CMainToolBar::CreateToolBar( void ) { if( m_hwndToolBar )return; REBARINFO rbi; REBARBANDINFO rbBand; int nFlag; TBBUTTON tbb; int i; int nIdx; LONG_PTR lToolType; nFlag = 0; // 2006.06.17 ryoji // Rebar ウィンドウの作成 if( IsVisualStyle() ){ // ビジュアルスタイル有効 m_hwndReBar = ::CreateWindowEx( WS_EX_TOOLWINDOW, REBARCLASSNAME, //レバーコントロール NULL, WS_CHILD/* | WS_VISIBLE*/ | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | // 2007.03.08 ryoji WS_VISIBLE 除去 RBS_BANDBORDERS | CCS_NODIVIDER, 0, 0, 0, 0, m_pOwner->GetHwnd(), NULL, CEditApp::getInstance()->GetAppInstance(), NULL ); if( NULL == m_hwndReBar ){ TopWarningMessage( m_pOwner->GetHwnd(), LS(STR_ERR_DLGEDITWND04) ); return; } if( GetDllShareData().m_Common.m_sToolBar.m_bToolBarIsFlat ){ /* フラットツールバーにする/しない */ PreventVisualStyle( m_hwndReBar ); // ビジュアルスタイル非適用のフラットな Rebar にする } ::ZeroMemory(&rbi, sizeof(rbi)); rbi.cbSize = sizeof(rbi); Rebar_SetbarInfo(m_hwndReBar, &rbi); nFlag = CCS_NORESIZE | CCS_NODIVIDER | CCS_NOPARENTALIGN | TBSTYLE_FLAT; // ツールバーへの追加スタイル } /* ツールバーウィンドウの作成 */ m_hwndToolBar = ::CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_CHILD/* | WS_VISIBLE*/ | WS_CLIPCHILDREN | /*WS_BORDER | */ // 2006.06.17 ryoji WS_CLIPCHILDREN 追加 // 2007.03.08 ryoji WS_VISIBLE 除去 /* WS_EX_WINDOWEDGE| */ TBSTYLE_TOOLTIPS | // TBSTYLE_WRAPABLE | // TBSTYLE_ALTDRAG | // CCS_ADJUSTABLE | nFlag, 0, 0, 0, 0, m_pOwner->GetHwnd(), (HMENU)ID_TOOLBAR, CEditApp::getInstance()->GetAppInstance(), NULL ); if( NULL == m_hwndToolBar ){ if( GetDllShareData().m_Common.m_sToolBar.m_bToolBarIsFlat ){ /* フラットツールバーにする/しない */ GetDllShareData().m_Common.m_sToolBar.m_bToolBarIsFlat = FALSE; } TopWarningMessage( m_pOwner->GetHwnd(), LS(STR_ERR_DLGEDITWND05) ); DestroyToolBar(); // 2006.06.17 ryoji } else{ // 2006.09.06 ryoji ツールバーをサブクラス化する g_pOldToolBarWndProc = (WNDPROC)::SetWindowLongPtr( m_hwndToolBar, GWLP_WNDPROC, (LONG_PTR)ToolBarWndProc ); Toolbar_SetButtonSize( m_hwndToolBar, DpiScaleX(22), DpiScaleY(22) ); // 2009.10.01 ryoji 高DPI対応スケーリング Toolbar_ButtonStructSize( m_hwndToolBar, sizeof(TBBUTTON) ); // Oct. 12, 2000 genta // 既に用意されているImage Listをアイコンとして登録 m_pcIcons->SetToolBarImages( m_hwndToolBar ); /* ツールバーにボタンを追加 */ int count = 0; //@@@ 2002.06.15 MIK int nToolBarButtonNum = 0;// 2005/8/29 aroka // From Here 2005.08.29 aroka // はじめにツールバー構造体の配列を作っておく TBBUTTON *pTbbArr = new TBBUTTON[GetDllShareData().m_Common.m_sToolBar.m_nToolBarButtonNum]; for( i = 0; i < GetDllShareData().m_Common.m_sToolBar.m_nToolBarButtonNum; ++i ){ nIdx = GetDllShareData().m_Common.m_sToolBar.m_nToolBarButtonIdxArr[i]; pTbbArr[nToolBarButtonNum] = m_pOwner->GetMenuDrawer().getButton(nIdx); // セパレータが続くときはひとつにまとめる // 折り返しボタンもTBSTYLE_SEP属性を持っているので // 折り返しの前のセパレータは全て削除される. if( (pTbbArr[nToolBarButtonNum].fsStyle & TBSTYLE_SEP) && (nToolBarButtonNum!=0)){ if( (pTbbArr[nToolBarButtonNum-1].fsStyle & TBSTYLE_SEP) ){ pTbbArr[nToolBarButtonNum-1] = pTbbArr[nToolBarButtonNum]; nToolBarButtonNum--; } } // 仮想折返しボタンがきたら直前のボタンに折返し属性を付ける if( pTbbArr[nToolBarButtonNum].fsState & TBSTATE_WRAP ){ if( nToolBarButtonNum!=0 ){ pTbbArr[nToolBarButtonNum-1].fsState |= TBSTATE_WRAP; } continue; } nToolBarButtonNum++; } // To Here 2005.08.29 aroka for( i = 0; i < nToolBarButtonNum; ++i ){ tbb = pTbbArr[i]; //@@@ 2002.06.15 MIK start switch( tbb.fsStyle ) { case TBSTYLE_DROPDOWN: //ドロップダウン //拡張スタイルに設定 Toolbar_SetExtendedStyle( m_hwndToolBar, TBSTYLE_EX_DRAWDDARROWS ); Toolbar_AddButtons( m_hwndToolBar, 1, &tbb ); count++; break; case TBSTYLE_COMBOBOX: //コンボボックス { RECT rc; TBBUTTONINFO tbi; TBBUTTON my_tbb; LOGFONT lf; switch( tbb.idCommand ) { case F_SEARCH_BOX: if( m_hwndSearchBox ) { break; } //セパレータ作る memset_raw( &my_tbb, 0, sizeof(my_tbb) ); my_tbb.fsStyle = TBSTYLE_BUTTON; //ボタンにしないと描画が乱れる 2005/8/29 aroka my_tbb.idCommand = tbb.idCommand; //同じIDにしておく if( tbb.fsState & TBSTATE_WRAP ){ //折り返し 2005/8/29 aroka my_tbb.fsState |= TBSTATE_WRAP; } Toolbar_AddButtons( m_hwndToolBar, 1, &my_tbb ); count++; //サイズを設定する tbi.cbSize = sizeof(tbi); tbi.dwMask = TBIF_SIZE; tbi.cx = (WORD)DpiScaleX(160); //ボックスの幅 // 2009.10.01 ryoji 高DPI対応スケーリング Toolbar_SetButtonInfo( m_hwndToolBar, tbb.idCommand, &tbi ); //位置とサイズを取得する rc.right = rc.left = rc.top = rc.bottom = 0; Toolbar_GetItemRect( m_hwndToolBar, count-1, &rc ); //コンボボックスを作る // Mar. 8, 2003 genta 検索ボックスを1ドット下にずらした m_hwndSearchBox = CreateWindow( _T("COMBOBOX"), _T("Combo"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN /*| CBS_SORT*/ | CBS_AUTOHSCROLL /*| CBS_DISABLENOSCROLL*/, rc.left, rc.top + 1, rc.right - rc.left, (rc.bottom - rc.top) * 10, m_hwndToolBar, (HMENU)(INT_PTR)tbb.idCommand, CEditApp::getInstance()->GetAppInstance(), NULL ); if( m_hwndSearchBox ) { m_pOwner->SetCurrentFocus(0); lf = m_pOwner->GetLogfont(); //memset_raw( &lf, 0, sizeof(lf) ); lf.lfHeight = DpiPointsToPixels(-9); // Jan. 14, 2003 genta ダイアログにあわせてちょっと小さく // 2009.10.01 ryoji 高DPI対応(ポイント数から算出) lf.lfWidth = 0; lf.lfEscapement = 0; lf.lfOrientation = 0; lf.lfWeight = FW_NORMAL; lf.lfItalic = FALSE; lf.lfUnderline = FALSE; lf.lfStrikeOut = FALSE; //lf.lfCharSet = GetDllShareData().m_Common.m_sView.m_lf.lfCharSet; lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; // Raster Font を使わないように //lf.lfClipPrecision = GetDllShareData().m_Common.m_sView.m_lf.lfClipPrecision; //lf.lfQuality = GetDllShareData().m_Common.m_sView.m_lf.lfQuality; //lf.lfPitchAndFamily = GetDllShareData().m_Common.m_sView.m_lf.lfPitchAndFamily; //_tcsncpy( lf.lfFaceName, GetDllShareData().m_Common.m_sView.m_lf.lfFaceName, _countof(lf.lfFaceName)); // 画面のフォントに設定 2012/11/27 Uchi m_hFontSearchBox = ::CreateFontIndirect( &lf ); if( m_hFontSearchBox ) { ::SendMessage( m_hwndSearchBox, WM_SETFONT, (WPARAM)m_hFontSearchBox, MAKELONG (TRUE, 0) ); } // //入力長制限 // Combo_LimitText( m_hwndSearchBox, (WPARAM)_MAX_PATH - 1 ); //検索ボックスを更新 // 関数化 2010/6/6 Uchi AcceptSharedSearchKey(); m_comboDel = SComboBoxItemDeleter(); // 再表示用の初期化 m_comboDel.pRecent = &m_cRecentSearch; CDialog::SetComboBoxDeleter(m_hwndSearchBox, &m_comboDel); } break; default: break; } } break; case TBSTYLE_BUTTON: //ボタン case TBSTYLE_SEP: //セパレータ default: Toolbar_AddButtons( m_hwndToolBar, 1, &tbb ); count++; break; } //@@@ 2002.06.15 MIK end } if( GetDllShareData().m_Common.m_sToolBar.m_bToolBarIsFlat ){ /* フラットツールバーにする/しない */ lToolType = ::GetWindowLongPtr(m_hwndToolBar, GWL_STYLE); lToolType |= (TBSTYLE_FLAT); ::SetWindowLongPtr(m_hwndToolBar, GWL_STYLE, lToolType); ::InvalidateRect(m_hwndToolBar, NULL, TRUE); } delete []pTbbArr;// 2005/8/29 aroka } // 2006.06.17 ryoji // ツールバーを Rebar に入れる if( m_hwndReBar && m_hwndToolBar ){ // ツールバーの高さを取得する DWORD dwBtnSize = Toolbar_GetButtonSize( m_hwndToolBar ); DWORD dwRows = Toolbar_GetRows( m_hwndToolBar ); // バンド情報を設定する // 以前のプラットフォームに _WIN32_WINNT >= 0x0600 で定義される構造体のフルサイズを渡すと失敗する // 2007.12.21 ryoji rbBand.cbSize = CCSIZEOF_STRUCT( REBARBANDINFO, wID ); rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; rbBand.fStyle = RBBS_CHILDEDGE; rbBand.hwndChild = m_hwndToolBar; // ツールバー rbBand.cxMinChild = 0; rbBand.cyMinChild = HIWORD(dwBtnSize) * dwRows; rbBand.cx = 250; // バンドを追加する Rebar_InsertBand( m_hwndReBar, -1, &rbBand ); ::ShowWindow( m_hwndToolBar, SW_SHOW ); } return; }
const void *Dialog::dialogTemplateWithSystemFont() { dlgData_.clear(); NONCLIENTMETRICSW ncm = {0, }; ncm.cbSize = CCSIZEOF_STRUCT(NONCLIENTMETRICSW, lfMessageFont); // For Windows under Vista. SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); HINSTANCE inst = Batang::Win32Environment::instance().getInstance(); HRSRC rsrc = FindResourceW(inst, dialogName(), RT_DIALOG); size_t size = SizeofResource(inst, rsrc); HGLOBAL mem = LoadResource(inst, rsrc); uint8_t *ptr = static_cast<uint8_t *>(LockResource(mem)); uint16_t data16; uint32_t style; wchar_t *stmp; size_t tmpsize, prev = 26, next = 26; dlgData_.assign(ptr, ptr + prev); // dlgVer to cy in DLGTEMPLATEEX: 26 bytes auto szOrOrd = [&ptr, &prev, &next, this]() -> void { prev = next; uint16_t *tmp = reinterpret_cast<uint16_t *>(ptr + prev); if(*tmp == 0x0000) next = prev + 2; else if(*tmp == 0xFFFF) next = prev + 4; else { wchar_t *stmp = reinterpret_cast<wchar_t *>(tmp); next = prev + (wcslen(stmp) + 1) * sizeof(wchar_t); } dlgData_.insert(dlgData_.end(), ptr + prev, ptr + next); }; szOrOrd(); szOrOrd(); prev = next; stmp = reinterpret_cast<wchar_t *>(ptr + prev); next = prev + (wcslen(stmp) + 1) * sizeof(wchar_t); // title dlgData_.insert(dlgData_.end(), ptr + prev, ptr + next); auto lfHeightToPoint = [](int32_t height) -> uint16_t { if(height >= 0) return static_cast<uint16_t>(height); HWND desktop = GetDesktopWindow(); HDC hdc = GetDC(desktop); uint16_t ret = static_cast<uint16_t>(static_cast<double>(-height * 72) / GetDeviceCaps(hdc, LOGPIXELSY) + 0.5); ReleaseDC(desktop, hdc); return ret; }; prev = next; style = *reinterpret_cast<uint32_t *>(ptr + 12); if((style & DS_SETFONT) || (style & DS_SHELLFONT)) { data16 = lfHeightToPoint(ncm.lfMessageFont.lfHeight); if(data16 < 9) data16 = 9; // XXX: Dialog's font size must be least 9pt. dlgData_.insert(dlgData_.end(), reinterpret_cast<uint8_t *>(&data16), reinterpret_cast<uint8_t *>(&data16 + 1)); prev += 2; next = prev + 2; dlgData_.insert(dlgData_.end(), ptr + prev, ptr + next); dlgData_.push_back(ncm.lfMessageFont.lfItalic); dlgData_.push_back(ncm.lfMessageFont.lfCharSet); next += 2; stmp = reinterpret_cast<wchar_t *>(ptr + next); prev = next + (wcslen(stmp) + 1) * sizeof(wchar_t); tmpsize = (wcslen(ncm.lfMessageFont.lfFaceName) + 1) * sizeof(wchar_t); dlgData_.insert(dlgData_.end(), reinterpret_cast<uint8_t *>(ncm.lfMessageFont.lfFaceName), reinterpret_cast<uint8_t *>(ncm.lfMessageFont.lfFaceName) + tmpsize); } size_t rest = 4 - (dlgData_.size() % 4); if(rest < 4) { for(; rest > 0; -- rest) dlgData_.push_back(0); } rest = 4 - (prev % 4); if(rest < 4) prev += rest; dlgData_.insert(dlgData_.end(), ptr + prev, ptr + size); // TODO: Controls FreeResource(mem); return &*dlgData_.begin(); }