2007-01-03 07:23:51 +01:00
|
|
|
/* Unit test suite for status control.
|
|
|
|
*
|
|
|
|
* Copyright 2007 Google (Lei Zhang)
|
2007-02-26 05:43:26 +01:00
|
|
|
* Copyright 2007 Alex Arazi
|
2007-01-03 07:23:51 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2008-07-16 20:21:09 +02:00
|
|
|
#define SUBCLASS_NAME "MyStatusBar"
|
|
|
|
|
2022-02-28 08:25:25 +01:00
|
|
|
#define expect(expected,got) expect_(__LINE__, expected, got)
|
|
|
|
static inline void expect_(unsigned line, DWORD expected, DWORD got)
|
|
|
|
{
|
|
|
|
ok_(__FILE__, line)(expected == got, "Expected %ld, got %ld\n", expected, got);
|
|
|
|
}
|
|
|
|
|
2008-09-08 07:46:53 +02:00
|
|
|
#define expect_rect(_left,_top,_right,_bottom,got) do { \
|
|
|
|
RECT exp = {abs(got.left - _left), abs(got.top - _top), \
|
|
|
|
abs(got.right - _right), abs(got.bottom - _bottom)}; \
|
|
|
|
ok(exp.left <= 2 && exp.top <= 2 && exp.right <= 2 && exp.bottom <= 2, \
|
2016-06-08 12:28:46 +02:00
|
|
|
"Expected rect (%d,%d)-(%d,%d), got %s\n", _left, _top, _right, _bottom, \
|
|
|
|
wine_dbgstr_rect(&(got))); } while (0)
|
2007-02-26 05:43:26 +01:00
|
|
|
|
2007-01-03 07:23:51 +01:00
|
|
|
static HINSTANCE hinst;
|
2008-07-16 15:25:43 +02:00
|
|
|
static WNDPROC g_status_wndproc;
|
|
|
|
static RECT g_rcCreated;
|
|
|
|
static HWND g_hMainWnd;
|
2008-07-16 20:21:09 +02:00
|
|
|
static int g_wmsize_count = 0;
|
2011-06-01 15:50:26 +02:00
|
|
|
static INT g_ysize;
|
|
|
|
static INT g_dpisize;
|
2009-02-15 14:27:55 +01:00
|
|
|
static int g_wmdrawitm_ctr;
|
|
|
|
static WNDPROC g_wndproc_saved;
|
2007-01-03 07:23:51 +01:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
|
|
|
|
|
2007-01-03 07:23:51 +01:00
|
|
|
static HWND create_status_control(DWORD style, DWORD exstyle)
|
|
|
|
{
|
|
|
|
HWND hWndStatus;
|
|
|
|
|
|
|
|
/* make the control */
|
2013-10-19 20:30:47 +02:00
|
|
|
hWndStatus = CreateWindowExA(exstyle, STATUSCLASSNAMEA, NULL, style,
|
2007-01-03 07:23:51 +01:00
|
|
|
/* placement */
|
|
|
|
0, 0, 300, 20,
|
|
|
|
/* parent, etc */
|
|
|
|
NULL, NULL, hinst, NULL);
|
2014-02-13 09:31:48 +01:00
|
|
|
ok(hWndStatus != NULL, "failed to create status wnd\n");
|
2007-01-03 07:23:51 +01:00
|
|
|
return hWndStatus;
|
|
|
|
}
|
|
|
|
|
2008-07-16 15:25:43 +02:00
|
|
|
static LRESULT WINAPI create_test_wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2008-07-16 20:21:09 +02:00
|
|
|
LRESULT ret;
|
|
|
|
|
2008-07-16 15:25:43 +02:00
|
|
|
if (msg == WM_CREATE)
|
|
|
|
{
|
2013-10-19 20:30:47 +02:00
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
|
|
|
|
ret = CallWindowProcA(g_status_wndproc, hwnd, msg, wParam, lParam);
|
2008-07-16 15:25:43 +02:00
|
|
|
GetWindowRect(hwnd, &g_rcCreated);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, g_hMainWnd, (LPPOINT)&g_rcCreated, 2);
|
|
|
|
ok(cs->x == g_rcCreated.left, "CREATESTRUCT.x modified\n");
|
|
|
|
ok(cs->y == g_rcCreated.top, "CREATESTRUCT.y modified\n");
|
2008-07-16 20:21:09 +02:00
|
|
|
} else if (msg == WM_SIZE)
|
|
|
|
{
|
|
|
|
g_wmsize_count++;
|
2013-10-19 20:30:47 +02:00
|
|
|
ret = CallWindowProcA(g_status_wndproc, hwnd, msg, wParam, lParam);
|
2008-07-16 15:25:43 +02:00
|
|
|
}
|
2008-07-16 20:21:09 +02:00
|
|
|
else
|
2013-10-19 20:30:47 +02:00
|
|
|
ret = CallWindowProcA(g_status_wndproc, hwnd, msg, wParam, lParam);
|
2008-07-16 20:21:09 +02:00
|
|
|
|
|
|
|
return ret;
|
2008-07-16 15:25:43 +02:00
|
|
|
}
|
|
|
|
|
2009-01-25 23:27:18 +01:00
|
|
|
static void register_subclass(void)
|
2008-07-16 15:25:43 +02:00
|
|
|
{
|
2013-10-19 20:30:47 +02:00
|
|
|
WNDCLASSEXA cls;
|
2008-07-16 15:25:43 +02:00
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
cls.cbSize = sizeof(WNDCLASSEXA);
|
|
|
|
GetClassInfoExA(NULL, STATUSCLASSNAMEA, &cls);
|
2008-07-16 15:25:43 +02:00
|
|
|
g_status_wndproc = cls.lpfnWndProc;
|
|
|
|
cls.lpfnWndProc = create_test_wndproc;
|
2008-07-16 20:21:09 +02:00
|
|
|
cls.lpszClassName = SUBCLASS_NAME;
|
2008-07-16 15:25:43 +02:00
|
|
|
cls.hInstance = NULL;
|
2013-10-19 20:30:47 +02:00
|
|
|
ok(RegisterClassExA(&cls), "RegisterClassEx failed\n");
|
2008-07-16 20:21:09 +02:00
|
|
|
}
|
2008-07-16 15:25:43 +02:00
|
|
|
|
2009-01-25 23:27:18 +01:00
|
|
|
static void test_create(void)
|
2008-07-16 20:21:09 +02:00
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
ok((hwnd = CreateWindowA(SUBCLASS_NAME, "", WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, 0, 0, 100, 100,
|
2008-07-16 15:25:43 +02:00
|
|
|
g_hMainWnd, NULL, NULL, 0)) != NULL, "CreateWindowA failed\n");
|
|
|
|
MapWindowPoints(HWND_DESKTOP, g_hMainWnd, (LPPOINT)&rc, 2);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, g_hMainWnd, (LPPOINT)&rc, 2);
|
|
|
|
expect_rect(0, 0, 100, 100, g_rcCreated);
|
|
|
|
expect(0, rc.left);
|
|
|
|
expect(672, rc.right);
|
|
|
|
expect(226, rc.bottom);
|
|
|
|
/* we don't check rc.top as this may depend on user font settings */
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
static int CALLBACK check_height_font_enumproc(ENUMLOGFONTEXA *enumlf, NEWTEXTMETRICEXA *ntm, DWORD type, LPARAM lParam)
|
2008-07-16 20:21:09 +02:00
|
|
|
{
|
2008-07-17 17:33:08 +02:00
|
|
|
HWND hwndStatus = (HWND)lParam;
|
|
|
|
HDC hdc = GetDC(NULL);
|
2009-02-04 00:35:57 +01:00
|
|
|
static const int sizes[] = { 6, 7, 8, 9, 10, 11, 12, 13, 15, 16,
|
|
|
|
20, 22, 28, 36, 48, 72};
|
|
|
|
DWORD i;
|
2011-06-01 15:50:26 +02:00
|
|
|
INT y;
|
2009-02-04 00:35:57 +01:00
|
|
|
LPSTR facename = (CHAR *)enumlf->elfFullName;
|
|
|
|
|
|
|
|
/* on win9x, enumlf->elfFullName is only valid for truetype fonts */
|
|
|
|
if (type != TRUETYPE_FONTTYPE)
|
|
|
|
facename = enumlf->elfLogFont.lfFaceName;
|
2008-07-17 17:33:08 +02:00
|
|
|
|
2018-06-06 20:36:15 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(sizes); i++)
|
2008-07-17 17:33:08 +02:00
|
|
|
{
|
|
|
|
HFONT hFont;
|
2013-10-19 20:30:47 +02:00
|
|
|
TEXTMETRICA tm;
|
2008-07-17 17:33:08 +02:00
|
|
|
HFONT hCtrlFont;
|
|
|
|
HFONT hOldFont;
|
|
|
|
RECT rcCtrl;
|
|
|
|
|
|
|
|
enumlf->elfLogFont.lfHeight = sizes[i];
|
2013-10-19 20:30:47 +02:00
|
|
|
hFont = CreateFontIndirectA(&enumlf->elfLogFont);
|
|
|
|
hCtrlFont = (HFONT)SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
|
2008-07-17 17:33:08 +02:00
|
|
|
hOldFont = SelectObject(hdc, hFont);
|
|
|
|
|
|
|
|
GetClientRect(hwndStatus, &rcCtrl);
|
2013-10-19 20:30:47 +02:00
|
|
|
GetTextMetricsA(hdc, &tm);
|
2009-02-04 00:35:57 +01:00
|
|
|
y = tm.tmHeight + (tm.tmInternalLeading ? tm.tmInternalLeading : 2) + 4;
|
|
|
|
|
2009-02-13 05:39:31 +01:00
|
|
|
ok( (rcCtrl.bottom == max(y, g_ysize)) || (rcCtrl.bottom == max(y, g_dpisize)),
|
2022-02-28 08:25:25 +01:00
|
|
|
"got %ld (expected %d or %d) for %s #%d\n",
|
2009-02-13 05:39:31 +01:00
|
|
|
rcCtrl.bottom, max(y, g_ysize), max(y, g_dpisize), facename, sizes[i]);
|
2008-07-17 17:33:08 +02:00
|
|
|
|
|
|
|
SelectObject(hdc, hOldFont);
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hCtrlFont, TRUE);
|
2008-07-17 17:33:08 +02:00
|
|
|
DeleteObject(hFont);
|
|
|
|
}
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
static int CALLBACK check_height_family_enumproc(ENUMLOGFONTEXA *enumlf, NEWTEXTMETRICEXA *ntm, DWORD type, LPARAM lParam)
|
2008-07-17 17:33:08 +02:00
|
|
|
{
|
|
|
|
HDC hdc = GetDC(NULL);
|
|
|
|
enumlf->elfLogFont.lfHeight = 0;
|
2013-10-19 20:30:47 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &enumlf->elfLogFont, (FONTENUMPROCA)check_height_font_enumproc, lParam, 0);
|
2008-07-17 17:33:08 +02:00
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_height(void)
|
|
|
|
{
|
2013-10-19 20:30:47 +02:00
|
|
|
LOGFONTA lf;
|
2008-07-22 21:29:19 +02:00
|
|
|
HFONT hFont, hFontSm;
|
2008-07-16 20:21:09 +02:00
|
|
|
RECT rc1, rc2;
|
2013-10-19 20:30:47 +02:00
|
|
|
HWND hwndStatus = CreateWindowA(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
|
2008-07-16 20:21:09 +02:00
|
|
|
0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
|
2008-07-17 17:33:08 +02:00
|
|
|
HDC hdc;
|
2008-07-16 20:21:09 +02:00
|
|
|
|
|
|
|
GetClientRect(hwndStatus, &rc1);
|
2013-10-19 20:30:47 +02:00
|
|
|
hFont = CreateFontA(32, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
2008-07-16 20:21:09 +02:00
|
|
|
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Tahoma");
|
|
|
|
|
|
|
|
g_wmsize_count = 0;
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
|
2008-09-15 11:08:24 +02:00
|
|
|
if (!g_wmsize_count)
|
|
|
|
{
|
2008-09-24 10:04:05 +02:00
|
|
|
skip("Status control not resized in win95, skipping broken tests.\n");
|
2008-09-15 11:08:24 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-07-16 20:21:09 +02:00
|
|
|
ok(g_wmsize_count > 0, "WM_SETFONT should issue WM_SIZE\n");
|
|
|
|
|
|
|
|
GetClientRect(hwndStatus, &rc2);
|
2008-09-08 07:46:53 +02:00
|
|
|
expect_rect(0, 0, 672, 42, rc2); /* GetTextMetrics returns invalid tmInternalLeading for this font */
|
2008-07-16 20:21:09 +02:00
|
|
|
|
|
|
|
g_wmsize_count = 0;
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
|
2008-07-16 20:21:09 +02:00
|
|
|
ok(g_wmsize_count > 0, "WM_SETFONT should issue WM_SIZE\n");
|
|
|
|
|
|
|
|
GetClientRect(hwndStatus, &rc2);
|
2008-09-08 07:46:53 +02:00
|
|
|
expect_rect(0, 0, 672, 42, rc2);
|
2008-07-16 20:21:09 +02:00
|
|
|
|
2008-07-22 21:29:19 +02:00
|
|
|
/* minheight < fontsize - no effects*/
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, SB_SETMINHEIGHT, 12, 0);
|
|
|
|
SendMessageA(hwndStatus, WM_SIZE, 0, 0);
|
2008-07-22 21:29:19 +02:00
|
|
|
GetClientRect(hwndStatus, &rc2);
|
2008-09-08 07:46:53 +02:00
|
|
|
expect_rect(0, 0, 672, 42, rc2);
|
2008-07-22 21:29:19 +02:00
|
|
|
|
|
|
|
/* minheight > fontsize - has an effect after WM_SIZE */
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, SB_SETMINHEIGHT, 60, 0);
|
2008-07-22 21:29:19 +02:00
|
|
|
GetClientRect(hwndStatus, &rc2);
|
2008-09-08 07:46:53 +02:00
|
|
|
expect_rect(0, 0, 672, 42, rc2);
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_SIZE, 0, 0);
|
2008-07-22 21:29:19 +02:00
|
|
|
GetClientRect(hwndStatus, &rc2);
|
|
|
|
expect_rect(0, 0, 672, 62, rc2);
|
|
|
|
|
|
|
|
/* font changed to smaller than minheight - has an effect */
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, SB_SETMINHEIGHT, 30, 0);
|
2008-07-22 21:29:19 +02:00
|
|
|
expect_rect(0, 0, 672, 62, rc2);
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_SIZE, 0, 0);
|
2008-07-22 21:29:19 +02:00
|
|
|
GetClientRect(hwndStatus, &rc2);
|
2008-09-08 07:46:53 +02:00
|
|
|
expect_rect(0, 0, 672, 42, rc2);
|
2013-10-19 20:30:47 +02:00
|
|
|
hFontSm = CreateFontA(9, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
2008-07-22 21:29:19 +02:00
|
|
|
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Tahoma");
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFontSm, TRUE);
|
2008-07-22 21:29:19 +02:00
|
|
|
GetClientRect(hwndStatus, &rc2);
|
|
|
|
expect_rect(0, 0, 672, 32, rc2);
|
|
|
|
|
2008-07-17 17:33:08 +02:00
|
|
|
/* test the height formula */
|
|
|
|
ZeroMemory(&lf, sizeof(lf));
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, SB_SETMINHEIGHT, 0, 0);
|
2008-07-17 17:33:08 +02:00
|
|
|
hdc = GetDC(NULL);
|
2009-02-04 00:35:57 +01:00
|
|
|
|
2009-02-13 05:39:31 +01:00
|
|
|
/* used only for some fonts (tahoma as example) */
|
|
|
|
g_ysize = GetSystemMetrics(SM_CYSIZE) + 2;
|
|
|
|
if (g_ysize & 1) g_ysize--; /* The min height is always even */
|
|
|
|
|
|
|
|
g_dpisize = MulDiv(18, GetDeviceCaps(hdc, LOGPIXELSY), 96) + 2;
|
|
|
|
if (g_dpisize & 1) g_dpisize--; /* The min height is always even */
|
|
|
|
|
|
|
|
|
|
|
|
trace("dpi=%d (min height: %d or %d) SM_CYSIZE: %d\n",
|
|
|
|
GetDeviceCaps(hdc, LOGPIXELSY), g_ysize, g_dpisize,
|
|
|
|
GetSystemMetrics(SM_CYSIZE));
|
2009-02-04 00:35:57 +01:00
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &lf, (FONTENUMPROCA)check_height_family_enumproc, (LPARAM)hwndStatus, 0);
|
2008-07-17 17:33:08 +02:00
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
2008-07-16 20:21:09 +02:00
|
|
|
DestroyWindow(hwndStatus);
|
|
|
|
DeleteObject(hFont);
|
2008-07-22 21:29:19 +02:00
|
|
|
DeleteObject(hFontSm);
|
2008-07-16 20:21:09 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 07:23:51 +01:00
|
|
|
static void test_status_control(void)
|
|
|
|
{
|
|
|
|
HWND hWndStatus;
|
|
|
|
int r;
|
|
|
|
int nParts[] = {50, 150, -1};
|
2021-11-12 16:47:39 +01:00
|
|
|
int checkParts[] = {0, 0, 0, 0, 0};
|
2007-02-26 05:43:26 +01:00
|
|
|
int borders[] = {0, 0, 0};
|
2007-01-03 07:23:51 +01:00
|
|
|
RECT rc;
|
2007-02-26 05:43:26 +01:00
|
|
|
CHAR charArray[20];
|
|
|
|
HICON hIcon;
|
2009-03-03 22:50:55 +01:00
|
|
|
char ch;
|
|
|
|
char chstr[10] = "Inval id";
|
2011-06-01 15:50:26 +02:00
|
|
|
COLORREF crColor = RGB(0,0,0);
|
2020-07-21 12:21:00 +02:00
|
|
|
WCHAR wbuf[20];
|
2007-02-26 05:43:26 +01:00
|
|
|
|
2011-02-25 18:03:33 +01:00
|
|
|
hWndStatus = create_status_control(WS_VISIBLE | SBT_TOOLTIPS, 0);
|
2007-01-03 07:23:51 +01:00
|
|
|
|
2007-02-26 05:43:26 +01:00
|
|
|
/* Divide into parts and set text */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETPARTS, 3, (LPARAM)nParts);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_POPOUT|0, (LPARAM)"First");
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW|1, (LPARAM)"Second");
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_NOBORDERS|2, (LPARAM)"Third");
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
2007-01-03 07:23:51 +01:00
|
|
|
|
2007-02-26 05:43:26 +01:00
|
|
|
/* Get RECT Information */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
|
|
|
expect(2,rc.top);
|
|
|
|
/* The rc.bottom test is system dependent
|
|
|
|
expect(22,rc.bottom); */
|
|
|
|
expect(0,rc.left);
|
|
|
|
expect(50,rc.right);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(FALSE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(FALSE,r);
|
|
|
|
/* Get text length and text */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 0, 0);
|
2012-01-20 19:33:10 +01:00
|
|
|
expect(5,LOWORD(r));
|
|
|
|
expect(SBT_POPOUT,HIWORD(r));
|
|
|
|
r = SendMessageW(hWndStatus, WM_GETTEXTLENGTH, 0, 0);
|
2016-09-08 12:20:10 +02:00
|
|
|
ok(r == 5, "Expected 5, got %d\n", r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 1, 0);
|
2012-01-20 19:33:10 +01:00
|
|
|
expect(0,LOWORD(r));
|
|
|
|
expect(SBT_OWNERDRAW,HIWORD(r));
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 2, 0);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(5,LOWORD(r));
|
2012-01-20 19:33:10 +01:00
|
|
|
expect(SBT_NOBORDERS,HIWORD(r));
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTA, 2, (LPARAM) charArray);
|
2007-02-26 05:43:26 +01:00
|
|
|
ok(strcmp(charArray,"Third") == 0, "Expected Third, got %s\n", charArray);
|
|
|
|
expect(5,LOWORD(r));
|
2012-01-20 19:33:10 +01:00
|
|
|
expect(SBT_NOBORDERS,HIWORD(r));
|
2007-02-26 05:43:26 +01:00
|
|
|
|
2021-11-12 16:47:39 +01:00
|
|
|
/* Get parts */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETPARTS, 3, (LPARAM)checkParts);
|
2007-02-26 05:43:26 +01:00
|
|
|
ok(r == 3, "Expected 3, got %d\n", r);
|
|
|
|
expect(50,checkParts[0]);
|
|
|
|
expect(150,checkParts[1]);
|
|
|
|
expect(-1,checkParts[2]);
|
2021-11-12 16:47:39 +01:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETPARTS, 5, (LPARAM)checkParts);
|
|
|
|
ok(r == 3, "Expected 3, got %d\n", r);
|
|
|
|
expect(50,checkParts[0]);
|
|
|
|
expect(150,checkParts[1]);
|
|
|
|
expect(-1,checkParts[2]);
|
|
|
|
expect(0,checkParts[3]);
|
|
|
|
expect(0,checkParts[4]);
|
|
|
|
/* Get borders */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETBORDERS, 0, (LPARAM)borders);
|
2007-01-03 07:23:51 +01:00
|
|
|
ok(r == TRUE, "Expected TRUE, got %d\n", r);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(0,borders[0]);
|
|
|
|
expect(2,borders[1]);
|
|
|
|
expect(2,borders[2]);
|
|
|
|
|
|
|
|
/* Test resetting text with different characters */
|
2020-07-21 12:21:00 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETPARTS, 4, (LPARAM)nParts);
|
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)"First@Again");
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, 1, (LPARAM)"Invalid\tChars\\7\7");
|
2020-07-21 12:21:00 +02:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, 2, (LPARAM)"InvalidChars\\n\n");
|
2020-07-21 12:21:00 +02:00
|
|
|
expect(TRUE,r);
|
|
|
|
r = SendMessageW(hWndStatus, SB_SETTEXTW, 3, (LPARAM)L"Non printable\x80");
|
|
|
|
expect(TRUE,r);
|
2007-01-03 07:23:51 +01:00
|
|
|
|
2007-02-26 05:43:26 +01:00
|
|
|
/* Get text again */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTA, 0, (LPARAM) charArray);
|
2007-02-26 05:43:26 +01:00
|
|
|
ok(strcmp(charArray,"First@Again") == 0, "Expected First@Again, got %s\n", charArray);
|
2020-07-21 12:21:00 +02:00
|
|
|
ok(r == 11, "r = %d\n", r);
|
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTA, 1, (LPARAM) charArray);
|
2009-03-03 22:50:55 +01:00
|
|
|
ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);
|
2020-07-21 12:21:00 +02:00
|
|
|
ok(r == 16, "r = %d\n", r);
|
2009-03-03 22:50:55 +01:00
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTA, 2, (LPARAM) charArray);
|
2009-03-03 22:50:55 +01:00
|
|
|
ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);
|
2020-07-21 12:21:00 +02:00
|
|
|
ok(r == 15, "r = %d\n", r);
|
2009-03-03 22:50:55 +01:00
|
|
|
|
2020-07-21 12:21:00 +02:00
|
|
|
r = SendMessageW(hWndStatus, SB_GETTEXTW, 3, (LPARAM) wbuf);
|
|
|
|
ok(wcscmp(wbuf, L"Non printable\x80") == 0, "got %s\n", wine_dbgstr_w(wbuf));
|
|
|
|
ok(r == 14, "r = %d\n", r);
|
2007-02-26 05:43:26 +01:00
|
|
|
|
2009-03-03 22:50:55 +01:00
|
|
|
/* test more nonprintable chars */
|
|
|
|
for(ch = 0x00; ch < 0x7F; ch++) {
|
|
|
|
chstr[5] = ch;
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)chstr);
|
2009-03-03 22:50:55 +01:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETTEXTA, 0, (LPARAM)charArray);
|
2015-11-11 22:46:49 +01:00
|
|
|
ok(r == strlen(charArray), "got %d\n", r);
|
2009-03-03 22:50:55 +01:00
|
|
|
/* substitution with single space */
|
|
|
|
if (ch > 0x00 && ch < 0x20 && ch != '\t')
|
|
|
|
chstr[5] = ' ';
|
|
|
|
ok(strcmp(charArray, chstr) == 0, "Expected %s, got %s\n", chstr, charArray);
|
|
|
|
}
|
|
|
|
|
2007-02-26 05:43:26 +01:00
|
|
|
/* Set background color */
|
2013-10-19 20:30:47 +02:00
|
|
|
crColor = SendMessageA(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
|
2011-06-01 15:50:26 +02:00
|
|
|
ok(crColor == CLR_DEFAULT ||
|
|
|
|
broken(crColor == RGB(0,0,0)), /* win95 */
|
2022-02-28 08:25:25 +01:00
|
|
|
"Expected 0x%.8lx, got 0x%.8lx\n", CLR_DEFAULT, crColor);
|
2013-10-19 20:30:47 +02:00
|
|
|
crColor = SendMessageA(hWndStatus, SB_SETBKCOLOR , 0, CLR_DEFAULT);
|
2011-06-01 15:50:26 +02:00
|
|
|
ok(crColor == RGB(255,0,0) ||
|
|
|
|
broken(crColor == RGB(0,0,0)), /* win95 */
|
2022-02-28 08:25:25 +01:00
|
|
|
"Expected 0x%.8lx, got 0x%.8lx\n", RGB(255,0,0), crColor);
|
2007-02-26 05:43:26 +01:00
|
|
|
|
|
|
|
/* Add an icon to the status bar */
|
2013-10-19 20:30:47 +02:00
|
|
|
hIcon = LoadIconA(NULL, (LPCSTR)IDI_QUESTION);
|
|
|
|
r = SendMessageA(hWndStatus, SB_SETICON, 1, 0);
|
2008-09-15 04:47:19 +02:00
|
|
|
ok(r != 0 ||
|
|
|
|
broken(r == 0), /* win95 */
|
|
|
|
"Expected non-zero, got %d\n", r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETICON, 1, (LPARAM) hIcon);
|
2008-09-15 04:47:19 +02:00
|
|
|
ok(r != 0 ||
|
|
|
|
broken(r == 0), /* win95 */
|
|
|
|
"Expected non-zero, got %d\n", r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETICON, 1, 0);
|
2008-09-15 04:47:19 +02:00
|
|
|
ok(r != 0 ||
|
|
|
|
broken(r == 0), /* win95 */
|
|
|
|
"Expected non-zero, got %d\n", r);
|
2007-02-26 05:43:26 +01:00
|
|
|
|
|
|
|
/* Set the Unicode format */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETUNICODEFORMAT, FALSE, 0);
|
2011-02-17 03:20:47 +01:00
|
|
|
expect(FALSE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(FALSE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETUNICODEFORMAT, TRUE, 0);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(FALSE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
|
2008-09-15 04:47:19 +02:00
|
|
|
ok(r == TRUE ||
|
|
|
|
broken(r == FALSE), /* win95 */
|
|
|
|
"Expected TRUE, got %d\n", r);
|
2007-02-26 05:43:26 +01:00
|
|
|
|
|
|
|
/* Reset number of parts */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETPARTS, 2, (LPARAM)nParts);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETPARTS, 0, 0);
|
2011-03-01 02:01:42 +01:00
|
|
|
ok(r == 2, "Expected 2, got %d\n", r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETPARTS, 0, 0);
|
2011-03-01 02:01:42 +01:00
|
|
|
expect(FALSE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETPARTS, 0, 0);
|
2011-03-01 02:01:42 +01:00
|
|
|
ok(r == 2, "Expected 2, got %d\n", r);
|
2007-02-26 05:43:26 +01:00
|
|
|
|
|
|
|
/* Set the minimum height and get rectangle information again */
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hWndStatus, SB_SETMINHEIGHT, 50, 0);
|
|
|
|
r = SendMessageA(hWndStatus, WM_SIZE, 0, 0);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(0,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(TRUE,r);
|
|
|
|
expect(2,rc.top);
|
|
|
|
/* The rc.bottom test is system dependent
|
|
|
|
expect(22,rc.bottom); */
|
|
|
|
expect(0,rc.left);
|
|
|
|
expect(50,rc.right);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(FALSE,r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
|
2007-02-26 05:43:26 +01:00
|
|
|
expect(FALSE,r);
|
|
|
|
|
|
|
|
/* Set the ToolTip text */
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hWndStatus, SB_SETTIPTEXTA, 0,(LPARAM) "Tooltip Text");
|
2011-02-25 18:03:33 +01:00
|
|
|
lstrcpyA(charArray, "apple");
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hWndStatus, SB_GETTIPTEXTA, MAKEWPARAM (0, 20),(LPARAM) charArray);
|
2011-02-25 18:03:33 +01:00
|
|
|
ok(strcmp(charArray,"Tooltip Text") == 0 ||
|
|
|
|
broken(!strcmp(charArray, "apple")), /* win95 */
|
|
|
|
"Expected Tooltip Text, got %s\n", charArray);
|
2007-02-26 05:43:26 +01:00
|
|
|
|
|
|
|
/* Make simple */
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hWndStatus, SB_SIMPLE, TRUE, 0);
|
|
|
|
r = SendMessageA(hWndStatus, SB_ISSIMPLE, 0, 0);
|
2008-09-24 10:03:28 +02:00
|
|
|
ok(r == TRUE ||
|
|
|
|
broken(r == FALSE), /* win95 */
|
|
|
|
"Expected TRUE, got %d\n", r);
|
2007-01-03 07:23:51 +01:00
|
|
|
|
|
|
|
DestroyWindow(hWndStatus);
|
|
|
|
}
|
|
|
|
|
2009-02-15 14:27:55 +01:00
|
|
|
static LRESULT WINAPI ownerdraw_test_wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
LRESULT ret;
|
|
|
|
if (msg == WM_DRAWITEM)
|
|
|
|
g_wmdrawitm_ctr++;
|
2013-10-19 20:30:47 +02:00
|
|
|
ret = CallWindowProcA(g_wndproc_saved, hwnd, msg, wParam, lParam);
|
2009-02-15 14:27:55 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_status_ownerdraw(void)
|
|
|
|
{
|
|
|
|
HWND hWndStatus;
|
|
|
|
int r;
|
|
|
|
const char* statustext = "STATUS TEXT";
|
|
|
|
LONG oldstyle;
|
|
|
|
|
|
|
|
/* subclass the main window and make sure it is visible */
|
2013-10-19 20:30:47 +02:00
|
|
|
g_wndproc_saved = (WNDPROC) SetWindowLongPtrA( g_hMainWnd, GWLP_WNDPROC,
|
2009-02-15 14:27:55 +01:00
|
|
|
(LONG_PTR)ownerdraw_test_wndproc );
|
|
|
|
ok( g_wndproc_saved != 0, "failed to set the WndProc\n");
|
|
|
|
SetWindowPos( g_hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
2013-10-19 20:30:47 +02:00
|
|
|
oldstyle = GetWindowLongA( g_hMainWnd, GWL_STYLE);
|
|
|
|
SetWindowLongA( g_hMainWnd, GWL_STYLE, oldstyle | WS_VISIBLE);
|
2009-02-15 14:27:55 +01:00
|
|
|
/* create a status child window */
|
|
|
|
ok((hWndStatus = CreateWindowA(SUBCLASS_NAME, "", WS_CHILD|WS_VISIBLE, 0, 0, 100, 100,
|
|
|
|
g_hMainWnd, NULL, NULL, 0)) != NULL, "CreateWindowA failed\n");
|
|
|
|
/* set text */
|
|
|
|
g_wmdrawitm_ctr = 0;
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)statustext);
|
2009-02-15 14:27:55 +01:00
|
|
|
ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
|
|
|
|
ok( 0 == g_wmdrawitm_ctr, "got %d drawitem messages expected none\n", g_wmdrawitm_ctr);
|
|
|
|
/* set same text, with ownerdraw flag */
|
|
|
|
g_wmdrawitm_ctr = 0;
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW, (LPARAM)statustext);
|
2009-02-15 14:27:55 +01:00
|
|
|
ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
|
|
|
|
ok( 1 == g_wmdrawitm_ctr, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr);
|
2011-09-27 00:14:10 +02:00
|
|
|
/* and again */
|
2009-02-15 14:27:55 +01:00
|
|
|
g_wmdrawitm_ctr = 0;
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW, (LPARAM)statustext);
|
2009-02-15 14:27:55 +01:00
|
|
|
ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
|
|
|
|
ok( 1 == g_wmdrawitm_ctr, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr);
|
|
|
|
/* clean up */
|
|
|
|
DestroyWindow(hWndStatus);
|
2013-10-19 20:30:47 +02:00
|
|
|
SetWindowLongA( g_hMainWnd, GWL_STYLE, oldstyle);
|
|
|
|
SetWindowLongPtrA( g_hMainWnd, GWLP_WNDPROC, (LONG_PTR)g_wndproc_saved );
|
2009-02-15 14:27:55 +01:00
|
|
|
}
|
|
|
|
|
2009-08-26 17:50:39 +02:00
|
|
|
static void test_gettext(void)
|
|
|
|
{
|
2013-10-19 20:30:47 +02:00
|
|
|
HWND hwndStatus = CreateWindowA(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
|
2009-08-26 17:50:39 +02:00
|
|
|
0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
|
|
|
|
char buf[5];
|
|
|
|
int r;
|
|
|
|
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hwndStatus, SB_SETTEXTA, 0, (LPARAM)"Text");
|
2009-08-26 17:50:39 +02:00
|
|
|
expect(TRUE, r);
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hwndStatus, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-26 17:50:39 +02:00
|
|
|
expect(4, r);
|
|
|
|
/* A size of 0 returns the length of the text */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hwndStatus, WM_GETTEXT, 0, 0);
|
2013-02-20 23:37:45 +01:00
|
|
|
ok( r == 4 || broken(r == 2) /* win8 */, "Expected 4 got %d\n", r );
|
2009-08-26 17:50:39 +02:00
|
|
|
/* A size of 1 only stores the NULL terminator */
|
|
|
|
buf[0] = 0xa;
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hwndStatus, WM_GETTEXT, 1, (LPARAM)buf);
|
2009-08-29 14:15:58 +02:00
|
|
|
ok( r == 0 || broken(r == 4), "Expected 0 got %d\n", r );
|
|
|
|
if (!r) ok(!buf[0], "expected empty buffer\n");
|
2009-08-26 17:50:39 +02:00
|
|
|
/* A size of 2 returns a length 1 */
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hwndStatus, WM_GETTEXT, 2, (LPARAM)buf);
|
2009-08-29 14:15:58 +02:00
|
|
|
ok( r == 1 || broken(r == 4), "Expected 1 got %d\n", r );
|
2013-10-19 20:30:47 +02:00
|
|
|
r = SendMessageA(hwndStatus, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
|
2009-08-26 17:50:39 +02:00
|
|
|
expect(4, r);
|
|
|
|
ok(!strcmp(buf, "Text"), "expected Text, got %s\n", buf);
|
|
|
|
DestroyWindow(hwndStatus);
|
|
|
|
}
|
|
|
|
|
2010-01-21 02:45:46 +01:00
|
|
|
/* Notify events to parent */
|
|
|
|
static BOOL g_got_dblclk;
|
|
|
|
static BOOL g_got_click;
|
|
|
|
static BOOL g_got_rdblclk;
|
|
|
|
static BOOL g_got_rclick;
|
|
|
|
|
|
|
|
/* Messages to parent */
|
|
|
|
static BOOL g_got_contextmenu;
|
|
|
|
|
|
|
|
static LRESULT WINAPI test_notify_parent_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
NMHDR *hdr = ((LPNMHDR)lParam);
|
|
|
|
switch(hdr->code)
|
|
|
|
{
|
|
|
|
case NM_DBLCLK: g_got_dblclk = TRUE; break;
|
|
|
|
case NM_CLICK: g_got_click = TRUE; break;
|
|
|
|
case NM_RDBLCLK: g_got_rdblclk = TRUE; break;
|
|
|
|
case NM_RCLICK: g_got_rclick = TRUE; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return zero to indicate default processing */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_CONTEXTMENU: g_got_contextmenu = TRUE; return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return( DefWindowProcA(hwnd, msg, wParam, lParam));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test that WM_NOTIFY messages from the status control works correctly */
|
|
|
|
static void test_notify(void)
|
|
|
|
{
|
|
|
|
HWND hwndParent;
|
|
|
|
HWND hwndStatus;
|
|
|
|
ATOM atom;
|
|
|
|
WNDCLASSA wclass = {0};
|
|
|
|
wclass.lpszClassName = "TestNotifyParentClass";
|
|
|
|
wclass.lpfnWndProc = test_notify_parent_proc;
|
|
|
|
atom = RegisterClassA(&wclass);
|
2010-03-20 15:25:31 +01:00
|
|
|
ok(atom, "RegisterClass failed\n");
|
2010-01-21 02:45:46 +01:00
|
|
|
|
|
|
|
/* create parent */
|
2013-10-19 20:30:47 +02:00
|
|
|
hwndParent = CreateWindowA(wclass.lpszClassName, "parent", WS_OVERLAPPEDWINDOW,
|
2010-01-21 02:45:46 +01:00
|
|
|
CW_USEDEFAULT, 0, 300, 20, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwndParent != NULL, "Parent creation failed!\n");
|
|
|
|
|
|
|
|
/* create status bar */
|
2013-10-19 20:30:47 +02:00
|
|
|
hwndStatus = CreateWindowA(STATUSCLASSNAMEA, NULL, WS_VISIBLE | WS_CHILD,
|
2010-01-21 02:45:46 +01:00
|
|
|
0, 0, 300, 20, hwndParent, NULL, NULL, NULL);
|
|
|
|
ok(hwndStatus != NULL, "Status creation failed!\n");
|
|
|
|
|
|
|
|
/* Send various mouse event, and check that we get them */
|
|
|
|
g_got_dblclk = FALSE;
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_LBUTTONDBLCLK, 0, 0);
|
2010-01-21 02:45:46 +01:00
|
|
|
ok(g_got_dblclk, "WM_LBUTTONDBLCLK was not processed correctly!\n");
|
|
|
|
g_got_rdblclk = FALSE;
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_RBUTTONDBLCLK, 0, 0);
|
2010-01-21 02:45:46 +01:00
|
|
|
ok(g_got_rdblclk, "WM_RBUTTONDBLCLK was not processed correctly!\n");
|
|
|
|
g_got_click = FALSE;
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_LBUTTONUP, 0, 0);
|
2010-01-21 02:45:46 +01:00
|
|
|
ok(g_got_click, "WM_LBUTTONUP was not processed correctly!\n");
|
|
|
|
|
|
|
|
/* For R-UP, check that we also get the context menu from the default processing */
|
|
|
|
g_got_contextmenu = FALSE;
|
|
|
|
g_got_rclick = FALSE;
|
2013-10-19 20:30:47 +02:00
|
|
|
SendMessageA(hwndStatus, WM_RBUTTONUP, 0, 0);
|
2010-01-21 02:45:46 +01:00
|
|
|
ok(g_got_rclick, "WM_RBUTTONUP was not processed correctly!\n");
|
|
|
|
ok(g_got_contextmenu, "WM_RBUTTONUP did not activate the context menu!\n");
|
|
|
|
}
|
|
|
|
|
2018-12-10 10:52:09 +01:00
|
|
|
static void test_sizegrip(void)
|
|
|
|
{
|
|
|
|
HWND hwndStatus;
|
|
|
|
LONG style;
|
|
|
|
RECT rc, rcClient;
|
|
|
|
POINT pt;
|
|
|
|
int width, r;
|
|
|
|
|
|
|
|
hwndStatus = CreateWindowA(SUBCLASS_NAME, "", WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP,
|
|
|
|
0, 0, 100, 100, g_hMainWnd, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
style = GetWindowLongPtrA(g_hMainWnd, GWL_STYLE);
|
|
|
|
width = GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
|
|
|
|
GetClientRect(hwndStatus, &rcClient);
|
|
|
|
|
|
|
|
pt.x = rcClient.right;
|
|
|
|
pt.y = rcClient.top;
|
|
|
|
ClientToScreen(hwndStatus, &pt);
|
|
|
|
rc.left = pt.x - width;
|
|
|
|
rc.right = pt.x;
|
|
|
|
rc.top = pt.y;
|
|
|
|
|
|
|
|
pt.y = rcClient.bottom;
|
|
|
|
ClientToScreen(hwndStatus, &pt);
|
|
|
|
rc.bottom = pt.y;
|
|
|
|
|
|
|
|
/* check bounds when not maximized */
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMRIGHT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left - 1, rc.top));
|
|
|
|
expect(HTCLIENT, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top - 1));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMRIGHT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMRIGHT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right + 1, rc.bottom));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMRIGHT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom + 1));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMRIGHT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right - 1, rc.bottom - 1));
|
|
|
|
expect(HTBOTTOMRIGHT, r);
|
|
|
|
|
|
|
|
/* not maximized and right-to-left */
|
|
|
|
SetWindowLongA(hwndStatus, GWL_EXSTYLE, WS_EX_LAYOUTRTL);
|
|
|
|
|
|
|
|
pt.x = rcClient.right;
|
|
|
|
ClientToScreen(hwndStatus, &pt);
|
|
|
|
rc.left = pt.x + width;
|
|
|
|
rc.right = pt.x;
|
|
|
|
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMLEFT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left + 1, rc.top));
|
|
|
|
expect(HTCLIENT, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top - 1));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMLEFT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMLEFT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right - 1, rc.bottom));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMLEFT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom + 1));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTBOTTOMLEFT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right + 1, rc.bottom - 1));
|
|
|
|
expect(HTBOTTOMLEFT, r);
|
|
|
|
|
|
|
|
/* maximize with left-to-right */
|
|
|
|
SetWindowLongA(g_hMainWnd, GWL_STYLE, style|WS_MAXIMIZE);
|
|
|
|
SetWindowLongA(hwndStatus, GWL_EXSTYLE, 0);
|
|
|
|
|
|
|
|
GetClientRect(hwndStatus, &rcClient);
|
|
|
|
|
|
|
|
pt.x = rcClient.right;
|
|
|
|
pt.y = rcClient.top;
|
|
|
|
ClientToScreen(hwndStatus, &pt);
|
|
|
|
rc.left = pt.x - width;
|
|
|
|
rc.right = pt.x;
|
|
|
|
rc.top = pt.y;
|
|
|
|
|
|
|
|
pt.y = rcClient.bottom;
|
|
|
|
ClientToScreen(hwndStatus, &pt);
|
|
|
|
rc.bottom = pt.y;
|
|
|
|
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top));
|
|
|
|
expect(HTCLIENT, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left - 1, rc.top));
|
|
|
|
expect(HTCLIENT, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top - 1));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right + 1, rc.bottom));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom + 1));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right - 1, rc.bottom - 1));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTCLIENT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
|
|
|
|
/* maximized with right-to-left */
|
|
|
|
SetWindowLongA(hwndStatus, GWL_EXSTYLE, WS_EX_LAYOUTRTL);
|
|
|
|
|
|
|
|
pt.x = rcClient.right;
|
|
|
|
ClientToScreen(hwndStatus, &pt);
|
|
|
|
rc.left = pt.x + width;
|
|
|
|
rc.right = pt.x;
|
|
|
|
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top));
|
|
|
|
expect(HTCLIENT, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left + 1, rc.top));
|
|
|
|
expect(HTCLIENT, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.left, rc.top - 1));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right - 1, rc.bottom));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right, rc.bottom + 1));
|
|
|
|
expect(HTNOWHERE, r);
|
|
|
|
r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(rc.right + 1, rc.bottom - 1));
|
2018-12-10 10:52:10 +01:00
|
|
|
expect(HTCLIENT, r);
|
2018-12-10 10:52:09 +01:00
|
|
|
|
|
|
|
SetWindowLongA(g_hMainWnd, GWL_STYLE, style);
|
|
|
|
DestroyWindow(hwndStatus);
|
|
|
|
}
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static void init_functions(void)
|
|
|
|
{
|
|
|
|
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
|
|
|
|
|
|
|
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
|
|
|
|
X(InitCommonControlsEx);
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2007-01-03 07:23:51 +01:00
|
|
|
START_TEST(status)
|
|
|
|
{
|
2018-01-24 13:47:09 +01:00
|
|
|
INITCOMMONCONTROLSEX iccex;
|
|
|
|
|
|
|
|
init_functions();
|
|
|
|
|
2007-01-03 07:23:51 +01:00
|
|
|
hinst = GetModuleHandleA(NULL);
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
iccex.dwSize = sizeof(iccex);
|
|
|
|
iccex.dwICC = ICC_BAR_CLASSES;
|
|
|
|
pInitCommonControlsEx(&iccex);
|
|
|
|
|
2018-02-14 06:33:50 +01:00
|
|
|
g_hMainWnd = CreateWindowExA(0, WC_STATICA, "", WS_OVERLAPPEDWINDOW,
|
2008-07-16 15:25:43 +02:00
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 672+2*GetSystemMetrics(SM_CXSIZEFRAME),
|
|
|
|
226+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYSIZEFRAME),
|
|
|
|
NULL, NULL, GetModuleHandleA(NULL), 0);
|
|
|
|
|
2008-07-16 20:21:09 +02:00
|
|
|
register_subclass();
|
|
|
|
|
2007-01-03 07:23:51 +01:00
|
|
|
test_status_control();
|
2008-07-16 15:25:43 +02:00
|
|
|
test_create();
|
2008-07-17 17:33:08 +02:00
|
|
|
test_height();
|
2009-02-15 14:27:55 +01:00
|
|
|
test_status_ownerdraw();
|
2009-08-26 17:50:39 +02:00
|
|
|
test_gettext();
|
2010-01-21 02:45:46 +01:00
|
|
|
test_notify();
|
2018-12-10 10:52:09 +01:00
|
|
|
test_sizegrip();
|
2007-01-03 07:23:51 +01:00
|
|
|
}
|