Author: janderwald
Date: Tue Jul 4 17:36:57 2006
New Revision: 22822
URL:
http://svn.reactos.org/svn/reactos?rev=22822&view=rev
Log:
* halfplemented console system menu
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
trunk/reactos/subsystems/win32/csrss/win32csr/en.rc
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
trunk/reactos/subsystems/win32/csrss/win32csr/resource.h
trunk/reactos/subsystems/win32/csrss/win32csr/w32csr.h
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c Tue Jul 4 17:36:57 2006
@@ -20,7 +20,7 @@
/* GLOBALS *******************************************************************/
HANDLE Win32CsrApiHeap;
-HINSTANCE Win32CsrDllHandle;
+HINSTANCE Win32CsrDllHandle = NULL;
static CSRSS_EXPORTED_FUNCS CsrExports;
static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/en.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/en.rc (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/en.rc Tue Jul 4 17:36:57 2006
@@ -26,3 +26,15 @@
LTEXT "If you choose to end the program immediately, you will loose
any unsaved data. To end the program now, click End Now",
IDC_STATIC,7,53,178,26
END
+
+STRINGTABLE
+BEGIN
+ IDS_MARK "Mark"
+ IDS_COPY "Copy\tEnter"
+ IDS_PASTE "Paste"
+ IDS_SELECTALL "Select All"
+ IDS_SCROLL "Scroll"
+ IDS_FIND "Find..."
+ IDS_DEFAULTS "Defaults"
+ IDS_PROPERTIES "Properties"
+END
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c Tue Jul 4 17:36:57 2006
@@ -30,6 +30,7 @@
RECT Selection;
POINT SelectionStart;
BOOL MouseDown;
+ HMODULE ConsoleLibrary;
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
#ifndef WM_APP
@@ -634,6 +635,10 @@
KillTimer(hWnd, 1);
Console->PrivateData = NULL;
DeleteCriticalSection(&GuiData->Lock);
+ GetSystemMenu(hWnd, TRUE);
+ if (GuiData->ConsoleLibrary)
+ FreeLibrary(GuiData->ConsoleLibrary);
+
HeapFree(Win32CsrApiHeap, 0, GuiData);
}
@@ -774,6 +779,160 @@
GuiConsoleUpdateSelection(hWnd, NULL, GuiData);
}
+}
+
+static VOID
+GuiConsoleShowConsoleProperties(HWND hWnd, BOOL Defaults)
+{
+ PCSRSS_CONSOLE Console;
+ PGUI_CONSOLE_DATA GuiData;
+ APPLET_PROC CPLFunc;
+ TCHAR szBuffer[MAX_PATH];
+
+ GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
+
+ if (GuiData == NULL)
+ {
+ DPRINT1("GuiConsoleGetDataPointers failed\n");
+ return;
+ }
+ if (GuiData->ConsoleLibrary == NULL)
+ {
+ GetWindowsDirectory(szBuffer,MAX_PATH);
+ _tcscat(szBuffer, _T("\\system32\\console.dll"));
+ GuiData->ConsoleLibrary = LoadLibrary(szBuffer);
+
+ if (GuiData->ConsoleLibrary == NULL)
+ {
+ DPRINT1("failed to load console.dll");
+ return;
+ }
+ }
+
+ CPLFunc = (APPLET_PROC) GetProcAddress(GuiData->ConsoleLibrary,
_T("CPlApplet"));
+ if (!CPLFunc)
+ {
+ DPRINT("Error: Console.dll misses CPlApplet export\n");
+ return;
+ }
+
+ if (!CPLFunc(hWnd, CPL_INIT, 0, 0))
+ {
+ DPRINT("Error: failed to initialize console.dll\n");
+ return;
+ }
+
+ if (CPLFunc(hWnd, CPL_GETCOUNT, 0, 0) != 1)
+ {
+ DPRINT("Error: console.dll returned unexpected CPL count\n");
+ return;
+ }
+
+ CPLFunc(hWnd, CPL_DBLCLK, 0, Defaults);
+
+ // TODO
+ //
+ // read back the changes from console.dll
+ //
+ // if the changes are system-wide then
+ // console.dll should have written it to
+ // registry
+ //
+ // if the changes only apply to this session
+ // then exchange this info with console.dll in
+ // some private way
+}
+static LRESULT FASTCALL
+GuiConsoleHandleSysMenuCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+ DPRINT1("GuiConsoleHandleSysMenuCommand entered %d\n", wParam);
+
+ switch(wParam)
+ {
+ case IDS_MARK:
+ case IDS_COPY:
+ case IDS_PASTE:
+ case IDS_SELECTALL:
+ case IDS_SCROLL:
+ case IDS_FIND:
+ break;
+
+ case IDS_DEFAULTS:
+ GuiConsoleShowConsoleProperties(hWnd, TRUE);
+ break;
+ case IDS_PROPERTIES:
+ GuiConsoleShowConsoleProperties(hWnd, FALSE);
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+static BOOLEAN FASTCALL
+InsertItem(HMENU hMenu, INT fType, INT fMask, INT fState, HMENU hSubMenu, INT
ResourceId)
+{
+ MENUITEMINFO MenuItemInfo;
+ TCHAR szBuffer[MAX_PATH];
+
+ memset(&MenuItemInfo, 0x0, sizeof(MENUITEMINFO));
+ MenuItemInfo.cbSize = sizeof (MENUITEMINFO);
+ MenuItemInfo.fMask = fMask;
+ MenuItemInfo.fType = fType;
+ MenuItemInfo.fState = fState;
+ MenuItemInfo.hSubMenu = hSubMenu;
+ MenuItemInfo.wID = ResourceId;
+
+ if (fType != MFT_SEPARATOR)
+ {
+ MenuItemInfo.cch = LoadString(Win32CsrDllHandle, ResourceId, szBuffer, MAX_PATH);
+ if (!MenuItemInfo.cch)
+ {
+ DPRINT("LoadString failed ResourceId %d Error %x\n", ResourceId,
GetLastError());
+ return FALSE;
+ }
+ MenuItemInfo.dwTypeData = szBuffer;
+ }
+
+ if (InsertMenuItem(hMenu, ResourceId, FALSE, &MenuItemInfo))
+ return TRUE;
+
+ DPRINT("InsertMenuItem failed Last error %x\n", GetLastError());
+ return FALSE;
+}
+
+
+
+static VOID FASTCALL
+GuiConsoleCreateSysMenu(HWND hWnd)
+{
+ HMENU hMenu;
+ HMENU hSubMenu;
+
+
+ hMenu = GetSystemMenu(hWnd, FALSE);
+ if (hMenu == NULL)
+ {
+ DPRINT("GetSysMenu failed\n");
+ return;
+ }
+ /* insert seperator */
+ InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
+
+ /* create submenu */
+ hSubMenu = CreatePopupMenu();
+ InsertItem(hSubMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_MARK);
+ InsertItem(hSubMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING | MIIM_STATE,
MFS_GRAYED, NULL, IDS_COPY);
+ InsertItem(hSubMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_PASTE);
+ InsertItem(hSubMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SELECTALL);
+ InsertItem(hSubMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLL);
+ InsertItem(hSubMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_FIND);
+ InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING | MIIM_SUBMENU, 0,
hSubMenu, IDS_EDIT);
+
+ /* create default/properties item */
+ InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_DEFAULTS);
+ InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_PROPERTIES);
+ DrawMenuBar(hWnd);
}
static LRESULT CALLBACK
@@ -817,6 +976,8 @@
case WM_MOUSEMOVE:
GuiConsoleMouseMove(hWnd, wParam, lParam);
break;
+ case WM_SYSCOMMAND:
+ return GuiConsoleHandleSysMenuCommand(hWnd, wParam, lParam);
default:
Result = DefWindowProcW(hWnd, msg, wParam, lParam);
break;
@@ -833,6 +994,8 @@
MSG Msg;
PWCHAR Buffer, Title;
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam;
+
+
switch(msg)
{
@@ -854,7 +1017,7 @@
}
NewWindow = CreateWindowW(L"ConsoleWindowClass",
Title,
- WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX,
+ WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX, // | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
@@ -870,6 +1033,9 @@
Console->hWindow = NewWindow;
if (NULL != NewWindow)
{
+ GuiConsoleCreateSysMenu(NewWindow);
+ //ShowScrollBar(NewWindow, SB_VERT, FALSE);
+ //ShowScrollBar(NewWindow, SB_HORZ, FALSE);
SetWindowLongW(hWnd, GWL_USERDATA, GetWindowLongW(hWnd, GWL_USERDATA) + 1);
ShowWindow(NewWindow, SW_SHOW);
}
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/resource.h (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/resource.h Tue Jul 4 17:36:57 2006
@@ -15,6 +15,21 @@
#define IDC_PROGRESS 101
#define IDC_END_NOW 102
+
+#define NCPOPUP_MENU 103
+
+#define IDS_EDIT 204
+#define IDS_MARK 205
+#define IDS_COPY 206
+#define IDS_PASTE 207
+#define IDS_SELECTALL 208
+#define IDS_SCROLL 209
+#define IDS_FIND 210
+#define IDS_DEFAULTS 211
+#define IDS_PROPERTIES 212
+
+
+
#endif /* WIN32CSR_RESOURCE_H_INCLUDED */
/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/w32csr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/w32csr.h (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/w32csr.h Tue Jul 4 17:36:57 2006
@@ -19,4 +19,9 @@
#include "tuiconsole.h"
#include <win32csr.h>
+#include <tchar.h>
+#include <cpl.h>
+
+#include "resource.h"
+
/* EOF */