From 9fa9badcf4eb38946402af9c471a08d17cd6ef15 Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Sun, 6 Jul 2003 07:18:32 +0000 Subject: [PATCH] Added desktop part of explorer clone by Andrew "Silver Blade" Greenwood. svn path=/trunk/; revision=5005 --- reactos/subsys/system/explorer/desktop.c | 108 ++++++++++++++++++++ reactos/subsys/system/explorer/explorer.rc | 38 +++++++ reactos/subsys/system/explorer/makefile_rex | 18 ++++ reactos/subsys/system/explorer/readme.txt | 25 +++++ 4 files changed, 189 insertions(+) create mode 100644 reactos/subsys/system/explorer/desktop.c create mode 100644 reactos/subsys/system/explorer/explorer.rc create mode 100644 reactos/subsys/system/explorer/makefile_rex create mode 100644 reactos/subsys/system/explorer/readme.txt diff --git a/reactos/subsys/system/explorer/desktop.c b/reactos/subsys/system/explorer/desktop.c new file mode 100644 index 00000000000..5e27795da9a --- /dev/null +++ b/reactos/subsys/system/explorer/desktop.c @@ -0,0 +1,108 @@ +/* + Desktop creation example + + Silver Blade (silverblade_uk@hotmail.com) + 5th July 2003 +*/ + + +#include + +const char DesktopClassName[] = "DesktopWindow"; + + + +LRESULT CALLBACK DeskWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_CLOSE : + { + // Over-ride close. We need to close desktop some other way. + return 0; + } + + case WM_PAINT : + { + // We'd want to draw the desktop wallpaper here. Need to + // maintain a copy of the wallpaper in an off-screen DC and then + // bitblt (or stretchblt?) it to the screen appropriately. For + // now, though, we'll just draw some text. + + PAINTSTRUCT ps; + HDC DesktopDC = BeginPaint(hwnd, &ps); + + char Text [] = "ReactOS 0.1.2 Desktop Example\nby Silver Blade"; + + int Width, Height; + + Width = GetSystemMetrics(SM_CXSCREEN); + Height = GetSystemMetrics(SM_CYSCREEN); + + // This next part could be improved by working out how much + // space the text actually needs... + + RECT r; + r.left = Width - 260; + r.top = Height - 80; + r.right = r.left + 250; + r.bottom = r.top + 40; + + SetTextColor(DesktopDC, 0x00ffffff); + SetBkMode(DesktopDC, TRANSPARENT); + DrawText(DesktopDC, &Text, -1, &r, DT_RIGHT); + + EndPaint(hwnd, &ps); + } + } + + return DefWindowProc(hwnd, uMsg, wParam, lParam); +} + + + +int main() +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = 0; + wc.lpfnWndProc = &DeskWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = GetModuleHandle(NULL); + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground= (HBRUSH) GetStockObject(BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName= DesktopClassName; + wc.hIconSm = NULL; + + if (! RegisterClassEx(&wc)) + return 1; // error + + + HWND Desktop; + int Width, Height; + + Width = GetSystemMetrics(SM_CXSCREEN); + Height = GetSystemMetrics(SM_CYSCREEN); + + Desktop = CreateWindowEx(0, DesktopClassName, "Desktop", + WS_VISIBLE | WS_POPUP | WS_CLIPCHILDREN, + 0, 0, Width, Height, + NULL, NULL, GetModuleHandle(NULL), NULL); + + if (! Desktop) + return 1; // error + + MSG Msg; + + while (GetMessage(&Msg, 0, 0, 0) != 0) + { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + + return 0; // get the return code! +} diff --git a/reactos/subsys/system/explorer/explorer.rc b/reactos/subsys/system/explorer/explorer.rc new file mode 100644 index 00000000000..e897993f059 --- /dev/null +++ b/reactos/subsys/system/explorer/explorer.rc @@ -0,0 +1,38 @@ +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD + PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", RES_STR_COMPANY_NAME + VALUE "FileDescription", "ReactOS Explorer\0" + VALUE "FileVersion", RES_STR_FILE_VERSION + VALUE "InternalName", "explorer\0" + VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT + VALUE "OriginalFilename", "explorer.exe\0" + VALUE "ProductName", RES_STR_PRODUCT_NAME + VALUE "ProductVersion", RES_STR_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + diff --git a/reactos/subsys/system/explorer/makefile_rex b/reactos/subsys/system/explorer/makefile_rex new file mode 100644 index 00000000000..90db61142be --- /dev/null +++ b/reactos/subsys/system/explorer/makefile_rex @@ -0,0 +1,18 @@ +PATH_TO_TOP = ../../.. + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_SDKLIBS = gdi32.a + +TARGET_NAME = explorer + +TARGET_OBJECTS = \ + desktop.o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/subsys/system/explorer/readme.txt b/reactos/subsys/system/explorer/readme.txt new file mode 100644 index 00000000000..1abeebb87e1 --- /dev/null +++ b/reactos/subsys/system/explorer/readme.txt @@ -0,0 +1,25 @@ +Desktop Example +--------------- + +This program doesn't do much, apart from create a window which could be +used as a desktop. + +It's pretty straightforward. It creates a window the size of the screen, +displays some text in the corner, and then disables ALT+F4. + +Ideally, this would be incorporated into some other part of ReactOS, where +it could be closed in a controlled manner (ie, when the user wishes to exit +the GUI.) + +Hope someone finds it of some use. I think it should run before the +explorer clone (taskbar) to get the wallpaper displayed (since when +explorer crashes on Windows, the wallpaper is always displayed, and there +is always a desktop, even with no icons, when the login window is shown.) + +It obviously is in need of some improvement, such as wallpaper actually +being drawn (stretch, center/centre and tile...) + +So, feel free to play around with it. + +Andrew "Silver Blade" Greenwood +silverblade_uk@hotmail.com