void HexView_CursorChanged(HWND hwndMain, HWND hwndHV) { MAINWND *mainWnd = (MAINWND *)GetWindowLongPtr(hwndMain, 0); UpdateStatusBarText(mainWnd->hwndStatusBar, hwndHV); UpdateToolbarState(mainWnd->hwndStatusBar, hwndHV); }
// WM_MFCMAPI_UPDATESTATUSBAR _Check_return_ LRESULT CBaseDialog::msgOnUpdateStatusBar(WPARAM wParam, LPARAM lParam) { __StatusPaneEnum iPane = (__StatusPaneEnum)wParam; LPCTSTR szStr = (LPCTSTR)lParam; UpdateStatusBarText(iPane, szStr); return S_OK; } // CBaseDialog::msgOnUpdateStatusBar
// Help strings can be found in mfcmapi.rc2 // Will preserve the existing text in the right status pane, restoring it when we stop displaying menus void CBaseDialog::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU /*hSysMenu*/) { if (!m_bDisplayingMenuText) { m_szMenuDisplacedText = m_StatusMessages[STATUSINFOTEXT]; } if (nItemID && !(nFlags & (MF_SEPARATOR | MF_POPUP))) { UpdateStatusBarText(STATUSINFOTEXT, nItemID); // This will LoadString the menu help text for us m_bDisplayingMenuText = true; } else { m_bDisplayingMenuText = false; } if (!m_bDisplayingMenuText) { UpdateStatusBarText(STATUSINFOTEXT, m_szMenuDisplacedText); } } // CBaseDialog::OnMenuSelect
BOOL HexSetCurFile(HWND hwndMain, int iItem, BOOL fSetFocus) { TCITEM tci = { TCIF_PARAM }; HWND hwndHV, hwndOld; TCHAR szFilePath[MAX_PATH]; TCHAR *name; RECT rect; // get specied item if(!TabCtrl_GetItem(g_hwndTabView, iItem, &tci)) return FALSE; TabCtrl_SetCurSel(g_hwndTabView, iItem); hwndHV = (HWND)tci.lParam; hwndOld = g_hwndHexView; GetWindowRect(hwndOld, &rect); MapWindowPoints(0, hwndMain, (POINT *)&rect, 2); MoveWindow(hwndHV, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,0); g_hwndHexView = hwndHV; ForceClientResize(hwndMain); if(fSetFocus) SetFocus(hwndHV); HexView_GetFileName(hwndHV, szFilePath, MAX_PATH); name = _tcsrchr(szFilePath, '\\'); name = name ? name+1 : TEXT("Untitled"); SetWindowFileName(hwndMain, name, HexView_CanUndo(hwndHV), HexView_IsReadOnly(hwndHV)); if(hwndOld != hwndHV) ShowWindow(hwndOld, SW_HIDE); UpdateStatusBarText(g_hwndStatusBar, hwndHV); UpdateTypeView(); return TRUE; }
void __cdecl CBaseDialog::UpdateStatusBarText(__StatusPaneEnum nPos, UINT uidMsg, LPCTSTR szParam1, LPCTSTR szParam2, LPCTSTR szParam3) { CString szStatBarString; // MAPI Load paths take special handling if (uidMsg >= ID_LOADMAPIMENUMIN && uidMsg <= ID_LOADMAPIMENUMAX) { HRESULT hRes = S_OK; MENUITEMINFOW mii = { 0 }; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_DATA; WC_B(GetMenuItemInfoW( ::GetMenu(m_hWnd), uidMsg, false, &mii)); if (mii.dwItemData) { LPMENUENTRY lme = (LPMENUENTRY)mii.dwItemData; szStatBarString.FormatMessage(IDS_LOADMAPISTATUS, lme->m_pName); } } else { LPMENUITEM lpAddInMenu = GetAddinMenuItem(m_hWnd, uidMsg); if (lpAddInMenu && lpAddInMenu->szHelp) { szStatBarString.Format(_T("%ws"), lpAddInMenu->szHelp); // STRING_OK } else { HRESULT hRes = S_OK; CString szMsg; WC_B(szMsg.LoadString(uidMsg)); if (FAILED(hRes)) DebugPrintEx(DBGMenu, CLASS, _T("UpdateStatusBarText"), _T("Cannot find menu item 0x%08X\n"), uidMsg); szStatBarString.FormatMessage(szMsg, szParam1, szParam2, szParam3); } } UpdateStatusBarText(nPos, szStatBarString); } // CBaseDialog::UpdateStatusBarText
void __cdecl CBaseDialog::UpdateStatusBarText(__StatusPaneEnum nPos, UINT uidMsg, ULONG ulParam1) { CString szParam1; szParam1.Format(_T("%u"), ulParam1); UpdateStatusBarText(nPos, uidMsg, szParam1, NULL, NULL); }
void __cdecl CBaseDialog::UpdateStatusBarText(__StatusPaneEnum nPos, UINT uidMsg) { UpdateStatusBarText(nPos, uidMsg, NULL, NULL, NULL); }
LRESULT HexEdit_OnNotify(MAINWND *mainWnd, HWND hwnd, UINT idCtrl, NMHDR *hdr) { HWND hwndHV = GetActiveHexView(hwnd); if(hdr->hwndFrom == mainWnd->hwndTabView) { TCITEM tci = { TCIF_PARAM }; TabCtrl_GetItem(mainWnd->hwndTabView, TabCtrl_GetCurSel(mainWnd->hwndTabView), &tci); // has the user clicked a file-tab? if(hdr->code == TCN_SELCHANGE) { HexSetCurFile(hwnd, TabCtrl_GetCurSel(mainWnd->hwndTabView), TRUE); OnFileChange(mainWnd); return 0; } else if(hdr->code == TCN_CLOSING) { // prompt close if if(HexFileCloseNotify(hwnd, hwndHV) == IDCANCEL) return TRUE; return 0; } else if(hdr->code == TCN_CLOSE) { // ask user if they want to save changes if(HexFileCloseNotify(hwnd, hwndHV) == IDCANCEL) return 0; //SetCurFile(hwnd, TabCtrl_GetCurSel(mainWnd->hwndTabView)); //DestroyWindow((HWND)tci.lParam); HexCloseFile(mainWnd, TabCtrl_GetCurSel(mainWnd->hwndTabView)); return 0; } } // double-click in a statusbar pane? if(hdr->hwndFrom == mainWnd->hwndStatusBar && hdr->code == NM_DBLCLK) { NMMOUSE *nmmouse; // statusbar is the only window at present which sends double-clicks nmmouse = (NMMOUSE *)hdr; // toggle the Readonly/Insert/Overwrite mode if(nmmouse->dwItemSpec == 4) { ToggleEditorMode(hwndHV); UpdateStatusBarText(mainWnd->hwndStatusBar, hwndHV); } return 0; } if(hdr->code == TBN_DROPDOWN) { if(GetParent(hdr->hwndFrom) == mainWnd->hwndStatusBar) { StatusBar_DropDownTB(mainWnd, hwndHV, (NMTOOLBAR *)hdr); } if(hdr->hwndFrom == mainWnd->hwndToolbar) { HexPasteSpecialDlg2(hwnd); } return 0; } /* if(hdr->code == DWN_ISDOCKABLE) { RECT rc1, rc2; // Get main window "outer" rectangle GetWindowRect(hwnd, &rc1); // Get main window "inner" rectangle GetClientRect(hwnd, &rc2); MapWindowPoints(hwnd, 0, (POINT *)&rc2, 2); InflateRect(&rc2, -2, -2); return DockWnd_GetDockSide(hwnd, (NMDOCKWNDQUERY *)hdr, &rc1, &rc2); }*/ if(hdr->code == DWN_SAVESETTINGS) { NMDOCKWNDCREATE *nmdw = (NMDOCKWNDCREATE *)hdr; TRACEA(" DWN_SAVESETTINGS: %d\n", nmdw->uId); switch(nmdw->hdr.idFrom) { case DWID_TYPEVIEW: case DWID_ALLTYPES: SaveTypeView(nmdw->hwndClient, nmdw->hKey); break; } return 0; } if(hdr->code == DWN_UPDATE_CONTENT) { NMDOCKWND *nmdw = (NMDOCKWND *)hdr; HWND hwndHV = GetActiveHexView(hwnd); switch(nmdw->hdr.idFrom) { case DWID_HIGHLIGHT: UpdateHighlights(TRUE); break; } return 0; } if(hdr->code == DWN_CREATE_CONTENT) { NMDOCKWNDCREATE *nmdw = (NMDOCKWNDCREATE *)hdr; TRACEA("DWN_CREATE_CONTENT: %d\n", hdr->idFrom); switch(nmdw->hdr.idFrom) { case DWID_TOOLBAR: mainWnd->hwndToolbar = InitToolbar(hdr->hwndFrom); return (LONG)mainWnd->hwndToolbar; case DWID_SEARCHBAR: return (LONG)CreateSearchBar(hdr->hwndFrom); case DWID_ALLTYPES: //SendMessage(hwndTB, TB_SETSTATE, IDM_TOOLS_TYPEVIEW, DockWnd_IsOpen(g_hwndMain, DWID_TYPEVIEW) ? TBSTATE_CHECKED|TBSTATE_ENABLED : TBSTATE_ENABLED); return (LONG)CreateTypeView(hdr->hwndFrom, nmdw->hKey, TRUE);//TEXT("struct ALL")); case DWID_TYPEVIEW: //SendMessage(hwndTB, TB_SETSTATE, IDM_TOOLS_TYPEVIEW, DockWnd_IsOpen(g_hwndMain, DWID_TYPEVIEW) ? TBSTATE_CHECKED|TBSTATE_ENABLED : TBSTATE_ENABLED); return (LONG)CreateTypeView(hdr->hwndFrom, nmdw->hKey, 0); case DWID_HIGHLIGHT: return (LONG)CreateHighlightView(hdr->hwndFrom); case DWID_STRINGS: return (LONG)CreateStringsView(hdr->hwndFrom); } } else if(hdr->code == DWN_DOCKCHANGE) { NMDOCKWND *nmdw = (NMDOCKWND *)hdr; switch(nmdw->hdr.idFrom) { case DWID_TOOLBAR: SendMessage(DockWnd_GetContents(mainWnd->hwndMain, DWID_TOOLBAR), TB_SETPARENT, (WPARAM)hdr->hwndFrom, 0); return 0; } } else if(hdr->code == DWN_CLOSING) { NMDOCKWND *nmdw = (NMDOCKWND *)hdr; switch(nmdw->hdr.idFrom) { case DWID_TYPEVIEW: break; } return 0; } return DefWindowProc(hwnd, WM_NOTIFY, idCtrl, (LONG)hdr); }
LONG StatusBar_DropDownTB(MAINWND *mainWnd, HWND hwndHV, NMTOOLBAR *nmtb) { RECT rect = nmtb->rcButton; HMENU hMenu, hPopup; UINT mode, cmdId; MapWindowPoints(nmtb->hdr.hwndFrom, 0, (POINT *)&rect, 2); switch(nmtb->hdr.idFrom) { case IDM_STATUSBAR_CURSORPOS: hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU3)); hPopup = GetSubMenu(hMenu, 0); MenuCheckMark(hPopup, IDM_STATUS_HEX, g_fStatusHexCursor); MenuCheckMark(hPopup, IDM_STATUS_DEC, !g_fStatusHexCursor); break; case IDM_STATUSBAR_VALUE: hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU2)); hPopup = GetSubMenu(hMenu, 0); MenuCheckMark(hPopup, IDM_VALUE_SIGNED, g_fStatusSignedValue); MenuCheckMark(hPopup, IDM_VALUE_ENDIAN, g_fStatusBigEndian); MenuCheckMark(hPopup, IDM_VALUE_HEX, g_fStatusHexValue); CheckMenuRadioItem(hPopup, IDM_VALUE_BYTE, IDM_VALUE_DOUBLE, g_nStatusValueType, MF_BYCOMMAND); break; case IDM_STATUSBAR_SIZE: hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU3)); hPopup = GetSubMenu(hMenu, 0); MenuCheckMark(hPopup, IDM_STATUS_HEX, g_fStatusHexSize); MenuCheckMark(hPopup, IDM_STATUS_DEC, !g_fStatusHexSize); break; case IDM_STATUSBAR_MODE: hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU4)); hPopup = GetSubMenu(hMenu, 0); mode = HexView_GetEditMode(hwndHV); MenuCheckMark(hPopup, IDM_STATUSBAR_INSERT, mode == HVMODE_INSERT); MenuCheckMark(hPopup, IDM_STATUSBAR_OVERWRITE, mode == HVMODE_OVERWRITE); MenuCheckMark(hPopup, IDM_STATUSBAR_READONLY, mode == HVMODE_READONLY); break; } //CheckMenuItem(hMenu, IDM_ cmdId = TrackPopupMenu(hPopup, TPM_RETURNCMD|TPM_RIGHTALIGN|TPM_BOTTOMALIGN, rect.right, rect.top, 0, g_hwndMain, 0); switch(cmdId) { case IDM_STATUSBAR_INSERT: HexView_SetEditMode(hwndHV, HVMODE_INSERT); break; case IDM_STATUSBAR_OVERWRITE: HexView_SetEditMode(hwndHV, HVMODE_OVERWRITE); break; case IDM_STATUSBAR_READONLY: HexView_SetEditMode(hwndHV, HVMODE_READONLY); break; case IDM_STATUS_HEX: if(nmtb->hdr.idFrom == IDM_STATUSBAR_SIZE) g_fStatusHexSize = TRUE; else g_fStatusHexCursor = TRUE; break; case IDM_STATUS_DEC: if(nmtb->hdr.idFrom == IDM_STATUSBAR_SIZE) g_fStatusHexSize = FALSE; else g_fStatusHexCursor = FALSE; break; case IDM_VALUE_HEX: g_fStatusHexValue = !g_fStatusHexValue; break; case IDM_VALUE_ENDIAN: g_fStatusBigEndian = !g_fStatusBigEndian; break; case IDM_VALUE_SIGNED: g_fStatusSignedValue = !g_fStatusSignedValue; break; case IDM_VALUE_BYTE: case IDM_VALUE_WORD: case IDM_VALUE_DWORD: case IDM_VALUE_QWORD: case IDM_VALUE_FLOAT: case IDM_VALUE_DOUBLE: g_nStatusValueType = cmdId; break; } DestroyMenu(hMenu); UpdateStatusBarText(mainWnd->hwndStatusBar, hwndHV); if(nmtb->hdr.idFrom == IDM_VALUE_SHOW) { } return 0; }
LONG HexViewNotifyHandler(MAINWND *mainWnd, HWND hwnd, NMHDR *hdr) { HWND hwndHV = GetActiveHexView(hwnd);//g_hwndHexView; NMHVPROGRESS *hvp; switch(hdr->code) { case HVN_CHANGED: mainWnd->fChanged = TRUE; UpdateToolbarState(mainWnd->hwndToolbar, hwndHV); if(g_szFileTitle[0]) { BOOL fModified = HexView_CanUndo(hwndHV); if(fModified != g_fFileChanged) { SetWindowFileName(hwnd, g_szFileTitle, fModified, FALSE); g_fFileChanged = fModified; } } UpdateTypeView(); return 0; case HVN_EDITMODE_CHANGE: // show the unicode value under the cursor //SetStatusBarText(g_hwndStatusbar, 1, 0, TEXT(" U+%04X"), // TextView_GetCurChar(g_hwndTextView) ); UpdateStatusBarText(mainWnd->hwndStatusBar, hwndHV); //SetStatusBarText(mainWnd->hwndStatusBar, 4, 0, // g_szEditMode[HexView_GetEditMode(hwndHV)] ); return 0; case HVN_CURSOR_CHANGE: UpdateStatusBarText(mainWnd->hwndStatusBar, hwndHV); UpdateToolbarState(mainWnd->hwndStatusBar, hwndHV); UpdateTypeView(); return 0; case HVN_PROGRESS: hvp = (NMHVPROGRESS *)hdr; return UpdateProgress(mainWnd, TRUE, hvp->pos, hvp->len); //return 0; case HVN_BOOKCLOSE: //HexView_DelBookmark(((NMHVBOOKMARK *)hdr)->hdr.hwndFrom, 0); //RemoveBookmark((NMHVBOOKMARK *)hdr); return 0; default: return 0; } }