mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
dynamic startmenu widths
svn path=/trunk/; revision=5707
This commit is contained in:
parent
3d0daebcc4
commit
e4b7ecbc70
8 changed files with 242 additions and 87 deletions
|
@ -277,16 +277,16 @@ void FileChildWindow::resize_children(int cx, int cy)
|
|||
|
||||
Header_Layout(_left->_hwndHeader, &hdl);
|
||||
|
||||
DeferWindowPos(hdwp, _left->_hwndHeader, wp.hwndInsertAfter,
|
||||
wp.x-1, wp.y, _split_pos-SPLIT_WIDTH/2+1, wp.cy, wp.flags);
|
||||
hdwp = DeferWindowPos(hdwp, _left->_hwndHeader, wp.hwndInsertAfter,
|
||||
wp.x-1, wp.y, _split_pos-SPLIT_WIDTH/2+1, wp.cy, wp.flags);
|
||||
|
||||
DeferWindowPos(hdwp, _right->_hwndHeader, wp.hwndInsertAfter,
|
||||
rt.left+cx+1, wp.y, wp.cx-cx+2, wp.cy, wp.flags);
|
||||
hdwp = DeferWindowPos(hdwp, _right->_hwndHeader, wp.hwndInsertAfter,
|
||||
rt.left+cx+1, wp.y, wp.cx-cx+2, wp.cy, wp.flags);
|
||||
}
|
||||
|
||||
DeferWindowPos(hdwp, _left_hwnd, 0, rt.left, rt.top, _split_pos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
hdwp = DeferWindowPos(hdwp, _left_hwnd, 0, rt.left, rt.top, _split_pos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
|
||||
DeferWindowPos(hdwp, _right_hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
hdwp = DeferWindowPos(hdwp, _right_hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
|
||||
EndDeferWindowPos(hdwp);
|
||||
}
|
||||
|
|
|
@ -61,10 +61,7 @@ StartMenu::StartMenu(HWND hwnd, const StartMenuFolders& info)
|
|||
|
||||
StartMenu::~StartMenu()
|
||||
{
|
||||
HWND parent = GetParent(_hwnd);
|
||||
|
||||
if (parent)
|
||||
SendMessage(parent, WM_STARTMENU_CLOSED, 0, 0);
|
||||
SendParent(WM_STARTMENU_CLOSED);
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +69,7 @@ StartMenu::~StartMenu()
|
|||
HWND StartMenu::Create(int x, int y, HWND hwndParent)
|
||||
{
|
||||
return Window::Create(WINDOW_CREATOR(StartMenu), NULL, s_wcStartMenu, TITLE_STARTMENU,
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH, 4, hwndParent);
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH_MIN, 4, hwndParent);
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -81,7 +78,7 @@ Window::CREATORFUNC StartMenu::s_def_creator = STARTMENU_CREATOR(StartMenu);
|
|||
HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, CREATORFUNC creator)
|
||||
{
|
||||
return Window::Create(creator, &folders, 0, s_wcStartMenu, NULL,
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH, 4, hwndParent);
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH_MIN, 4/*start height*/, hwndParent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,6 +150,10 @@ void StartMenu::AddShellEntries(const ShellDirectory& dir, int max, bool subfold
|
|||
LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
case WM_SIZE:
|
||||
ResizeButtons(LOWORD(lparam));
|
||||
break;
|
||||
|
||||
case WM_NCHITTEST: {
|
||||
LRESULT res = super::WndProc(nmsg, wparam, lparam);
|
||||
|
||||
|
@ -166,6 +167,27 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
return 0; // disable window resizing
|
||||
goto def;
|
||||
|
||||
case WM_STARTENTRY_FOCUSED: {
|
||||
BOOL hasSubmenu = wparam;
|
||||
HWND hctrl = (HWND)lparam;
|
||||
|
||||
// automatically open submenus
|
||||
if (hasSubmenu) {
|
||||
UpdateWindow(_hwnd); // draw focused button before waiting on submenu creation
|
||||
//SendMessage(_hwnd, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hctrl),BN_CLICKED), (LPARAM)hctrl);
|
||||
Command(GetDlgCtrlID(hctrl), BN_CLICKED);
|
||||
} else {
|
||||
// close any open submenu
|
||||
CloseOtherSubmenus(0);
|
||||
}
|
||||
break;}
|
||||
|
||||
case WM_STARTENTRY_LAUNCHED:
|
||||
// route message to the parent menu and close menus after launching an entry
|
||||
if (!SendParent(nmsg, wparam, lparam))
|
||||
DestroyWindow(_hwnd);
|
||||
return 1; // signal that we have received and processed the message
|
||||
|
||||
case WM_STARTMENU_CLOSED:
|
||||
_submenu = 0;
|
||||
break;
|
||||
|
@ -178,6 +200,29 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
}
|
||||
|
||||
|
||||
// resize child button controls to accomodate for new window size
|
||||
void StartMenu::ResizeButtons(int cx)
|
||||
{
|
||||
HDWP hdwp = BeginDeferWindowPos(10);
|
||||
|
||||
for(HWND ctrl=GetWindow(_hwnd,GW_CHILD); ctrl; ctrl=GetNextWindow(ctrl,GW_HWNDNEXT)) {
|
||||
ClientRect rt(ctrl);
|
||||
|
||||
if (rt.right != cx) {
|
||||
int height = rt.bottom - rt.top;
|
||||
|
||||
// special handling for separator controls
|
||||
if (!height && (GetWindowStyle(ctrl)&SS_TYPEMASK)==SS_ETCHEDHORZ)
|
||||
height = 2;
|
||||
|
||||
hdwp = DeferWindowPos(hdwp, ctrl, 0, 0, 0, cx, height, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
EndDeferWindowPos(hdwp);
|
||||
}
|
||||
|
||||
|
||||
int StartMenu::Command(int id, int code)
|
||||
{
|
||||
switch(id) {
|
||||
|
@ -237,6 +282,7 @@ void StartMenu::AddButton(LPCTSTR title, HICON hIcon, bool hasSubmenu, UINT id,
|
|||
{
|
||||
WindowRect rect(_hwnd);
|
||||
|
||||
// increase window height to make room for the new button
|
||||
rect.top -= STARTMENU_LINE_HEIGHT;
|
||||
|
||||
if (rect.top < 0) {
|
||||
|
@ -244,9 +290,16 @@ void StartMenu::AddButton(LPCTSTR title, HICON hIcon, bool hasSubmenu, UINT id,
|
|||
rect.bottom += STARTMENU_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
// widen window, if it is too small
|
||||
int width = StartMenuButton::GetTextWidth(title) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/;
|
||||
|
||||
ClientRect clnt(_hwnd);
|
||||
if (width > clnt.right)
|
||||
rect.right += width-clnt.right;
|
||||
|
||||
MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
|
||||
|
||||
StartMenuCtrl(_hwnd, rect.bottom-rect.top-STARTMENU_LINE_HEIGHT-4, title, id, hIcon, hasSubmenu, style);
|
||||
StartMenuCtrl(_hwnd, rect.bottom-rect.top-STARTMENU_LINE_HEIGHT-6, title, id, hIcon, hasSubmenu, style);
|
||||
}
|
||||
|
||||
void StartMenu::AddSeparator()
|
||||
|
@ -262,7 +315,7 @@ 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-4);
|
||||
StartMenuSeparator(_hwnd, rect.bottom-rect.top-STARTMENU_SEP_HEIGHT-6);
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,7 +348,7 @@ void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, CREAT
|
|||
WindowRect pos(btn);
|
||||
|
||||
x = pos.right-3; // Submenus should overlap their parent a bit.
|
||||
y = pos.top;
|
||||
y = pos.top+STARTMENU_LINE_HEIGHT-3;
|
||||
} else {
|
||||
WindowRect pos(_hwnd);
|
||||
|
||||
|
@ -351,26 +404,49 @@ void StartMenu::ActivateEntry(int id, ShellEntry* entry)
|
|||
CreateSubmenu(id, new_folders);
|
||||
} else {
|
||||
entry->launch_entry(_hwnd); //TODO: launch in the background
|
||||
|
||||
CloseStartMenu(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StartMenu::CloseStartMenu(int id)
|
||||
{
|
||||
// close start menus after launching the selected entry
|
||||
if (!SendParent(WM_STARTENTRY_LAUNCHED, id, (LPARAM)_hwnd))
|
||||
DestroyWindow(_hwnd);
|
||||
}
|
||||
|
||||
|
||||
int StartMenuButton::GetTextWidth(LPCTSTR title)
|
||||
{
|
||||
RECT rect = {0, 0, 0, 0};
|
||||
|
||||
HDC hdc = GetDC(0);
|
||||
SelectedFont font(hdc, GetStockFont(DEFAULT_GUI_FONT));
|
||||
|
||||
DrawText(hdc, title, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
|
||||
|
||||
ReleaseDC(0, hdc);
|
||||
|
||||
return rect.right-rect.left;
|
||||
}
|
||||
|
||||
|
||||
LRESULT StartMenuButton::WndProc(UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(message) {
|
||||
case WM_MOUSEMOVE:
|
||||
// automatically set the focus to startmenu entries when moving the mouse over them
|
||||
if (GetFocus()!=_hwnd && !(GetWindowStyle(_hwnd)&WS_DISABLED)) {
|
||||
if (GetFocus()!=_hwnd && !(GetWindowStyle(_hwnd)&WS_DISABLED))
|
||||
SetFocus(_hwnd);
|
||||
UpdateWindow(GetParent(_hwnd)); // draw focused button before waiting on submenu creation
|
||||
|
||||
// automatically open submenus
|
||||
if (_hasSubmenu)
|
||||
SendMessage(GetParent(_hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(_hwnd),BN_CLICKED), (LPARAM)_hwnd);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case WM_SETFOCUS:
|
||||
PostParent(WM_STARTENTRY_FOCUSED, _hasSubmenu, (LPARAM)_hwnd);
|
||||
goto def;
|
||||
|
||||
default: def:
|
||||
return super::WndProc(message, wparam, lparam);
|
||||
}
|
||||
|
||||
|
@ -416,15 +492,15 @@ void StartMenuButton::DrawItem(LPDRAWITEMSTRUCT dis)
|
|||
dis->itemState&ODS_FOCUS?selArrowIcon:arrowIcon, 16, 16, 0, bk_brush, DI_NORMAL);
|
||||
}
|
||||
|
||||
TCHAR text[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, text, BUFFER_LEN);
|
||||
TCHAR title[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, title, BUFFER_LEN);
|
||||
|
||||
if (dis->itemState & (ODS_DISABLED|ODS_GRAYED))
|
||||
DrawGrayText(dis, &textRect, text, DT_SINGLELINE|DT_NOPREFIX|DT_VCENTER);
|
||||
DrawGrayText(dis, &textRect, title, DT_SINGLELINE|DT_NOPREFIX|DT_VCENTER);
|
||||
else {
|
||||
BkMode mode(dis->hDC, TRANSPARENT);
|
||||
TextColor lcColor(dis->hDC, GetSysColor(text_color));
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_NOPREFIX|DT_VCENTER);
|
||||
DrawText(dis->hDC, title, -1, &textRect, DT_SINGLELINE|DT_NOPREFIX|DT_VCENTER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,10 +517,12 @@ StartMenuRoot::StartMenuRoot(HWND hwnd)
|
|||
_dirs.push_back(StartMenuDirectory(usr_startmenu, false)); // dont't add subfolders
|
||||
}
|
||||
|
||||
HWND StartMenuRoot::Create(int x, int y, HWND hwndParent)
|
||||
HWND StartMenuRoot::Create(HWND hwndDesktopBar)
|
||||
{
|
||||
WindowRect pos(hwndDesktopBar);
|
||||
|
||||
return Window::Create(WINDOW_CREATOR(StartMenuRoot), 0, s_wcStartMenu, TITLE_STARTMENU,
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, x, y, STARTMENU_WIDTH, 4, hwndParent);
|
||||
WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, pos.left, pos.top-4, STARTMENU_WIDTH_MIN, 4, hwndDesktopBar);
|
||||
}
|
||||
|
||||
LRESULT StartMenuRoot::Init(LPCREATESTRUCT pcs)
|
||||
|
@ -487,6 +565,7 @@ int StartMenuRoot::Command(int id, int code)
|
|||
|
||||
case IDC_EXPLORE:
|
||||
explorer_show_frame(_hwnd, SW_SHOWNORMAL);
|
||||
CloseStartMenu(id);
|
||||
break;
|
||||
|
||||
case IDC_DOCUMENTS:
|
||||
|
|
|
@ -33,12 +33,14 @@
|
|||
#define TITLE_STARTMENU _T("Start Menu")
|
||||
|
||||
|
||||
#define STARTMENU_WIDTH 150
|
||||
#define STARTMENU_WIDTH_MIN 120
|
||||
#define STARTMENU_LINE_HEIGHT 22
|
||||
#define STARTMENU_SEP_HEIGHT (STARTMENU_LINE_HEIGHT/2)
|
||||
|
||||
|
||||
#define WM_STARTMENU_CLOSED (WM_APP+0x11)
|
||||
#define WM_STARTENTRY_FOCUSED (WM_APP+0x12)
|
||||
#define WM_STARTENTRY_LAUNCHED (WM_APP+0x13)
|
||||
|
||||
|
||||
struct StartMenuDirectory
|
||||
|
@ -72,6 +74,8 @@ struct StartMenuButton : public OwnerdrawnButton
|
|||
StartMenuButton(HWND hwnd, HICON hIcon, bool hasSubmenu)
|
||||
: super(hwnd), _hIcon(hIcon), _hasSubmenu(hasSubmenu) {}
|
||||
|
||||
static int GetTextWidth(LPCTSTR title);
|
||||
|
||||
protected:
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
virtual void DrawItem(LPDRAWITEMSTRUCT dis);
|
||||
|
@ -141,6 +145,8 @@ protected:
|
|||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
int Command(int id, int code);
|
||||
|
||||
void ResizeButtons(int cx);
|
||||
|
||||
virtual void AddEntries();
|
||||
|
||||
StartMenuEntry& AddEntry(LPCTSTR title, HICON hIcon=0, UINT id=(UINT)-1);
|
||||
|
@ -156,6 +162,7 @@ protected:
|
|||
void CreateSubmenu(int id, int folder1, int folder2, CREATORFUNC creator=s_def_creator);
|
||||
void CreateSubmenu(int id, int folder, CREATORFUNC creator=s_def_creator);
|
||||
void ActivateEntry(int id, ShellEntry* entry);
|
||||
void CloseStartMenu(int id=0);
|
||||
};
|
||||
|
||||
|
||||
|
@ -166,7 +173,7 @@ struct StartMenuRoot : public StartMenu
|
|||
|
||||
StartMenuRoot(HWND hwnd);
|
||||
|
||||
static HWND Create(int x, int y, HWND hwndParent=0);
|
||||
static HWND Create(HWND hwndDesktopBar);
|
||||
|
||||
protected:
|
||||
LRESULT Init(LPCREATESTRUCT pcs);
|
||||
|
|
|
@ -60,8 +60,6 @@ HWND InitializeExplorerBar(HINSTANCE hInstance)
|
|||
DesktopBar::DesktopBar(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
_hwndTaskBar = 0;
|
||||
_startMenuRoot = 0;
|
||||
}
|
||||
|
||||
DesktopBar::~DesktopBar()
|
||||
|
@ -89,10 +87,33 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
|
|||
|
||||
taskbar->_desktop_bar = this;
|
||||
|
||||
RegisterHotkeys();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DesktopBar::RegisterHotkeys()
|
||||
{
|
||||
// register hotkey CTRL+ESC for opening Startmenu
|
||||
RegisterHotKey(_hwnd, 0, MOD_CONTROL, VK_ESCAPE);
|
||||
|
||||
// register hotkey WIN+E opening explorer
|
||||
RegisterHotKey(_hwnd, 1, MOD_WIN, 'E');
|
||||
|
||||
//TODO: register all common hotkeys
|
||||
}
|
||||
|
||||
void DesktopBar::ProcessHotKey(int id_hotkey)
|
||||
{
|
||||
switch(id_hotkey) {
|
||||
case 0: ToggleStartmenu(); break;
|
||||
case 1: explorer_show_frame(_hwnd, SW_SHOWNORMAL); break;
|
||||
//TODO: implement all common hotkeys
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
|
@ -136,6 +157,10 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
_startMenuRoot = 0;
|
||||
break;
|
||||
|
||||
case WM_HOTKEY:
|
||||
ProcessHotKey(wparam);
|
||||
break;
|
||||
|
||||
default: def:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
@ -148,16 +173,7 @@ int DesktopBar::Command(int id, int code)
|
|||
{
|
||||
switch(id) {
|
||||
case IDC_START:
|
||||
if (_startMenuRoot && IsWindow(_startMenuRoot)) { // IsWindow(): safety first
|
||||
// dispose Startmenu
|
||||
DestroyWindow(_startMenuRoot);
|
||||
_startMenuRoot = 0;
|
||||
} else {
|
||||
// create Startmenu
|
||||
WindowRect my_pos(_hwnd);
|
||||
|
||||
_startMenuRoot = StartMenuRoot::Create(my_pos.left, my_pos.top-4, _hwnd);
|
||||
}
|
||||
ToggleStartmenu();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -165,6 +181,19 @@ int DesktopBar::Command(int id, int code)
|
|||
}
|
||||
|
||||
|
||||
void DesktopBar::ToggleStartmenu()
|
||||
{
|
||||
if (_startMenuRoot && IsWindow(_startMenuRoot)) { // IsWindow(): safety first
|
||||
// dispose Startmenu
|
||||
DestroyWindow(_startMenuRoot);
|
||||
_startMenuRoot = 0;
|
||||
} else {
|
||||
// create Startmenu
|
||||
_startMenuRoot = StartMenuRoot::Create(_hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static HICON get_window_icon(HWND hwnd)
|
||||
{
|
||||
HICON hIcon = 0;
|
||||
|
|
|
@ -77,6 +77,10 @@ protected:
|
|||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
int Command(int id, int code);
|
||||
|
||||
void RegisterHotkeys();
|
||||
void ProcessHotKey(int id_hotkey);
|
||||
void ToggleStartmenu();
|
||||
|
||||
WindowHandle _hwndTaskBar;
|
||||
WindowHandle _startMenuRoot;
|
||||
};
|
||||
|
|
|
@ -134,7 +134,6 @@ protected:
|
|||
COLORREF _old_color;
|
||||
};
|
||||
|
||||
|
||||
struct BkMode
|
||||
{
|
||||
BkMode(HDC hdc, int bkmode)
|
||||
|
@ -147,6 +146,18 @@ protected:
|
|||
COLORREF _old_bkmode;
|
||||
};
|
||||
|
||||
struct SelectedFont
|
||||
{
|
||||
SelectedFont(HDC hdc, HFONT hFont)
|
||||
: _hdc(hdc), _old_hFont(SelectFont(hdc, hFont)) {}
|
||||
|
||||
~SelectedFont() {SelectFont(_hdc, _old_hFont);}
|
||||
|
||||
protected:
|
||||
HDC _hdc;
|
||||
HFONT _old_hFont;
|
||||
};
|
||||
|
||||
|
||||
struct FullScreenParameters {
|
||||
FullScreenParameters()
|
||||
|
|
|
@ -356,9 +356,9 @@ void ChildWindow::resize_children(int cx, int cy)
|
|||
|
||||
cx = _split_pos + SPLIT_WIDTH/2;
|
||||
|
||||
DeferWindowPos(hdwp, _left_hwnd, 0, rt.left, rt.top, _split_pos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
hdwp = DeferWindowPos(hdwp, _left_hwnd, 0, rt.left, rt.top, _split_pos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
|
||||
DeferWindowPos(hdwp, _right_hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
hdwp = DeferWindowPos(hdwp, _right_hwnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
|
||||
EndDeferWindowPos(hdwp);
|
||||
}
|
||||
|
@ -408,30 +408,6 @@ BOOL Window::dispatch_dialog_msg(MSG* pmsg)
|
|||
}
|
||||
|
||||
|
||||
PreTranslateWindow::PreTranslateWindow(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
register_pretranslate(hwnd);
|
||||
}
|
||||
|
||||
PreTranslateWindow::~PreTranslateWindow()
|
||||
{
|
||||
unregister_pretranslate(_hwnd);
|
||||
}
|
||||
|
||||
|
||||
Dialog::Dialog(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
register_dialog(hwnd);
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
unregister_dialog(_hwnd);
|
||||
}
|
||||
|
||||
|
||||
int Window::MessageLoop()
|
||||
{
|
||||
MSG msg;
|
||||
|
@ -460,9 +436,54 @@ int Window::MessageLoop()
|
|||
}
|
||||
|
||||
|
||||
Button::Button(HWND parent, LPCTSTR text, int left, int top, int width, int height,
|
||||
LRESULT Window::SendParent(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
HWND parent = GetParent(_hwnd);
|
||||
|
||||
if (!parent)
|
||||
return 0;
|
||||
|
||||
return SendMessage(parent, nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
LRESULT Window::PostParent(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
HWND parent = GetParent(_hwnd);
|
||||
|
||||
if (!parent)
|
||||
return 0;
|
||||
|
||||
return PostMessage(parent, nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
|
||||
PreTranslateWindow::PreTranslateWindow(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
register_pretranslate(hwnd);
|
||||
}
|
||||
|
||||
PreTranslateWindow::~PreTranslateWindow()
|
||||
{
|
||||
unregister_pretranslate(_hwnd);
|
||||
}
|
||||
|
||||
|
||||
Dialog::Dialog(HWND hwnd)
|
||||
: super(hwnd)
|
||||
{
|
||||
register_dialog(hwnd);
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
unregister_dialog(_hwnd);
|
||||
}
|
||||
|
||||
|
||||
Button::Button(HWND parent, LPCTSTR title, int left, int top, int width, int height,
|
||||
int id, DWORD flags, DWORD exStyle)
|
||||
: WindowHandle(CreateWindowEx(exStyle, TEXT("BUTTON"), text, flags, left, top, width, height,
|
||||
: WindowHandle(CreateWindowEx(exStyle, TEXT("BUTTON"), title, flags, left, top, width, height,
|
||||
parent, (HMENU)id, g_Globals._hInstance, 0))
|
||||
{
|
||||
}
|
||||
|
@ -478,9 +499,9 @@ LRESULT OwnerdrawnButton::WndProc(UINT message, WPARAM wparam, LPARAM lparam)
|
|||
}
|
||||
|
||||
|
||||
Static::Static(HWND parent, LPCTSTR text, int left, int top, int width, int height,
|
||||
Static::Static(HWND parent, LPCTSTR title, int left, int top, int width, int height,
|
||||
int id, DWORD flags, DWORD exStyle)
|
||||
: WindowHandle(CreateWindowEx(exStyle, TEXT("STATIC"), text, flags, left, top, width, height,
|
||||
: WindowHandle(CreateWindowEx(exStyle, TEXT("STATIC"), title, flags, left, top, width, height,
|
||||
parent, (HMENU)id, g_Globals._hInstance, 0))
|
||||
{
|
||||
}
|
||||
|
@ -494,23 +515,23 @@ static BOOL CALLBACK MyDrawText(HDC hdc, LPARAM data, int cnt)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void OwnerdrawnButton::DrawGrayText(LPDRAWITEMSTRUCT dis, LPRECT pRect, LPCTSTR text, int dt_flags)
|
||||
void OwnerdrawnButton::DrawGrayText(LPDRAWITEMSTRUCT dis, LPRECT pRect, LPCTSTR title, int dt_flags)
|
||||
{
|
||||
COLORREF gray = GetSysColor(COLOR_GRAYTEXT);
|
||||
|
||||
if (gray) {
|
||||
TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNHIGHLIGHT));
|
||||
RECT shadowRect = {pRect->left+1, pRect->top+1, pRect->right+1, pRect->bottom+1};
|
||||
DrawText(dis->hDC, text, -1, &shadowRect, dt_flags);
|
||||
DrawText(dis->hDC, title, -1, &shadowRect, dt_flags);
|
||||
|
||||
BkMode mode(dis->hDC, TRANSPARENT);
|
||||
SetTextColor(dis->hDC, gray);
|
||||
DrawText(dis->hDC, text, -1, pRect, dt_flags);
|
||||
DrawText(dis->hDC, title, -1, pRect, dt_flags);
|
||||
} else {
|
||||
int old_r = pRect->right;
|
||||
int old_b = pRect->bottom;
|
||||
|
||||
DrawText(dis->hDC, text, -1, pRect, dt_flags|DT_CALCRECT);
|
||||
DrawText(dis->hDC, title, -1, pRect, dt_flags|DT_CALCRECT);
|
||||
|
||||
int x = pRect->left + (old_r-pRect->right)/2;
|
||||
int y = pRect->top + (old_b-pRect->bottom)/2;
|
||||
|
@ -519,7 +540,7 @@ void OwnerdrawnButton::DrawGrayText(LPDRAWITEMSTRUCT dis, LPRECT pRect, LPCTSTR
|
|||
s_MyDrawText_Rect.right = w;
|
||||
s_MyDrawText_Rect.bottom = h;
|
||||
|
||||
GrayString(dis->hDC, GetSysColorBrush(COLOR_GRAYTEXT), MyDrawText, (LPARAM)text, -1, x, y, w, h);
|
||||
GrayString(dis->hDC, GetSysColorBrush(COLOR_GRAYTEXT), MyDrawText, (LPARAM)title, -1, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,14 +563,14 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT dis)
|
|||
|
||||
DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, style);
|
||||
|
||||
TCHAR text[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, text, BUFFER_LEN);
|
||||
TCHAR title[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, title, BUFFER_LEN);
|
||||
|
||||
if (dis->itemState & (ODS_DISABLED|ODS_GRAYED))
|
||||
DrawGrayText(dis, &textRect, text, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
DrawGrayText(dis, &textRect, title, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
else {
|
||||
TextColor lcColor(dis->hDC, _textColor);
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
DrawText(dis->hDC, title, -1, &textRect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
|
||||
}
|
||||
|
||||
if (dis->itemState & ODS_FOCUS) {
|
||||
|
@ -592,15 +613,15 @@ void PictureButton::DrawItem(LPDRAWITEMSTRUCT dis)
|
|||
|
||||
DrawIconEx(dis->hDC, iconPos.x, iconPos.y, _hIcon, 16, 16, 0, GetSysColorBrush(COLOR_BTNFACE), DI_NORMAL);
|
||||
|
||||
TCHAR text[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, text, BUFFER_LEN);
|
||||
TCHAR title[BUFFER_LEN];
|
||||
GetWindowText(_hwnd, title, BUFFER_LEN);
|
||||
|
||||
if (dis->itemState & (ODS_DISABLED|ODS_GRAYED))
|
||||
DrawGrayText(dis, &textRect, text, DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/);
|
||||
DrawGrayText(dis, &textRect, title, DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/);
|
||||
else {
|
||||
//BkMode mode(dis->hDC, TRANSPARENT);
|
||||
TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNTEXT));
|
||||
DrawText(dis->hDC, text, -1, &textRect, DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/);
|
||||
DrawText(dis->hDC, title, -1, &textRect, DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/);
|
||||
}
|
||||
|
||||
if (dis->itemState & ODS_FOCUS) {
|
||||
|
|
|
@ -107,6 +107,10 @@ struct Window : public WindowHandle
|
|||
static int MessageLoop();
|
||||
|
||||
|
||||
LRESULT SendParent(UINT nmsg, WPARAM wparam=0, LPARAM lparam=0);
|
||||
LRESULT PostParent(UINT nmsg, WPARAM wparam=0, LPARAM lparam=0);
|
||||
|
||||
|
||||
protected:
|
||||
virtual LRESULT Init(LPCREATESTRUCT pcs); // WM_CREATE processing
|
||||
virtual LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
|
Loading…
Reference in a new issue