ReactOS 0.4.17-dev-940-g8bd6e85
CMainWnd Class Reference

#include <CMainWnd.h>

Inheritance diagram for CMainWnd:
Collaboration diagram for CMainWnd:

Public Member Functions

 CMainWnd ()
 
 ~CMainWnd ()
 
LRESULT OnCreate (UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSize (UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnCloseChild (UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnDestroy (UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnClose (UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnFileNew (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileOpen (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileSave (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileSaveAs (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileAdd (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileOptions (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileRecent (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnFileExit (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnViewCustomize (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnWindowsNew (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnWindowsCascade (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnWindowsTile (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnWindowsArrange (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnHelpAboutMMC (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnToolbarScopePane (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnToolbarActionsPane (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
LRESULT OnMDIForward (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 
CAtlString * GetConsoleTitle ()
 
void SetConsoleTitle (CAtlString consoleTitle)
 
BOOL IsToolBarVisible ()
 
VOID SetToolBarVisible (BOOL bVisible)
 
BOOL AreStandardMenusVisible ()
 
VOID SetStandardMenusVisible (BOOL bVisible)
 
int GetSnapinCacheCount ()
 
CSnapinCacheEntry * GetSnapinCacheEntry (int nIndex)
 
CSnapinCacheEntry * GetSnapinCacheEntryByGuid (PWSTR pszGuid)
 
HIMAGELIST SnapinImageList ()
 
CSnapin * GetRootSnapin ()
 
int RegisterView (CConsoleWnd *pView)
 
void UnregisterView (CConsoleWnd *pView)
 
DOCUMENT_MODE GetDocumentMode ()
 
void SetDocumentMode (DOCUMENT_MODE DocumentMode)
 
BOOL GetLogicalReadOnly ()
 
void SetLogicalReadOnly (BOOL LogicalReadOnly)
 
BOOL GetPreventViewCustomization ()
 
void SetPreventViewCustomization (BOOL PreventCustomization)
 

Static Public Member Functions

static CWndClassInfo & GetWndClassInfo ()
 
static LPCTSTR GetWndClassName ()
 
static LRESULT CALLBACK XDefFrameProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Public Attributes

CWindow m_MDIClient
 
CAtlString m_Filename
 

Private Member Functions

void UpdateMenu ()
 
void UpdateTitle ()
 
CConsoleWnd * GetActiveChildInfo ()
 
void CreateNewConsoleTitle (CAtlString &str)
 
LRESULT LoadSnapinCache ()
 
void UpdateLayout ()
 
void UpdateViews ()
 
VOID UpdateRecentFilesMenu ()
 
VOID LoadRecentFiles ()
 
VOID AddToRecentFiles (const CAtlString &FileName)
 
DWORD CreateNewFilename (PWSTR pBuffer, DWORD dwSize, DWORD Number)
 
LPWSTR ProgramModeToString ()
 
LRESULT SaveMscFile (const CAtlString &FileName)
 
LRESULT LoadMscFile (const CAtlString &FileName)
 

Private Attributes

CWndProcThunk m_FrameThunk
 
int m_ConsoleNumber
 
CAtlString m_ConsoleTitle
 
HMENU m_hMenuConsoleSmall
 
HMENU m_hMenuConsoleLarge
 
DOCUMENT_MODE m_DocumentMode
 
BOOL m_LogicalReadOnly
 
BOOL m_PreventViewCustomization
 
CToolbar< DWORD_PTR > m_ToolBar
 
int m_iToolBarHeight
 
BOOL m_bToolBarVisible
 
HIMAGELIST m_hToolBarImageList
 
BOOL m_bStandardMenusVisible
 
CSimpleArray< CSnapinCacheEntry * > m_SnapinCache
 
HIMAGELIST m_hSnapinImageList
 
CAtlList< CConsoleWnd * > m_ViewList
 
int m_NextViewId
 
CSnapin * m_RootNode
 
CAtlList< CRecentFileEntry * > m_RecentFilesList
 

Detailed Description

Definition at line 23 of file CMainWnd.h.

Constructor & Destructor Documentation

◆ CMainWnd()

CMainWnd::CMainWnd ( )

Definition at line 26 of file CMainWnd.cpp.

31 , m_bToolBarVisible(true)
32 , m_NextViewId(1)
34{
36 m_pfnSuperWindowProc = m_FrameThunk.GetWNDPROC();
38 m_hMenuConsoleSmall = LoadMenu(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDM_CONSOLE_SMALL));
39 m_hMenuConsoleLarge = LoadMenu(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDM_CONSOLE_LARGE));
43 0,
44 4);
45
49 0,
50 4);
51
52 HBITMAP hToolBarBitmap = LoadBitmapW(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDB_TOOLBAR));
54 hToolBarBitmap,
55 RGB(0,0,0));
56 DeleteObject(hToolBarBitmap);
57
60}
#define IDM_CONSOLE_SMALL
Definition: resource.h:8
#define IDM_CONSOLE_LARGE
Definition: resource.h:9
@ DocumentMode_Author
Definition: precomp.h:43
#define IDB_TOOLBAR
Definition: resource.h:19
WNDPROC GetWNDPROC()
Definition: atlwin.h:258
BOOL Init(WNDPROC proc, void *pThis)
Definition: atlwin.h:250
CWndProcThunk m_FrameThunk
Definition: CMainWnd.h:27
HIMAGELIST m_hToolBarImageList
Definition: CMainWnd.h:40
static LRESULT CALLBACK XDefFrameProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CMainWnd.h:121
int m_ConsoleNumber
Definition: CMainWnd.h:29
VOID LoadRecentFiles()
Definition: CMainWnd.cpp:693
int m_NextViewId
Definition: CMainWnd.h:47
HMENU m_hMenuConsoleSmall
Definition: CMainWnd.h:31
CSnapin * m_RootNode
Definition: CMainWnd.h:49
HIMAGELIST m_hSnapinImageList
Definition: CMainWnd.h:44
LRESULT LoadSnapinCache()
Definition: CMainWnd.cpp:502
DOCUMENT_MODE m_DocumentMode
Definition: CMainWnd.h:33
BOOL m_LogicalReadOnly
Definition: CMainWnd.h:34
BOOL m_PreventViewCustomization
Definition: CMainWnd.h:35
HMENU m_hMenuConsoleLarge
Definition: CMainWnd.h:32
BOOL m_bToolBarVisible
Definition: CMainWnd.h:39
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:573
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
#define RGB(r, g, b)
Definition: precomp.h:67
pKey DeleteObject()
static HBITMAP
Definition: button.c:44
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILC_MASK
Definition: commctrl.h:351
#define SM_CYSMICON
Definition: winuser.h:1024
#define SM_CXSMICON
Definition: winuser.h:1023
#define LoadMenu
Definition: winuser.h:5983
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2532
int WINAPI GetSystemMetrics(_In_ int)

◆ ~CMainWnd()

CMainWnd::~CMainWnd ( )

Definition at line 62 of file CMainWnd.cpp.

63{
69}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:941
BOOL WINAPI DestroyMenu(_In_ HMENU)

Member Function Documentation

◆ AddToRecentFiles()

VOID CMainWnd::AddToRecentFiles ( const CAtlString &  FileName)
private

Definition at line 726 of file CMainWnd.cpp.

727{
728 POSITION pos = m_RecentFilesList.GetHeadPosition();
729 while (pos != NULL)
730 {
732 if (ValueData->FileName() == FileName)
733 break;
734
735 m_RecentFilesList.GetNext(pos);
736 }
737
738 if (pos == NULL)
739 {
740 /* Insert at top */
742 if (m_RecentFilesList.GetCount() > 4)
743 m_RecentFilesList.RemoveTail();
744 }
745 else
746 {
747 /* Move to top */
748 /* m_RecentFilesList.MoveToHead(pos); */
750 m_RecentFilesList.RemoveAt(pos);
752 }
753
754 /* Update the registry key */
755 CRegKey RecentFilesKey;
756 if (ERROR_SUCCESS == RecentFilesKey.Create(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\MMC_NEW\\Recent Files List"))
757 {
758 INT count = 0;
760 pos = m_RecentFilesList.GetHeadPosition();
761 while (pos != NULL)
762 {
764 ValueName.Format(L"File%u", count + 1);
765 RecentFilesKey.SetStringValue(ValueName, ValueData->FileName().GetString());
766 count++;
767 if (count >= MAX_RECENT_FILES)
768 break;
769 }
770
771 RecentFilesKey.Close();
772 }
773
775}
#define MAX_RECENT_FILES
Definition: CMainWnd.h:21
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ) noexcept
Definition: atlbase.h:1315
LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_READ|KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL) noexcept
Definition: atlbase.h:1189
LONG Close() noexcept
Definition: atlbase.h:1156
CAtlList< CRecentFileEntry * > m_RecentFilesList
Definition: CMainWnd.h:51
VOID UpdateRecentFilesMenu()
Definition: CMainWnd.cpp:655
#define ERROR_SUCCESS
Definition: deptool.c:10
#define L(x)
Definition: resources.c:13
GLuint GLuint GLsizei count
Definition: gl.h:1545
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
int32_t INT
Definition: typedefs.h:58
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by OnFileOpen(), OnFileRecent(), and OnFileSaveAs().

◆ AreStandardMenusVisible()

BOOL CMainWnd::AreStandardMenusVisible ( )

Definition at line 488 of file CMainWnd.cpp.

489{
491}
BOOL m_bStandardMenusVisible
Definition: CMainWnd.h:41

Referenced by CCustomizeDialog::OnInitDialog().

◆ CreateNewConsoleTitle()

void CMainWnd::CreateNewConsoleTitle ( CAtlString &  str)
inlineprivate

Definition at line 158 of file CMainWnd.h.

159 {
161 str.LoadString(IDS_CONSOLETITLE);
162
163 LPTSTR lpTarget = NULL;
165 str.GetString(), 0, 0, (LPTSTR)&lpTarget, 0, (va_list*)args);
166
167 if (Ret)
168 {
169 str = lpTarget;
170 LocalFree(lpTarget);
171 }
172 }
#define IDS_CONSOLETITLE
Definition: resource.h:4
char * va_list
Definition: vadefs.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
LPSTR LPTSTR
Definition: ms-dtyp.idl:131
const WCHAR * str
Definition: match.c:390
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FormatMessage
Definition: winbase.h:3518
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:398
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:396
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:401

Referenced by UpdateTitle().

◆ CreateNewFilename()

DWORD CMainWnd::CreateNewFilename ( PWSTR  pBuffer,
DWORD  dwSize,
DWORD  Number 
)
private

Definition at line 778 of file CMainWnd.cpp.

779{
780 DWORD_PTR args[1] = { (DWORD_PTR)Number };
782
783 str.LoadString(IDS_CONSOLETITLE);
784
786 str.GetString(), 0, 0, pBuffer, dwSize, (va_list*)args);
787}
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
_In_ ULONG Number
Definition: haltypes.h:1872
PVOID pBuffer

Referenced by OnFileSaveAs().

◆ GetActiveChildInfo()

CConsoleWnd * CMainWnd::GetActiveChildInfo ( )
inlineprivate

Definition at line 147 of file CMainWnd.h.

148 {
149 HWND hWndMDIChild;
150
151 hWndMDIChild = (HWND)m_MDIClient.SendMessage(WM_MDIGETACTIVE, 0, 0);
152 if (hWndMDIChild == NULL)
153 return NULL;
154
155 return (CConsoleWnd*)::GetWindowLongPtr(hWndMDIChild, 0);
156 }
CWindow m_MDIClient
Definition: CMainWnd.h:54
HANDLE HWND
Definition: compat.h:19
#define WM_MDIGETACTIVE
Definition: winuser.h:1849
#define GetWindowLongPtr
Definition: treelist.c:73

Referenced by OnFileAdd(), OnFileOpen(), OnFileOptions(), OnFileSave(), OnFileSaveAs(), OnToolbarActionsPane(), OnToolbarScopePane(), and OnViewCustomize().

◆ GetConsoleTitle()

CAtlString * CMainWnd::GetConsoleTitle ( )

Definition at line 463 of file CMainWnd.cpp.

464{
465 return &m_ConsoleTitle;
466}
CAtlString m_ConsoleTitle
Definition: CMainWnd.h:30

Referenced by COptionsDialog::OnInitDialog().

◆ GetDocumentMode()

DOCUMENT_MODE CMainWnd::GetDocumentMode ( )

Definition at line 619 of file CMainWnd.cpp.

620{
621 return m_DocumentMode;
622}

Referenced by COptionsDialog::COptionsDialog().

◆ GetLogicalReadOnly()

BOOL CMainWnd::GetLogicalReadOnly ( )

Definition at line 631 of file CMainWnd.cpp.

632{
633 return m_LogicalReadOnly;
634}

Referenced by COptionsDialog::COptionsDialog().

◆ GetPreventViewCustomization()

BOOL CMainWnd::GetPreventViewCustomization ( )

Definition at line 643 of file CMainWnd.cpp.

644{
646}

Referenced by COptionsDialog::COptionsDialog().

◆ GetRootSnapin()

CSnapin * CMainWnd::GetRootSnapin ( )

Definition at line 556 of file CMainWnd.cpp.

557{
558 return m_RootNode;
559}

Referenced by CAddDialog::OnInitDialog().

◆ GetSnapinCacheCount()

int CMainWnd::GetSnapinCacheCount ( )

Definition at line 526 of file CMainWnd.cpp.

527{
528 return m_SnapinCache.GetSize();
529}
CSimpleArray< CSnapinCacheEntry * > m_SnapinCache
Definition: CMainWnd.h:43

Referenced by CAddDialog::OnInitDialog(), and SaveMscFile().

◆ GetSnapinCacheEntry()

CSnapinCacheEntry * CMainWnd::GetSnapinCacheEntry ( int  nIndex)

Definition at line 532 of file CMainWnd.cpp.

533{
534 return m_SnapinCache[nIndex];
535}

Referenced by CAddDialog::OnInitDialog(), and SaveMscFile().

◆ GetSnapinCacheEntryByGuid()

CSnapinCacheEntry * CMainWnd::GetSnapinCacheEntryByGuid ( PWSTR  pszGuid)

Definition at line 538 of file CMainWnd.cpp.

539{
540 for (int i = 0; i < m_SnapinCache.GetSize(); i++)
541 {
543 if (entry->GuidString().CompareNoCase(pszGuid) == 0)
544 return entry;
545 }
546 return NULL;
547}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63

Referenced by OnFileNew().

◆ GetWndClassInfo()

static CWndClassInfo & CMainWnd::GetWndClassInfo ( )
inlinestatic

Definition at line 93 of file CMainWnd.h.

94 {
95 static CWndClassInfo wc =
96 {
97 {
98 /* cbSize= */sizeof(WNDCLASSEX),
99 /* style= */0,
100 /* lpfnWndProc= */StartWindowProc,
101 /* cbClsExtra= */0,
102 /* cbWndExtra= */0,
103 /* hInstance= */NULL,
104 /* hIcon= */LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAINAPP)),
105 /* hCursor= */NULL,
106 /* hbrBackground= */(HBRUSH)(COLOR_BTNFACE + 1),
107 /* lpszMenuName= */NULL,
108 /* lpszClassName= */TEXT("MMCMainFrame"),
109 /* hIconSm= */LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAINAPP))
110 },
111 NULL, NULL, IDC_ARROW, TRUE, 0, L""
112 };
113 return wc;
114 }
#define IDI_MAINAPP
Definition: resource.h:6
#define TRUE
Definition: types.h:120
#define TEXT(s)
Definition: k32.h:28
_ATL_WNDCLASSINFOW CWndClassInfo
Definition: atlwin.h:70
#define IDC_ARROW
Definition: winuser.h:695
#define LoadIcon
Definition: winuser.h:5979
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5885
#define COLOR_BTNFACE
Definition: winuser.h:939

Referenced by GetWndClassName().

◆ GetWndClassName()

static LPCTSTR CMainWnd::GetWndClassName ( )
inlinestatic

Definition at line 116 of file CMainWnd.h.

117 {
118 return GetWndClassInfo().m_wc.lpszClassName;
119 }
static CWndClassInfo & GetWndClassInfo()
Definition: CMainWnd.h:93

◆ IsToolBarVisible()

BOOL CMainWnd::IsToolBarVisible ( )

Definition at line 475 of file CMainWnd.cpp.

476{
477 return m_bToolBarVisible;
478}

Referenced by CCustomizeDialog::OnInitDialog().

◆ LoadMscFile()

LRESULT CMainWnd::LoadMscFile ( const CAtlString &  FileName)
private

Definition at line 910 of file CMainWnd.cpp.

911{
912 HRESULT hr = S_OK;
913
914 MscFile *mscFile = new MscFile(FileName.GetString());
915
916 CHK_HR(mscFile->CreateAndInitDOM());
917
918 CHK_HR(mscFile->LoadDOM());
919
920 /* FIXME: Parse the dom and set up the app, the views and the snapin tree */
921
922CleanUp:
923
924 delete mscFile;
925
926 return 0;
927}
HRESULT CreateAndInitDOM()
Definition: mscfile.cpp:46
HRESULT LoadDOM()
Definition: mscfile.cpp:314
HRESULT hr
Definition: delayimp.cpp:582
#define S_OK
Definition: intsafe.h:52
#define CHK_HR(stmt)
Definition: mscfile.h:9

Referenced by OnFileOpen(), and OnFileRecent().

◆ LoadRecentFiles()

VOID CMainWnd::LoadRecentFiles ( )
private

Definition at line 693 of file CMainWnd.cpp.

694{
695 CRegKey RecentFilesKey;
696 if (ERROR_SUCCESS == RecentFilesKey.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\MMC_NEW\\Recent Files List", KEY_READ))
697 {
698 WCHAR pathBuf[MAX_PATH];
699 ULONG pathLength, i;
700 DWORD err;
701
702 CAtlString valueName;
703 CAtlString fileName;
704
705 for (i = 0; i < MAX_RECENT_FILES; i++)
706 {
707 valueName.Format(L"File%u", i + 1);
708 pathLength = _countof(pathBuf);
709 err = RecentFilesKey.QueryStringValue(valueName.GetString(),
710 pathBuf,
711 &pathLength);
712 if (err == ERROR_SUCCESS)
713 {
714 CAtlString fileName(pathBuf);
715 m_RecentFilesList.AddTail(new CRecentFileEntry(fileName));
716 }
717 }
718
719 RecentFilesKey.Close();
720 }
721
723}
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1240
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
#define MAX_PATH
Definition: compat.h:34
#define KEY_READ
Definition: nt_native.h:1026
short WCHAR
Definition: pedump.c:58
#define err(...)
#define _countof(array)
Definition: sndvol32.h:70
uint32_t ULONG
Definition: typedefs.h:59

Referenced by CMainWnd().

◆ LoadSnapinCache()

LRESULT CMainWnd::LoadSnapinCache ( )
private

Definition at line 502 of file CMainWnd.cpp.

503{
504 CRegKey SnapinsKey;
505 if (ERROR_SUCCESS == SnapinsKey.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\MMC\\SnapIns", KEY_READ))
506 {
507 WCHAR namebuf[MAX_PATH];
508 DWORD index = 0, namelen = _countof(namebuf);
509 while (ERROR_SUCCESS == SnapinsKey.EnumKey(index++, namebuf, &namelen))
510 {
511 DPRINT1("%S\n", namebuf);
512 CSnapinCacheEntry* snapin = CSnapinCacheEntry::Create(SnapinsKey, namebuf, m_hSnapinImageList);
513 DPRINT1("CacheEntry %p\n", snapin);
514 if (snapin)
515 {
516 m_SnapinCache.Add(snapin);
517 }
518 namelen = _countof(namebuf);
519 }
520 SnapinsKey.Close();
521 }
522 return S_OK;
523}
#define DPRINT1
Definition: precomp.h:8
LONG EnumKey(DWORD iIndex, LPTSTR pszName, LPDWORD pnNameLength, FILETIME *pftLastWriteTime=NULL) noexcept
Definition: atlbase.h:1421
static CSnapinCacheEntry * Create(CRegKey &SnapinsKey, PWSTR guidString, HIMAGELIST hImageList)
GLint namelen
Definition: glext.h:7232
GLuint index
Definition: glext.h:6031
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CMainWnd().

◆ OnClose()

LRESULT CMainWnd::OnClose ( UINT  nMessage,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)

Definition at line 137 of file CMainWnd.cpp.

138{
140 return 0;
141}
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ OnCloseChild()

LRESULT CMainWnd::OnCloseChild ( UINT  nMessage,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)

Definition at line 121 of file CMainWnd.cpp.

122{
123 UpdateTitle();
124 UpdateMenu();
125 return 0;
126}
void UpdateMenu()
Definition: CMainWnd.h:129
void UpdateTitle()
Definition: CMainWnd.h:138

◆ OnCreate()

LRESULT CMainWnd::OnCreate ( UINT  nMessage,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)

Definition at line 72 of file CMainWnd.cpp.

73{
75 LPCTSTR lpFileName = (LPCTSTR)(((LPCREATESTRUCT)lParam)->lpCreateParams);
76 RECT rect;
77
79
80 /* Create and initialize the Toolbar */
82 m_ToolBar.Create(m_hWnd,
84 0);
85
86 m_ToolBar.SendMessageW(TB_SETBITMAPSIZE, 0, MAKELONG(16, 16));
87 m_ToolBar.SendMessageW(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
88
91
92 m_ToolBar.GetClientRect(&rect);
94
97
98 /* Create the MDI client window */
101
105
106 if (lpFileName == NULL)
107 {
109 }
110 return 0;
111}
static TBBUTTON TbButtons[]
Definition: CMainWnd.cpp:12
#define IDM_FILE_NEW
Definition: resource.h:11
#define IDM_MDI_FIRSTCHILD
Definition: resource.h:19
#define U(x)
Definition: wordpad.c:45
HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:417
BOOL UpdateWindow()
Definition: atlwin.h:1345
BOOL ShowWindow(int nCmdShow)
Definition: atlwin.h:1333
CToolbar< DWORD_PTR > m_ToolBar
Definition: CMainWnd.h:37
int m_iToolBarHeight
Definition: CMainWnd.h:38
HWND Create(HWND hWndParent, DWORD dwStyles=0, DWORD dwExStyles=0)
Definition: rosctrls.h:256
HIMAGELIST SetImageList(HIMAGELIST himl)
Definition: rosctrls.h:424
RECT rect
Definition: combotst.c:67
LPARAM lParam
Definition: combotst.c:139
LONG_PTR LPARAM
Definition: minwindef.h:175
LPCSTR LPCTSTR
Definition: ms-dtyp.idl:130
#define WS_CHILD
Definition: pedump.c:617
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TB_SETBITMAPSIZE
Definition: commctrl.h:1136
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
#define WM_COMMAND
Definition: winuser.h:1768
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define PostMessage
Definition: winuser.h:5998
#define SW_SHOW
Definition: winuser.h:786
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
#define MAKELONG(a, b)
Definition: typedefs.h:249
_In_ LPCSTR lpFileName
Definition: winbase.h:2800

◆ OnDestroy()

LRESULT CMainWnd::OnDestroy ( UINT  nMessage,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)

Definition at line 129 of file CMainWnd.cpp.

130{
132 SetMenu(NULL);
133 return 0;
134}
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

◆ OnFileAdd()

LRESULT CMainWnd::OnFileAdd ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 299 of file CMainWnd.cpp.

300{
302 if (child == NULL)
303 return 0;
304 CAddDialog dlg(this, child);
305 if (dlg.DoModal(m_hWnd, (LPARAM)child) == IDOK)
306 {
307 UpdateViews();
308 }
309
310 return 0;
311}
void UpdateViews()
Definition: CMainWnd.cpp:577
CConsoleWnd * GetActiveChildInfo()
Definition: CMainWnd.h:147
static HWND child
Definition: cursoricon.c:298
#define IDOK
Definition: winuser.h:841

◆ OnFileExit()

LRESULT CMainWnd::OnFileExit ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 344 of file CMainWnd.cpp.

345{
346 PostMessage(WM_CLOSE, 0, 0);
347 return 0;
348}
#define WM_CLOSE
Definition: winuser.h:1649

◆ OnFileNew()

LRESULT CMainWnd::OnFileNew ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 144 of file CMainWnd.cpp.

145{
147 HWND hChild;
149// CAtlString nodeGuid(L"{C96401CC-0E17-11D3-885B-00C04F72C717}");
150
151 /* Close all views */
152 POSITION pos = m_ViewList.GetHeadPosition();
153 while (pos)
154 {
155 CConsoleWnd *console = (CConsoleWnd*)m_ViewList.GetNext(pos);
156 console->SendMessage(WM_CLOSE, 0, 0);
157 }
158
159 /* Delete the snapin tree */
160 delete m_RootNode;
162
163 /* Create a new snapin root node */
164 CSnapinCacheEntry *CacheEntry = GetSnapinCacheEntryByGuid((PWSTR)L"{C96401CC-0E17-11D3-885B-00C04F72C717}");
165 if (!CacheEntry)
166 {
167 DPRINT1("No folder cache entry!\n");
168 return 0;
169 }
170
171 m_RootNode = new CSnapin(CacheEntry, rootName.GetString());
172 if (!CacheEntry)
173 {
174 DPRINT1("No root folder!\n");
175 return 0;
176 }
177
178 /* Create a new view */
179 mcs.szTitle = rootName.GetString();
181 mcs.hOwner = _AtlBaseModule.GetModuleInstance();
182 mcs.x = mcs.cx = CW_USEDEFAULT;
183 mcs.y = mcs.cy = CW_USEDEFAULT;
184 mcs.style = MDIS_ALLCHILDSTYLES;
185 BOOL bMaximized = FALSE;
186 HWND hWndOld = (HWND)m_MDIClient.SendMessage(WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized);
187 mcs.lParam = bMaximized || !hWndOld;
188 /* This object registers itself in the _AtlWinModule to be assigned to the next window created */
190 /* Ask for a new MDI Child window */
192 if (hChild)
193 {
195 }
196 else
197 {
198 delete child;
199 delete m_RootNode;
201 }
202
203 UpdateTitle();
204 UpdateMenu();
205
206 return 1;
207}
static struct myctx * mcs
Definition: adnstest.c:53
#define IDS_CONSOLEROOT
Definition: resource.h:98
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1116
static LPCWSTR GetWndClassName()
Definition: CConsoleWnd.h:72
CAtlList< CConsoleWnd * > m_ViewList
Definition: CMainWnd.h:46
CSnapinCacheEntry * GetSnapinCacheEntryByGuid(PWSTR pszGuid)
Definition: CMainWnd.cpp:538
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT GetString(REFGUID guidKey, [out, size_is(cchBufSize)] LPWSTR pwszValue, UINT32 cchBufSize, [in, out, ptr] UINT32 *pcchLength)
static HTREEITEM hChild
Definition: treeview.c:383
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_MDICREATE
Definition: winuser.h:1840
#define MDIS_ALLCHILDSTYLES
Definition: winuser.h:253
#define CW_USEDEFAULT
Definition: winuser.h:225
uint16_t * PWSTR
Definition: typedefs.h:56

◆ OnFileOpen()

LRESULT CMainWnd::OnFileOpen ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 210 of file CMainWnd.cpp.

211{
212 OPENFILENAME openas;
214
216 if (child == NULL)
217 return 0;
218
219 ZeroMemory(&openas, sizeof(openas));
220 wcscpy(szPath, L"");
221
222 openas.lStructSize = sizeof(OPENFILENAME);
223 openas.hwndOwner = m_hWnd;
224 openas.hInstance = _AtlBaseModule.GetModuleInstance();
225 openas.lpstrFilter = L"MSC Files (*.msc)\0*.msc\0All Files (*.*)\0*.*\0";
226 openas.lpstrFile = szPath;
227 openas.nMaxFile = MAX_PATH;
229 openas.lpstrDefExt = L"msc";
230
231 if (GetOpenFileNameW(&openas))
232 {
235 if (ret == ERROR_SUCCESS)
237 }
238
239 return 0;
240}
VOID AddToRecentFiles(const CAtlString &FileName)
Definition: CMainWnd.cpp:726
LRESULT LoadMscFile(const CAtlString &FileName)
Definition: CMainWnd.cpp:910
CAtlString m_Filename
Definition: CMainWnd.h:55
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4760
return ret
Definition: mutex.c:147
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LRESULT
Definition: minwindef.h:176
LPCWSTR szPath
Definition: env.c:37
wcscpy
LPCSTR lpstrDefExt
Definition: commdlg.h:345
HWND hwndOwner
Definition: commdlg.h:330
HINSTANCE hInstance
Definition: commdlg.h:331
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337

◆ OnFileOptions()

LRESULT CMainWnd::OnFileOptions ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 314 of file CMainWnd.cpp.

315{
317 if (child == NULL)
318 return 0;
319 COptionsDialog dlg(this, child);
320 dlg.DoModal(m_hWnd, (LPARAM)child);
321 return 0;
322}

◆ OnFileRecent()

LRESULT CMainWnd::OnFileRecent ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 325 of file CMainWnd.cpp.

326{
328
329 mi.cbSize = sizeof(MENUITEMINFOW);
330 mi.fMask = MIIM_DATA;
331 if (GetMenuItemInfoW(GetMenu(), wID, FALSE, &mi))
332 {
333 CRecentFileEntry *FileEntry = (CRecentFileEntry *)mi.dwItemData;
334
335 LRESULT ret = LoadMscFile(FileEntry->FileName());
336 if (ret == ERROR_SUCCESS)
337 AddToRecentFiles(FileEntry->FileName());
338 }
339
340 return 0;
341}
const CAtlString & FileName() const
static MONITORINFO mi
Definition: win.c:9400
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define MIIM_DATA
Definition: winuser.h:737
HMENU WINAPI GetMenu(_In_ HWND)
struct tagMENUITEMINFOW MENUITEMINFOW
DWORD cbSize
Definition: winuser.h:3892

◆ OnFileSave()

LRESULT CMainWnd::OnFileSave ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 243 of file CMainWnd.cpp.

244{
246 if (child == NULL)
247 return 0;
248
249 if (m_Filename.IsEmpty())
250 return OnFileSaveAs(wNotifyCode, wID, hWndCtl, bHandled);
251
252 return SaveMscFile(m_Filename);
253}
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
LRESULT OnFileSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: CMainWnd.cpp:256
LRESULT SaveMscFile(const CAtlString &FileName)
Definition: CMainWnd.cpp:812

◆ OnFileSaveAs()

LRESULT CMainWnd::OnFileSaveAs ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 256 of file CMainWnd.cpp.

257{
258 OPENFILENAME saveas;
260
262 if (child == NULL)
263 return 0;
264
265 ZeroMemory(&saveas, sizeof(saveas));
266 if (!m_Filename.IsEmpty())
267 {
269 }
270 else
271 {
272 child->GetWindowText(szPath, MAX_PATH);
274 wcscat(szPath, L".msc");
275 }
276
277 saveas.lStructSize = sizeof(OPENFILENAME);
278 saveas.hwndOwner = m_hWnd;
279 saveas.hInstance = _AtlBaseModule.GetModuleInstance();
280 saveas.lpstrFilter = L"MSC Files (*.msc)\0*.msc\0All Files (*.*)\0*.*\0";
281 saveas.lpstrFile = szPath;
282 saveas.nMaxFile = MAX_PATH;
284 saveas.lpstrDefExt = L"msc";
285
286 if (GetSaveFileNameW(&saveas))
287 {
290 if (ret == ERROR_SUCCESS)
292 return ret;
293 }
294
295 return 0;
296}
DWORD CreateNewFilename(PWSTR pBuffer, DWORD dwSize, DWORD Number)
Definition: CMainWnd.cpp:778
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4825
wcscat

Referenced by OnFileSave().

◆ OnHelpAboutMMC()

LRESULT CMainWnd::OnHelpAboutMMC ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 412 of file CMainWnd.cpp.

413{
414 HICON hIcon = LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAINAPP));
417 CAtlString TitleString;
418
419 TitleString = AboutTitle;
420 TitleString += L"#";
421 TitleString += AppTitle;
422
423 ::ShellAboutW(this->m_hWnd, (LPWSTR)TitleString.GetString(), NULL, hIcon);
424
425 return 0;
426}
#define IDS_APPTITLE
Definition: resource.h:3
#define IDS_ABOUTTITLE
Definition: resource.h:15
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
uint16_t * LPWSTR
Definition: typedefs.h:56

◆ OnMDIForward()

LRESULT CMainWnd::OnMDIForward ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 451 of file CMainWnd.cpp.

452{
454 if (hChild)
455 {
456 WPARAM wParam = MAKEWPARAM(wNotifyCode, wID);
457 LPARAM lParam = (LPARAM)hWndCtl;
459 }
460 return 0;
461}
WPARAM wParam
Definition: combotst.c:138
UINT_PTR WPARAM
Definition: minwindef.h:174
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define SendMessage
Definition: winuser.h:6009

◆ OnSize()

LRESULT CMainWnd::OnSize ( UINT  nMessage,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)

Definition at line 114 of file CMainWnd.cpp.

115{
116 UpdateLayout();
117 return 0;
118}
void UpdateLayout()
Definition: CMainWnd.cpp:593

◆ OnToolbarActionsPane()

LRESULT CMainWnd::OnToolbarActionsPane ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 440 of file CMainWnd.cpp.

441{
443 if (child == NULL)
444 return 0;
445
446 child->SetActionsPaneVisible(!child->IsActionsPaneVisible());
447 return 0;
448}

◆ OnToolbarScopePane()

LRESULT CMainWnd::OnToolbarScopePane ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 429 of file CMainWnd.cpp.

430{
432 if (child == NULL)
433 return 0;
434
435 child->SetTreeViewVisible(!child->IsTreeViewVisible());
436 return 0;
437}

◆ OnViewCustomize()

LRESULT CMainWnd::OnViewCustomize ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 351 of file CMainWnd.cpp.

352{
354 if (child == NULL)
355 return 0;
356
357 CCustomizeDialog dlg2(this, child);
358 dlg2.DoModal(m_hWnd, (LPARAM)child);
359 return 0;
360}

◆ OnWindowsArrange()

LRESULT CMainWnd::OnWindowsArrange ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 405 of file CMainWnd.cpp.

406{
408 return 0;
409}
#define WM_MDIICONARRANGE
Definition: winuser.h:1848

◆ OnWindowsCascade()

LRESULT CMainWnd::OnWindowsCascade ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 391 of file CMainWnd.cpp.

392{
394 return 0;
395}
#define WM_MDICASCADE
Definition: winuser.h:1847

◆ OnWindowsNew()

LRESULT CMainWnd::OnWindowsNew ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 363 of file CMainWnd.cpp.

364{
366 HWND hChild;
367
368 mcs.szTitle = m_RootNode->DisplayName().GetString();
370 mcs.hOwner = _AtlBaseModule.GetModuleInstance();
371 mcs.x = mcs.cx = CW_USEDEFAULT;
372 mcs.y = mcs.cy = CW_USEDEFAULT;
373 mcs.style = MDIS_ALLCHILDSTYLES;
374 BOOL bMaximized = FALSE;
375 HWND hWndOld = (HWND)m_MDIClient.SendMessage(WM_MDIGETACTIVE, 0, (LPARAM)&bMaximized);
376 mcs.lParam = bMaximized || !hWndOld;
377 /* This object registers itself in the _AtlWinModule to be assigned to the next window created */
379 /* Ask for a new MDI Child window */
381 if (!hChild)
382 {
383 delete child;
384 }
385
386 UpdateMenu();
387 return 0;
388}
const CAtlString & DisplayName() const
Definition: CSnapin.cpp:40

◆ OnWindowsTile()

LRESULT CMainWnd::OnWindowsTile ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL &  bHandled 
)

Definition at line 398 of file CMainWnd.cpp.

399{
401 return 0;
402}
#define WM_MDITILE
Definition: winuser.h:1846
#define MDITILE_HORIZONTAL
Definition: winuser.h:2224

◆ ProgramModeToString()

LPWSTR CMainWnd::ProgramModeToString ( )
private

Definition at line 790 of file CMainWnd.cpp.

791{
792 switch (m_DocumentMode)
793 {
795 return (LPWSTR)L"Author";
796
798 return (LPWSTR)L"User";
799
801 return (LPWSTR)L"UserMDI";
802
804 return (LPWSTR)L"UserSDI";
805
806 default:
807 return (LPWSTR)L"";
808 }
809}
@ DocumentMode_UserSDI
Definition: precomp.h:46
@ DocumentMode_User
Definition: precomp.h:44
@ DocumentMode_UserMDI
Definition: precomp.h:45

Referenced by SaveMscFile().

◆ RegisterView()

int CMainWnd::RegisterView ( CConsoleWnd *  pView)

Definition at line 562 of file CMainWnd.cpp.

563{
564 m_ViewList.AddTail(pView);
565 return m_NextViewId++;
566}

Referenced by CConsoleWnd::OnCreate().

◆ SaveMscFile()

LRESULT CMainWnd::SaveMscFile ( const CAtlString &  FileName)
private

Definition at line 812 of file CMainWnd.cpp.

813{
814 IXMLDOMElement *pRootNode = NULL;
815 IXMLDOMElement *pNode = NULL;
816 IXMLDOMElement *pFrameStateNode = NULL;
817 IXMLDOMElement *pViewsNode = NULL;
818 IXMLDOMElement *pScopeTreeNode = NULL;
819 IXMLDOMElement *pSnapinCacheNode = NULL;
820 IXMLDOMElement *pSnapinNode = NULL;
821 IXMLDOMElement *pNodesNode = NULL;
823 CConsoleWnd* console;
824 HRESULT hr = S_OK;
825
826 MscFile *mscFile = new MscFile(FileName.GetString());
827
828 CHK_HR(mscFile->CreateAndInitDOM());
829
830 /* <?xml version="1.0"?> */
831 CHK_HR(mscFile->CreateAndAddPINode(L"xml", L"version='1.0'"));
832
833 /* <MMC_ConsoleFile ConsoleVersion="2.0" ProgramMode="Author"> */
834 CHK_HR(mscFile->CreateElement(L"MMC_ConsoleFile", &pRootNode));
835 CHK_HR(mscFile->CreateAndAddAttributeNode(L"ConsoleVersion", L"2.0", pRootNode));
836 CHK_HR(mscFile->CreateAndAddAttributeNode(L"ProgramMode", ProgramModeToString(), pRootNode));
837
838 /* <ConsoleFileID> */
839 CHK_HR(mscFile->CreateAndAddElementNode(L"ConsoleFileID", pRootNode, &pNode));
840 CHK_HR(mscFile->CreateAndAddTextNode(L"{Random GUID}", pNode));
841 SAFE_RELEASE(pNode); /* </ConsoleFileID> */
842
843 /* <FrameState> */
844 CHK_HR(mscFile->CreateAndAddElementNode(L"FrameState", pRootNode, &pFrameStateNode));
845 CHK_HR(mscFile->CreateAndAddAttributeNode(L"ShowStatusBar", L"true", pFrameStateNode));
847 CHK_HR(mscFile->CreateAndAddAttributeNode(L"LogicalReadOnly", L"true", pFrameStateNode));
849 CHK_HR(mscFile->CreateAndAddAttributeNode(L"PreventViewCustomization", L"true", pFrameStateNode));
850
851 mscFile->SaveWindowPlacement(this, pFrameStateNode);
852
853 SAFE_RELEASE(pFrameStateNode); /* </FrameState> */
854
855 /* <Views> */
856 CHK_HR(mscFile->CreateAndAddElementNode(L"Views", pRootNode, &pViewsNode));
857 pos = m_ViewList.GetHeadPosition();
858 do
859 {
860 console = (CConsoleWnd*)m_ViewList.GetNext(pos);
861 if (console)
862 console->SaveView(mscFile, pViewsNode);
863
864 } while (pos != NULL);
865 SAFE_RELEASE(pViewsNode); /* </Views> */
866
867 /* <ScopeTree> */
868 CHK_HR(mscFile->CreateAndAddElementNode(L"ScopeTree", pRootNode, &pScopeTreeNode));
869
870 /* <SnapinCache> */
871 CHK_HR(mscFile->CreateAndAddElementNode(L"SnapinCache", pScopeTreeNode, &pSnapinCacheNode));
872
873 for (int i = 0; i < GetSnapinCacheCount(); i++)
874 {
876 if (entry)
877 {
878 /* <Snapin> */
879 CHK_HR(mscFile->CreateAndAddElementNode(L"Snapin", pSnapinCacheNode, &pSnapinNode));
880 CHK_HR(mscFile->CreateAndAddAttributeNode(L"CLSID", entry->GuidString().GetString(), pSnapinNode));
881 CHK_HR(mscFile->CreateAndAddAttributeNode(L"AllExtensionsEnabled", L"true", pSnapinNode)); /* FIXME */
882 CHK_HR(mscFile->CreateAndAddAttributeNode(L"Name", entry->Name().GetString(), pSnapinNode));
883 CHK_HR(mscFile->CreateAndAddAttributeNode(L"Provider", entry->Provider().GetString(), pSnapinNode));
884 SAFE_RELEASE(pSnapinNode); /* </Snapin> */
885 }
886 }
887 SAFE_RELEASE(pSnapinCacheNode); /* </SnapinCache> */
888
889 /* <Nodes> */
890 CHK_HR(mscFile->CreateAndAddElementNode(L"Nodes", pScopeTreeNode, &pNodesNode));
891 if (m_RootNode)
892 m_RootNode->SaveNode(mscFile, pNodesNode);
893 SAFE_RELEASE(pNodesNode); /* </Nodes> */
894
895 SAFE_RELEASE(pScopeTreeNode); /* </ScopeTree> */
896
897 CHK_HR(mscFile->AppendChildToParent(pRootNode));
898
899 CHK_HR(mscFile->SaveDOM());
900
901CleanUp:
902 SAFE_RELEASE(pRootNode); /* </MMC_ConsoleFile> */
903
904 delete mscFile;
905
906 return 0;
907}
VOID SaveView(MscFile *mscFile, IXMLDOMElement *pParentElement)
LPWSTR ProgramModeToString()
Definition: CMainWnd.cpp:790
int GetSnapinCacheCount()
Definition: CMainWnd.cpp:526
CSnapinCacheEntry * GetSnapinCacheEntry(int nIndex)
Definition: CMainWnd.cpp:532
VOID SaveNode(MscFile *mscFile, IXMLDOMElement *pParentNode)
Definition: CSnapin.cpp:110
HRESULT CreateAndAddTextNode(PCWSTR wszText, IXMLDOMNode *pParent)
Definition: mscfile.cpp:162
HRESULT CreateElement(PCWSTR wszName, IXMLDOMElement **ppElement)
Definition: mscfile.cpp:65
HRESULT SaveWindowPlacement(CWindow *pWindow, IXMLDOMElement *pParentNode)
Definition: mscfile.cpp:264
HRESULT SaveDOM()
Definition: mscfile.cpp:337
HRESULT CreateAndAddAttributeNode(PCWSTR wszName, PCWSTR wszValue, IXMLDOMElement *pParent)
Definition: mscfile.cpp:135
HRESULT AppendChildToParent(IXMLDOMNode *pChild, IXMLDOMNode *pParent=NULL)
Definition: mscfile.cpp:81
HRESULT CreateAndAddPINode(PCWSTR wszTarget, PCWSTR wszData)
Definition: mscfile.cpp:97
HRESULT CreateAndAddElementNode(PCWSTR wszName, IXMLDOMNode *pParent, IXMLDOMElement **ppElement=NULL)
Definition: mscfile.cpp:199
#define SAFE_RELEASE(p)
Definition: mscfile.h:15

Referenced by OnFileSave(), and OnFileSaveAs().

◆ SetConsoleTitle()

void CMainWnd::SetConsoleTitle ( CAtlString  consoleTitle)

Definition at line 468 of file CMainWnd.cpp.

469{
470 m_ConsoleTitle = consoleTitle;
471 SetWindowTextW(consoleTitle.GetString());
472}
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)

Referenced by COptionsDialog::OnCommand().

◆ SetDocumentMode()

void CMainWnd::SetDocumentMode ( DOCUMENT_MODE  DocumentMode)

Definition at line 625 of file CMainWnd.cpp.

626{
627 m_DocumentMode = DocumentMode;
628}

Referenced by COptionsDialog::OnCommand().

◆ SetLogicalReadOnly()

void CMainWnd::SetLogicalReadOnly ( BOOL  LogicalReadOnly)

Definition at line 637 of file CMainWnd.cpp.

638{
639 m_LogicalReadOnly = LogicalReadOnly;
640}

Referenced by COptionsDialog::OnCommand().

◆ SetPreventViewCustomization()

void CMainWnd::SetPreventViewCustomization ( BOOL  PreventCustomization)

Definition at line 649 of file CMainWnd.cpp.

650{
651 m_PreventViewCustomization = PreventCustomization;
652}

Referenced by COptionsDialog::OnCommand().

◆ SetStandardMenusVisible()

VOID CMainWnd::SetStandardMenusVisible ( BOOL  bVisible)

Definition at line 494 of file CMainWnd.cpp.

495{
496 m_bStandardMenusVisible = bVisible;
497// m_MainWnd->UpdateMenu(m_bStandardMenusVisible);
498// UpdateLayout();
499}

Referenced by CCustomizeDialog::OnCommand().

◆ SetToolBarVisible()

VOID CMainWnd::SetToolBarVisible ( BOOL  bVisible)

Definition at line 481 of file CMainWnd.cpp.

482{
483 m_bToolBarVisible = bVisible;
484 UpdateLayout();
485}

Referenced by CCustomizeDialog::OnCommand().

◆ SnapinImageList()

HIMAGELIST CMainWnd::SnapinImageList ( )

Definition at line 550 of file CMainWnd.cpp.

551{
552 return m_hSnapinImageList;
553}

Referenced by CAddDialog::InitLV(), CAddDialog::InitTV(), and CConsoleWnd::OnCreate().

◆ UnregisterView()

void CMainWnd::UnregisterView ( CConsoleWnd *  pView)

Definition at line 569 of file CMainWnd.cpp.

570{
571 POSITION pos = m_ViewList.Find(pView);
572 if (pos)
573 m_ViewList.RemoveAt(pos);
574}

Referenced by CConsoleWnd::OnDestroy().

◆ UpdateLayout()

void CMainWnd::UpdateLayout ( )
private

Definition at line 593 of file CMainWnd.cpp.

594{
595 RECT rcClient, rcToolBar = {0, 0, 0, 0};
596 GetClientRect(&rcClient);
597
598 int nToolBarFlags = SWP_NOZORDER;
600 {
601 rcClient.top += m_iToolBarHeight;
602 rcClient.bottom -= m_iToolBarHeight;
603
604 rcToolBar.right = rcClient.right;
605 rcToolBar.bottom = m_iToolBarHeight;
606 nToolBarFlags |= SWP_SHOWWINDOW;
607 }
608 else
609 {
610 nToolBarFlags |= SWP_HIDEWINDOW;
611 }
612
613 m_ToolBar.SetWindowPos(NULL, rcToolBar.left, rcToolBar.top, rcToolBar.right, rcToolBar.bottom, nToolBarFlags);
614
615 m_MDIClient.SetWindowPos(NULL, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, SWP_NOZORDER);
616}
BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
Definition: atlwin.h:1288
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define SWP_HIDEWINDOW
Definition: winuser.h:1252
#define SWP_NOZORDER
Definition: winuser.h:1258
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29

Referenced by OnSize(), and SetToolBarVisible().

◆ UpdateMenu()

void CMainWnd::UpdateMenu ( )
inlineprivate

Definition at line 129 of file CMainWnd.h.

130 {
131 if (m_ViewList.IsEmpty())
133 else
136 }

Referenced by OnCloseChild(), OnFileNew(), and OnWindowsNew().

◆ UpdateRecentFilesMenu()

VOID CMainWnd::UpdateRecentFilesMenu ( )
private

Definition at line 655 of file CMainWnd.cpp.

656{
658 HMENU hMenu = GetMenu();
659
660 mi.cbSize = sizeof(MENUITEMINFOW);
662 mi.fType = MFT_STRING;
663 mi.wID = IDM_FILE_RECENT1;
664
666
667 INT i = 0;
669 POSITION pos = m_RecentFilesList.GetHeadPosition();
670 while (pos != NULL)
671 {
673
674 CRecentFileEntry *FileEntry = m_RecentFilesList.GetNext(pos);
675 ValueName.Format(L"%d %s", i + 1, FileEntry->DisplayName().GetString());
676 mi.dwTypeData = ValueName.GetString();
677 mi.dwItemData = (ULONG_PTR)FileEntry;
678
680 mi.wID++;
681
682 i++;
683 if (i >= MAX_RECENT_FILES)
684 break;
685 }
686
687 mi.fType = MFT_SEPARATOR;
688 mi.fMask = MIIM_FTYPE | MIIM_ID;
690}
#define IDM_FILE_EXIT
Definition: resource.h:15
#define IDM_FILE_RECENT1
Definition: resource.h:32
#define IDM_FILE_RECENT_SEP
Definition: resource.h:36
const CAtlString & DisplayName() const
#define ULONG_PTR
Definition: config.h:101
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MIIM_STRING
Definition: winuser.h:738
#define MIIM_ID
Definition: winuser.h:733
#define MIIM_FTYPE
Definition: winuser.h:740
#define MFT_SEPARATOR
Definition: winuser.h:755
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MFT_STRING
Definition: winuser.h:757
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

Referenced by AddToRecentFiles(), LoadRecentFiles(), and UpdateMenu().

◆ UpdateTitle()

void CMainWnd::UpdateTitle ( )
inlineprivate

Definition at line 138 of file CMainWnd.h.

139 {
140 if (m_ViewList.IsEmpty())
141 m_ConsoleTitle.LoadString(IDS_APPTITLE);
142 else
144 SetWindowTextW(m_ConsoleTitle.GetString());
145 }
void CreateNewConsoleTitle(CAtlString &str)
Definition: CMainWnd.h:158

Referenced by OnCloseChild(), and OnFileNew().

◆ UpdateViews()

void CMainWnd::UpdateViews ( )
private

Definition at line 577 of file CMainWnd.cpp.

578{
579 CConsoleWnd *console;
581
582 pos = m_ViewList.GetHeadPosition();
583 while (pos)
584 {
585 console = (CConsoleWnd*)m_ViewList.GetNext(pos);
586 if (console)
587 console->UpdateView();
588
589 }
590}
VOID UpdateView()

Referenced by OnFileAdd().

◆ XDefFrameProc()

static LRESULT CALLBACK CMainWnd::XDefFrameProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
inlinestatic

Definition at line 121 of file CMainWnd.h.

122 {
123 CMainWnd* pThis = reinterpret_cast<CMainWnd*>(hWnd);
124 return ::DefFrameProc(pThis->m_hWnd, pThis->m_MDIClient.m_hWnd, uMsg, wParam, lParam);
125 }
HWND hWnd
Definition: settings.c:17

Referenced by CMainWnd().

Member Data Documentation

◆ m_bStandardMenusVisible

BOOL CMainWnd::m_bStandardMenusVisible
private

Definition at line 41 of file CMainWnd.h.

Referenced by AreStandardMenusVisible(), OnCreate(), and SetStandardMenusVisible().

◆ m_bToolBarVisible

BOOL CMainWnd::m_bToolBarVisible
private

Definition at line 39 of file CMainWnd.h.

Referenced by IsToolBarVisible(), OnCreate(), SetToolBarVisible(), and UpdateLayout().

◆ m_ConsoleNumber

int CMainWnd::m_ConsoleNumber
private

Definition at line 29 of file CMainWnd.h.

Referenced by CreateNewConsoleTitle(), OnFileNew(), and OnFileSaveAs().

◆ m_ConsoleTitle

CAtlString CMainWnd::m_ConsoleTitle
private

Definition at line 30 of file CMainWnd.h.

Referenced by GetConsoleTitle(), SetConsoleTitle(), and UpdateTitle().

◆ m_DocumentMode

DOCUMENT_MODE CMainWnd::m_DocumentMode
private

Definition at line 33 of file CMainWnd.h.

Referenced by GetDocumentMode(), ProgramModeToString(), SaveMscFile(), and SetDocumentMode().

◆ m_Filename

CAtlString CMainWnd::m_Filename

Definition at line 55 of file CMainWnd.h.

Referenced by OnFileOpen(), OnFileSave(), and OnFileSaveAs().

◆ m_FrameThunk

CWndProcThunk CMainWnd::m_FrameThunk
private

Definition at line 27 of file CMainWnd.h.

Referenced by CMainWnd().

◆ m_hMenuConsoleLarge

HMENU CMainWnd::m_hMenuConsoleLarge
private

Definition at line 32 of file CMainWnd.h.

Referenced by CMainWnd(), OnCreate(), UpdateMenu(), and ~CMainWnd().

◆ m_hMenuConsoleSmall

HMENU CMainWnd::m_hMenuConsoleSmall
private

Definition at line 31 of file CMainWnd.h.

Referenced by CMainWnd(), UpdateMenu(), and ~CMainWnd().

◆ m_hSnapinImageList

HIMAGELIST CMainWnd::m_hSnapinImageList
private

Definition at line 44 of file CMainWnd.h.

Referenced by CMainWnd(), LoadSnapinCache(), SnapinImageList(), and ~CMainWnd().

◆ m_hToolBarImageList

HIMAGELIST CMainWnd::m_hToolBarImageList
private

Definition at line 40 of file CMainWnd.h.

Referenced by CMainWnd(), OnCreate(), and ~CMainWnd().

◆ m_iToolBarHeight

int CMainWnd::m_iToolBarHeight
private

Definition at line 38 of file CMainWnd.h.

Referenced by OnCreate(), and UpdateLayout().

◆ m_LogicalReadOnly

BOOL CMainWnd::m_LogicalReadOnly
private

Definition at line 34 of file CMainWnd.h.

Referenced by GetLogicalReadOnly(), SaveMscFile(), and SetLogicalReadOnly().

◆ m_MDIClient

◆ m_NextViewId

int CMainWnd::m_NextViewId
private

Definition at line 47 of file CMainWnd.h.

Referenced by RegisterView().

◆ m_PreventViewCustomization

BOOL CMainWnd::m_PreventViewCustomization
private

◆ m_RecentFilesList

CAtlList<CRecentFileEntry *> CMainWnd::m_RecentFilesList
private

Definition at line 51 of file CMainWnd.h.

Referenced by AddToRecentFiles(), LoadRecentFiles(), and UpdateRecentFilesMenu().

◆ m_RootNode

CSnapin* CMainWnd::m_RootNode
private

Definition at line 49 of file CMainWnd.h.

Referenced by GetRootSnapin(), OnFileNew(), OnWindowsNew(), and SaveMscFile().

◆ m_SnapinCache

CSimpleArray<CSnapinCacheEntry*> CMainWnd::m_SnapinCache
private

◆ m_ToolBar

CToolbar<DWORD_PTR> CMainWnd::m_ToolBar
private

Definition at line 37 of file CMainWnd.h.

Referenced by OnCreate(), and UpdateLayout().

◆ m_ViewList

CAtlList<CConsoleWnd*> CMainWnd::m_ViewList
private

The documentation for this class was generated from the following files: