Commit c23ccc03 authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

comdlg32: Rearrange some more controls when resizing a file dialog.

parent 0066319b
......@@ -1019,6 +1019,8 @@ static LRESULT FILEDLG95_OnWMSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
/* get the new dialog rectangle */
GetWindowRect( hwnd, &rc);
TRACE("Size from %d,%d to %d,%d\n", fodInfos->sizedlg.cx, fodInfos->sizedlg.cy,
rc.right -rc.left, rc.bottom -rc.top);
/* not initialized yet */
if( (fodInfos->sizedlg.cx == 0 && fodInfos->sizedlg.cy == 0) ||
((fodInfos->sizedlg.cx == rc.right -rc.left) && /* no change */
......@@ -1039,6 +1041,7 @@ static LRESULT FILEDLG95_OnWMSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* change position and sizes of the controls */
for( ctrl = GetWindow( hwnd, GW_CHILD); ctrl ; ctrl = GetWindow( ctrl, GW_HWNDNEXT))
{
int ctrlid = GetDlgCtrlID( ctrl);
GetWindowRect( ctrl, &rc);
MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
if( ctrl == fodInfos->DlgInfos.hwndGrip)
......@@ -1047,29 +1050,69 @@ static LRESULT FILEDLG95_OnWMSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
else if( GetDlgCtrlID( ctrl) == IDC_SHELLSTATIC)
{
DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
rc.right - rc.left + chgx,
rc.bottom - rc.top + chgy,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
}
else if( rc.top > rcview.bottom)
{
/* if it was below the shell view
* move to bottom */
DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
rc.right - rc.left, rc.bottom - rc.top,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
switch( ctrlid)
{
/* file name box and file types combo change also width */
case edt1:
case cmb1:
DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
rc.right - rc.left + chgx, rc.bottom - rc.top,
SWP_NOACTIVATE | SWP_NOZORDER);
break;
/* then these buttons must move out of the way */
case IDOK:
case IDCANCEL:
case pshHelp:
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
break;
default:
DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
}
else if( rc.left > rcview.right)
{
/* if it was to the right of the shell view
* move to right */
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
rc.right - rc.left, rc.bottom - rc.top,
0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
else
/* special cases */
{
switch( ctrlid)
{
#if 0 /* this is Win2k, Win XP. Vista and Higher don't move/size these controls */
case IDC_LOOKIN:
DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
rc.right - rc.left + chgx, rc.bottom - rc.top,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
break;
case IDC_TOOLBARSTATIC:
case IDC_TOOLBAR:
DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
break;
#endif
/* not resized in windows. Since wine uses this invisible control
* to size the browser view it needs to be resized */
case IDC_SHELLSTATIC:
DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
rc.right - rc.left + chgx,
rc.bottom - rc.top + chgy,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
break;
}
}
}
if(fodInfos->DlgInfos.hwndCustomDlg &&
(fodInfos->ofnInfos->Flags & (OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE)))
......
......@@ -278,16 +278,17 @@ struct {
int resize_timer1; /* change in first WM_TIMER handler */
int resize_check; /* expected change (in second WM_TIMER handler) */
BOOL todo; /* mark that test todo_wine */
BOOL testcontrols; /* test resizing and moving of the controls */
} resize_testcases[] = {
{ 0 , 10, 10, 10, 30,FALSE}, /* 0 */
{ 0 ,-10,-10,-10,-30,FALSE},
{ OFN_ENABLESIZING , 0, 0, 0, 0,FALSE},
{ OFN_ENABLESIZING , 0, 0,-10, 0,FALSE},
{ OFN_ENABLESIZING , 0, 0, 10, 10,FALSE},
{ OFN_ENABLESIZING , 0,-10, 0, 10, TRUE}, /* 5 */
{ OFN_ENABLESIZING , 0, 10, 0, 10,FALSE},
{ OFN_ENABLESIZING ,-10, 0, 0, 10, TRUE},
{ OFN_ENABLESIZING , 10, 0, 0, 10,FALSE},
{ 0 , 10, 10, 10, 30,FALSE,FALSE}, /* 0 */
{ 0 ,-10,-10,-10,-30,FALSE,FALSE},
{ OFN_ENABLESIZING , 0, 0, 0, 0,FALSE,FALSE},
{ OFN_ENABLESIZING , 0, 0,-10, 0,FALSE,FALSE},
{ OFN_ENABLESIZING , 0, 0, 10, 10,FALSE, TRUE},
{ OFN_ENABLESIZING , 0,-10, 0, 10, TRUE,FALSE}, /* 5 */
{ OFN_ENABLESIZING , 0, 10, 0, 10,FALSE,FALSE},
{ OFN_ENABLESIZING ,-10, 0, 0, 10, TRUE,FALSE},
{ OFN_ENABLESIZING , 10, 0, 0, 10,FALSE,FALSE},
/* mark the end */
{ 0xffffffff }
};
......@@ -299,6 +300,12 @@ static LONG_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, L
static int gotSWP_bottom, gotShowWindow;
HWND parent = GetParent( dlg);
int resize;
#define MAXNRCTRLS 30
static RECT ctrlrcs[MAXNRCTRLS];
static int ctrlids[MAXNRCTRLS];
static HWND ctrls[MAXNRCTRLS];
static int nrctrls;
switch( msg)
{
case WM_INITDIALOG:
......@@ -343,6 +350,20 @@ static LONG_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, L
case WM_TIMER:
{
if( count == 0){
/* store the control rectangles */
if( resize_testcases[index].testcontrols) {
HWND ctrl;
int i;
for( i = 0, ctrl = GetWindow( parent, GW_CHILD);
i < MAXNRCTRLS && ctrl;
i++, ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
ctrlids[i] = GetDlgCtrlID( ctrl);
GetWindowRect( ctrl, &ctrlrcs[i]);
MapWindowPoints( NULL, parent, (LPPOINT) &ctrlrcs[i], 2);
ctrls[i] = ctrl;
}
nrctrls = i;
}
if( (resize = resize_testcases[index].resize_timer1)){
GetWindowRect( parent, &rc);
MoveWindow( parent, rc.left,rc.top, rc.right - rc.left + resize,
......@@ -368,6 +389,101 @@ static LONG_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, L
"testid %d size-y change %d expected %d\n", index,
rc.bottom - rc.top - initrc.bottom + initrc.top, resize);
}
if( resize_testcases[index].testcontrols) {
int i;
RECT rc;
for( i = 0; i < nrctrls; i++) {
GetWindowRect( ctrls[i], &rc);
MapWindowPoints( NULL, parent, (LPPOINT) &rc, 2);
switch( ctrlids[i]){
/* test if RECT R1, moved and sized result in R2 */
#define TESTRECTS( R1, R2, Mx, My, Sx, Sy) \
((R1).left + (Mx) ==(R2).left \
&&(R1).top + (My) ==(R2).top \
&&(R1).right + (Mx) + (Sx) == (R2).right \
&&(R1).bottom + (My) + (Sy) ==(R2).bottom)
/* sized horizontal and moved vertical */
case cmb1:
case edt1:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 10, 0) ||
broken(TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0)),/*win98*/
"control id %03x should have sized horizontally and moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* sized horizontal and vertical */
case lst2:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 10),
"control id %03x should have sized horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* moved horizontal and vertical */
case IDCANCEL:
case pshHelp:
ok( TESTRECTS( ctrlrcs[i], rc, 10, 10, 0, 0) ||
broken(TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0)),/*win98*/
"control id %03x should have moved horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* moved vertically */
case chx1:
case stc2:
case stc3:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0),
"control id %03x should have moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* resized horizontal */
case cmb2: /* aka IDC_LOOKIN */
ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 0)||
TESTRECTS( ctrlrcs[i], rc, 0, 0, 0, 0), /* Vista and higher */
"control id %03x should have resized horizontally, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* non moving non sizing controls */
case stc4:
ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
"control id %03x was moved/resized, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* todo_wine: non moving non sizing controls */
case lst1:
todo_wine
ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
"control id %03x was moved/resized, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
break;
/* don't test: id is not unique */
case IDOK:
case stc1:
case 0:
case -1:
break;
default:
trace("untested control id %03x before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom,
rc.left, rc.top, rc.right, rc.bottom);
#undef TESTRECTS
#undef MAXNRCTRLS
}
}
}
KillTimer( dlg, 0);
PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
}
......@@ -410,7 +526,7 @@ static void test_resize(void)
for( i = 0; resize_testcases[i].flags != 0xffffffff; i++) {
ofn.lCustData = i;
ofn.Flags = resize_testcases[i].flags |
OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ;
OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE | OFN_SHOWHELP ;
ret = GetOpenFileName(&ofn);
ok(!ret, "GetOpenFileName returned %#x\n", ret);
ret = CommDlgExtendedError();
......@@ -526,7 +642,8 @@ static void test_ok(void)
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
ok( DeleteFileA( tmpfilename), "Failed to delete temporary file\n");
ret = DeleteFileA( tmpfilename);
ok( ret, "Failed to delete temporary file %s err %d\n", tmpfilename, GetLastError());
}
START_TEST(filedlg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment