BOOL IsAnyDesktopRunning()
{
- HINSTANCE shell32 = GetModuleHandle(TEXT("user32"));
+ HINSTANCE shell32 = GetModuleHandle(_T("user32"));
SetShellWindow = (BOOL(WINAPI*)(HWND)) GetProcAddress(shell32, "SetShellWindow");
SetShellWindowEx = (BOOL(WINAPI*)(HWND,HWND)) GetProcAddress(shell32, "SetShellWindowEx");
static void draw_desktop_background(HWND hwnd, HDC hdc)
{
- // 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.
-
- static const TCHAR BkgndText[] = TEXT("ReactOS 0.1.2 Desktop Example\nby Silver Blade, Martin Fuchs");
-
ClientRect rect(hwnd);
PaintDesktop(hdc);
FillRect(hdc, &rect, bkgndBrush);
DeleteBrush(bkgndBrush);
*/
- // This next part could be improved by working out how much
- // space the text actually needs...
rect.left = rect.right - 280;
rect.top = rect.bottom - 56 - DESKTOPBARBAR_HEIGHT;
rect.right = rect.left + 250;
rect.bottom = rect.top + 40;
+ static const LPCTSTR BkgndText = _T("ReactOS 0.1.2 Explorer\nby Martin Fuchs");
+
BkMode bkMode(hdc, TRANSPARENT);
TextColor textColor(hdc, RGB(128,128,192));
{
switch(nmsg) {
case WM_ERASEBKGND:
- draw_desktop_background(_hwnd, (HDC)wparam);
+ PaintDesktop((HDC)wparam);
return TRUE;
case WM_MBUTTONDBLCLK:
LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
- case WM_PAINT: {
- PaintCanvas canvas(_hwnd);
- draw_desktop_background(_hwnd, canvas);
- break;}
+ case WM_PAINT:
+ draw_desktop_background(_hwnd, PaintCanvas(_hwnd));
+ break;
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
}
+ResBitmap::ResBitmap(UINT nid)
+{
+ _hBmp = LoadBitmap(g_Globals._hInstance, MAKEINTRESOURCE(nid));
+}
+
+
void explorer_show_frame(HWND hwndDesktop, int cmdshow)
{
if (g_Globals._hMainWnd)
# End Source File
# Begin Source File
+SOURCE=.\res\logov.bmp
+# End Source File
+# Begin Source File
+
SOURCE=.\res\reactos.ico
# End Source File
# Begin Source File
#define IDS_ADMIN 15
#define IDS_NETWORK 16
#define IDS_CONNECTIONS 17
-#define IDS_DRIVES 18
+#define IDS_DRIVES 18
#define IDI_REACTOS 100
#define IDI_EXPLORER 101
#define IDI_STARTMENU 102
#define IDI_FOLDERARROW 125
#define IDI_ARROW 125
#define IDI_ARROW_SELECTED 126
+#define IDB_LOGOV 129
#define ID_VIEW_NAME 401
#define ID_VIEW_ALL_ATTRIBUTES 402
#define ID_VIEW_SELECTED_ATTRIBUTES 403
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
IDB_IMAGES BITMAP DISCARDABLE "res/images.bmp"
IDB_TOOLBAR BITMAP DISCARDABLE "res/toolbar.bmp"
IDB_DRIVEBAR BITMAP DISCARDABLE "res/drivebar.bmp"
+IDB_LOGOV BITMAP DISCARDABLE "res/logov.bmp"
/////////////////////////////////////////////////////////////////////////////
//
protected:
HICON _hIcon;
};
+
+struct ResBitmap
+{
+ ResBitmap(UINT nid);
+ ~ResBitmap() {DeleteObject(_hBmp);}
+
+ operator HBITMAP() const {return _hBmp;}
+
+protected:
+ HBITMAP _hBmp;
+};
int visible_cols = _visible_cols;
COLORREF bkcolor, textcolor;
RECT focusRect = dis->rcItem;
- HBRUSH hbrush;
enum IMAGE img;
int img_pos, cx;
int col = 0;
bkcolor = RGB(255,255,255);
}
- hbrush = CreateSolidBrush(bkcolor);
+ HBRUSH hbrush = CreateSolidBrush(bkcolor);
FillRect(dis->hDC, &focusRect, hbrush);
DeleteObject(hbrush);
{
_next_id = IDC_FIRST_MENU;
_submenu_id = 0;
+ _border_left = 0;
}
StartMenu::StartMenu(HWND hwnd, const StartMenuFolders& info)
_next_id = IDC_FIRST_MENU;
_submenu_id = 0;
+ _border_left = 0;
}
StartMenu::~StartMenu()
{
switch(nmsg) {
case WM_SIZE:
- ResizeButtons(LOWORD(lparam));
+ ResizeButtons(LOWORD(lparam)-_border_left);
break;
case WM_NCHITTEST: {
}
// widen window, if it is too small
- int width = StartMenuButton::GetTextWidth(title,_hwnd) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/;
+ int text_width = StartMenuButton::GetTextWidth(title,_hwnd) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/;
ClientRect clnt(_hwnd);
- if (width > clnt.right)
- rect.right += width-clnt.right;
+ int cx = clnt.right - _border_left;
+ if (text_width > cx)
+ rect.right += text_width-cx;
MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
- StartMenuCtrl(_hwnd, rect.bottom-rect.top-STARTMENU_LINE_HEIGHT-6, title, id, hIcon, hasSubmenu, style);
+ StartMenuCtrl(_hwnd, _border_left, rect.bottom-rect.top-STARTMENU_LINE_HEIGHT-6, rect.right-rect.left-_border_left,
+ title, id, hIcon, hasSubmenu, style);
}
void StartMenu::AddSeparator()
MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
- StartMenuSeparator(_hwnd, rect.bottom-rect.top-STARTMENU_SEP_HEIGHT-6);
+ StartMenuSeparator(_hwnd, _border_left, rect.bottom-rect.top-STARTMENU_SEP_HEIGHT-6, rect.right-rect.left-_border_left);
}
// insert directory "<user name>\Start Menu"
ShellDirectory usr_startmenu(Desktop(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd);
_dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // don't add subfolders
+
+ // read size of logo bitmap
+ BITMAP bmp_hdr;
+ GetObject(ResBitmap(IDB_LOGOV), sizeof(BITMAP), &bmp_hdr);
+ _logo_size.cx = bmp_hdr.bmWidth;
+ _logo_size.cy = bmp_hdr.bmHeight;
+
+ _border_left = _logo_size.cx;
}
}
+LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
+{
+ switch(nmsg) {
+ case WM_PAINT: {
+ PaintCanvas canvas(_hwnd);
+ MemCanvas mem_dc;
+ ResBitmap bmp(IDB_LOGOV);
+ BitmapSelection sel(mem_dc, bmp);
+
+ ClientRect clnt(_hwnd);
+ int h = min(_logo_size.cy, clnt.bottom);
+
+ RECT rect = {0, 0, _logo_size.cx-1, clnt.bottom-h};
+ HBRUSH hbr = CreateSolidBrush(RGB(166,202,240)); // same color as the background color in the logo bitmap
+ FillRect(canvas, &rect, hbr);
+ PatBlt(canvas, _logo_size.cx-1, 0, 1, clnt.bottom-h, WHITENESS);
+ DeleteObject(hbr);
+
+ BitBlt(canvas, 0, clnt.bottom-h, _logo_size.cx, h, mem_dc, 0, 0, SRCCOPY);
+ break;}
+
+ default:
+ return super::WndProc(nmsg, wparam, lparam);
+ }
+
+ return 0;
+}
+
+
int StartMenuRoot::Command(int id, int code)
{
switch(id) {
*/
struct StartMenuCtrl : public Button
{
- StartMenuCtrl(HWND parent, int y, LPCTSTR title,
+ StartMenuCtrl(HWND parent, int x, int y, int w, LPCTSTR title,
UINT id, HICON hIcon=0, bool hasSubmenu=false, DWORD style=WS_VISIBLE|WS_CHILD|BS_OWNERDRAW, DWORD exStyle=0)
- : Button(parent, title, 0, y, ClientRect(parent).right, STARTMENU_LINE_HEIGHT, id, style, exStyle)
+ : Button(parent, title, x, y, w, STARTMENU_LINE_HEIGHT, id, style, exStyle)
{
*new StartMenuButton(_hwnd, hIcon, hasSubmenu);
struct StartMenuSeparator : public Static
{
- StartMenuSeparator(HWND parent, int y, DWORD style=WS_VISIBLE|WS_CHILD|WS_DISABLED|SS_ETCHEDHORZ, DWORD exStyle=0)
- : Static(parent, NULL, 0, y+STARTMENU_SEP_HEIGHT/2-1, ClientRect(parent).right, 2, -1, style, exStyle)
+ StartMenuSeparator(HWND parent, int x, int y, int w, DWORD style=WS_VISIBLE|WS_CHILD|WS_DISABLED|SS_ETCHEDHORZ, DWORD exStyle=0)
+ : Static(parent, NULL, x, y+STARTMENU_SEP_HEIGHT/2-1, w, 2, -1, style, exStyle)
{
}
};
UINT _submenu_id;
WindowHandle _submenu;
+ int _border_left; // left border in pixels
+
// member functions
void ResizeButtons(int cx);
protected:
LRESULT Init(LPCREATESTRUCT pcs);
+ LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
int Command(int id, int code);
void ShowLaunchDialog(HWND hwndDesktopBar);
+
+ SIZE _logo_size;
};
{
HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, 16, 16);
- HDC hdc = CreateCompatibleDC(0);
- HBITMAP hbmp_org = SelectBitmap(hdc, hbmp);
+ MemCanvas canvas;
+ BitmapSelection sel(canvas, hbmp);
RECT rect = {0, 0, 16, 16};
- FillRect(hdc, &rect, hbrush_bkgnd);
+ FillRect(canvas, &rect, hbrush_bkgnd);
- DrawIconEx(hdc, 0, 0, hIcon, 16, 16, 0, hbrush_bkgnd, DI_NORMAL);
-
- SelectBitmap(hdc, hbmp_org);
- DeleteDC(hdc);
+ DrawIconEx(canvas, 0, 0, hIcon, 16, 16, 0, hbrush_bkgnd, DI_NORMAL);
return hbmp;
}
HFONT _old_hFont;
};
+struct BitmapSelection
+{
+ BitmapSelection(HDC hdc, HBITMAP hBmp)
+ : _hdc(hdc), _old_hBmp(SelectBitmap(hdc, hBmp)) {}
+
+ ~BitmapSelection() {SelectBitmap(_hdc, _old_hBmp);}
+
+protected:
+ HDC _hdc;
+ HBITMAP _old_hBmp;
+};
+
struct String
#ifdef UNICODE