static void test_dts_shownone(void) { HWND hwnd; DWORD style; /* it isn't allowed to change DTS_SHOWNONE after creation */ hwnd = create_datetime_control(0); style = GetWindowLongA(hwnd, GWL_STYLE); SetWindowLongA(hwnd, GWL_STYLE, style | DTS_SHOWNONE); style = GetWindowLongA(hwnd, GWL_STYLE); ok(!(style & DTS_SHOWNONE), "Expected DTS_SHOWNONE not to be set\n"); DestroyWindow(hwnd); hwnd = create_datetime_control(DTS_SHOWNONE); style = GetWindowLongA(hwnd, GWL_STYLE); SetWindowLongA(hwnd, GWL_STYLE, style & ~DTS_SHOWNONE); style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & DTS_SHOWNONE, "Expected DTS_SHOWNONE to be set\n"); DestroyWindow(hwnd); }
/************************************************************************* * DragAcceptFiles [SHELL32.@] */ void WINAPI DragAcceptFiles(HWND hWnd, BOOL b) { LONG exstyle; if( !IsWindow(hWnd) ) return; exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE); if (b) exstyle |= WS_EX_ACCEPTFILES; else exstyle &= ~WS_EX_ACCEPTFILES; SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle); }
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; /* log system messages, except for painting */ if (message < WM_USER && message != WM_PAINT && message != WM_ERASEBKGND && message != WM_NCPAINT && message != WM_NCHITTEST && message != WM_GETTEXT && message != WM_GETICON && message != WM_DEVICECHANGE) { msg.message = message; msg.flags = sent|wparam|lparam|parent; if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code; add_message(sequences, PAGER_SEQ_INDEX, &msg); } if (message == WM_NOTIFY) { NMHDR *nmhdr = (NMHDR *)lParam; switch (nmhdr->code) { case PGN_CALCSIZE: { NMPGCALCSIZE *nmpgcs = (NMPGCALCSIZE *)lParam; DWORD style = GetWindowLongA(nmpgcs->hdr.hwndFrom, GWL_STYLE); if (style & PGS_HORZ) ok(nmpgcs->dwFlag == PGF_CALCWIDTH, "Unexpected flags %#x.\n", nmpgcs->dwFlag); else ok(nmpgcs->dwFlag == PGF_CALCHEIGHT, "Unexpected flags %#x.\n", nmpgcs->dwFlag); break; } default: ; } } defwndproc_counter++; ret = DefWindowProcA(hwnd, message, wParam, lParam); defwndproc_counter--; return ret; }
WNDPROC SubclassWindow(HWND hWnd, WNDPROC newWndProc) { WNDPROC origProc; if (IsWindowUnicode(hWnd)) { origProc = (WNDPROC)GetWindowLongW(hWnd, GWL_WNDPROC); SetWindowLongW(hWnd, GWL_WNDPROC, (LONG)newWndProc); } else { origProc = (WNDPROC)GetWindowLongA(hWnd, GWL_WNDPROC); SetWindowLongA(hWnd, GWL_WNDPROC, (LONG)newWndProc); } return origProc; }
static int TestgetwindowinfoObjCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { long hwnd; Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL; Tcl_Obj *childrenObj = NULL; TCHAR buf[512]; int cch, cchBuf = 256; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "hwnd"); return TCL_ERROR; } if (Tcl_GetLongFromObj(interp, objv[1], &hwnd) != TCL_OK) return TCL_ERROR; cch = GetClassName(INT2PTR(hwnd), buf, cchBuf); if (cch == 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1)); AppendSystemError(interp, GetLastError()); return TCL_ERROR; } else { Tcl_DString ds; Tcl_WinTCharToUtf(buf, -1, &ds); classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); } dictObj = Tcl_NewDictObj(); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), Tcl_NewLongObj(GetWindowLongA(INT2PTR(hwnd), GWL_ID))); cch = GetWindowText(INT2PTR(hwnd), (LPTSTR)buf, cchBuf); textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), Tcl_NewLongObj(PTR2INT(GetParent((INT2PTR(hwnd)))))); childrenObj = Tcl_NewListObj(0, NULL); EnumChildWindows(INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj); Tcl_SetObjResult(interp, dictObj); return TCL_OK; }
HOOKFUNC LONG WINAPI MyGetWindowLongA(HWND hWnd, int nIndex) { debuglog(LCF_WINDOW|LCF_FREQUENT, __FUNCTION__ "(%d) called on 0x%X.\n", nIndex, hWnd); if(nIndex == GWL_WNDPROC) { std::map<HWND, WNDPROC>::iterator found = hwndToOrigHandler.find(hWnd); if(found != hwndToOrigHandler.end()) { debuglog(LCF_WINDOW|LCF_FREQUENT, __FUNCTION__ " rV = 0x%X.\n", found->second); return (LONG)found->second; } else { LONG rv = GetWindowLongA(hWnd, nIndex); debuglog(LCF_WINDOW|LCF_FREQUENT, __FUNCTION__ " rv! = 0x%X.\n", rv); return rv; } } LONG rv = GetWindowLongA(hWnd, nIndex); debuglog(LCF_WINDOW|LCF_FREQUENT, __FUNCTION__ " Rv = 0x%X.\n", rv); return rv; }
static void test_create_tooltip(void) { HWND parent, hwnd; DWORD style, exp_style; parent = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, 0); ok(parent != NULL, "failed to create parent wnd\n"); hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0x7fffffff | WS_POPUP, 10, 10, 300, 100, parent, NULL, NULL, 0); ok(hwnd != NULL, "failed to create tooltip wnd\n"); style = GetWindowLongA(hwnd, GWL_STYLE); trace("style = %08x\n", style); exp_style = 0x7fffffff | WS_POPUP; exp_style &= ~(WS_CHILD | WS_MAXIMIZE | WS_BORDER | WS_DLGFRAME); ok(style == exp_style || broken(style == (exp_style | WS_BORDER)), /* nt4 */ "wrong style %08x/%08x\n", style, exp_style); DestroyWindow(hwnd); hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, 10, 10, 300, 100, parent, NULL, NULL, 0); ok(hwnd != NULL, "failed to create tooltip wnd\n"); style = GetWindowLongA(hwnd, GWL_STYLE); trace("style = %08x\n", style); ok(style == (WS_POPUP | WS_CLIPSIBLINGS | WS_BORDER), "wrong style %08x\n", style); DestroyWindow(hwnd); DestroyWindow(parent); }
static void test_autoscroll(void) { HWND hwnd; UINT ret; /* The WS_VSCROLL and WS_HSCROLL styles implicitly set * auto vertical/horizontal scrolling options. */ hwnd = CreateWindowExA(0, RICHEDIT_CLASS10A, NULL, WS_POPUP|ES_MULTILINE|WS_VSCROLL|WS_HSCROLL, 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS10A, (int) GetLastError()); ret = SendMessageA(hwnd, EM_GETOPTIONS, 0, 0); ok(ret & ECO_AUTOVSCROLL || broken(!(ret & ECO_AUTOVSCROLL)), /* Win9x, WinME and NT4 */ "ECO_AUTOVSCROLL isn't set.\n"); ok(!(ret & ECO_AUTOHSCROLL), "ECO_AUTOHSCROLL is set.\n"); ret = GetWindowLongA(hwnd, GWL_STYLE); todo_wine ok(ret & ES_AUTOVSCROLL || broken(!(ret & ES_AUTOVSCROLL)), /* Win9x, WinMe and NT4 */ "ES_AUTOVSCROLL isn't set.\n"); ok(!(ret & ES_AUTOHSCROLL), "ES_AUTOHSCROLL is set.\n"); DestroyWindow(hwnd); hwnd = CreateWindowExA(0, RICHEDIT_CLASS10A, NULL, WS_POPUP|ES_MULTILINE, 0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "class: %s, error: %d\n", RICHEDIT_CLASS10A, (int) GetLastError()); ret = SendMessageA(hwnd, EM_GETOPTIONS, 0, 0); ok(!(ret & ECO_AUTOVSCROLL), "ECO_AUTOVSCROLL is set.\n"); ok(!(ret & ECO_AUTOHSCROLL), "ECO_AUTOHSCROLL is set.\n"); ret = GetWindowLongA(hwnd, GWL_STYLE); ok(!(ret & ES_AUTOVSCROLL), "ES_AUTOVSCROLL is set.\n"); ok(!(ret & ES_AUTOHSCROLL), "ES_AUTOHSCROLL is set.\n"); DestroyWindow(hwnd); }
void MCStack::sethints() { if (!opened || MCnoui || window == DNULL) return; if (flags & F_RESIZABLE) { rect.width = MCU_max(minwidth, rect.width); rect.width = MCU_min(maxwidth, rect.width); rect.height = MCU_max(minheight, rect.height); rect.height = MCU_min(maxheight, rect.height); } MCStack *sptr = MCdefaultstackptr == this ? MCtopstackptr : MCdefaultstackptr; if (sptr != NULL && sptr != this && sptr->getw() != DNULL && GetWindowLongA((HWND)window->handle.window, 0) == 0) SetWindowLongA((HWND)window->handle.window, 0, (LONG)sptr->getw()->handle.window); }
/*********************************************************************** * ICONTITLE_Create */ HWND ICONTITLE_Create( HWND owner ) { HWND hWnd; HINSTANCE instance = (HINSTANCE)GetWindowLongPtrA( owner, GWLP_HINSTANCE ); LONG style = WS_CLIPSIBLINGS; if (!IsWindowEnabled(owner)) style |= WS_DISABLED; if( GetWindowLongA( owner, GWL_STYLE ) & WS_CHILD ) hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_ATOM, NULL, style | WS_CHILD, 0, 0, 1, 1, GetParent(owner), 0, instance, NULL ); else hWnd = CreateWindowExA( 0, ICONTITLE_CLASS_ATOM, NULL, style, 0, 0, 1, 1, owner, 0, instance, NULL ); WIN_SetOwner( hWnd, owner ); /* MDI depends on this */ SetWindowLongW( hWnd, GWL_STYLE, GetWindowLongW( hWnd, GWL_STYLE ) & ~(WS_CAPTION | WS_BORDER) ); return hWnd; }
//-------------------------------------------------------------------------- void WindowsVideoDevice::_SetWindowBordered(VeWindow::Data* pkWindow, VE_BOOL bBordered) noexcept { VE_ASSERT(pkWindow); HWND hWnd = ((VeWindowData*)pkWindow->m_spDriverdata)->m_hWnd; DWORD dwStyle = GetWindowLongA(hWnd, GWL_STYLE); if (bBordered) { dwStyle &= ~STYLE_BORDERLESS; dwStyle |= STYLE_NORMAL; } else { dwStyle &= ~STYLE_NORMAL; dwStyle |= STYLE_BORDERLESS; } SetWindowLongA(hWnd, GWL_STYLE, dwStyle); SetWindowPositionInternal(pkWindow, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOREPOSITION | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); }
static void test_title(void) { HPROPSHEETPAGE hpsp[1]; PROPSHEETPAGEA psp; PROPSHEETHEADERA psh; HWND hdlg; DWORD style; memset(&psp, 0, sizeof(psp)); psp.dwSize = sizeof(psp); psp.dwFlags = 0; psp.hInstance = GetModuleHandleA(NULL); U(psp).pszTemplate = "prop_page1"; U2(psp).pszIcon = NULL; psp.pfnDlgProc = page_dlg_proc; psp.lParam = 0; hpsp[0] = CreatePropertySheetPageA(&psp); memset(&psh, 0, sizeof(psh)); psh.dwSize = PROPSHEETHEADERA_V1_SIZE; psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK; psh.pszCaption = "test caption"; psh.nPages = 1; psh.hwndParent = GetDesktopWindow(); U3(psh).phpage = hpsp; psh.pfnCallback = sheet_callback; hdlg = (HWND)PropertySheetA(&psh); ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle value %p\n", hdlg); style = GetWindowLongA(hdlg, GWL_STYLE); ok(style == (WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CAPTION|WS_SYSMENU| DS_CONTEXTHELP|DS_MODALFRAME|DS_SETFONT|DS_3DLOOK), "got unexpected style: %x\n", style); DestroyWindow(hdlg); }
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 */ g_wndproc_saved = (WNDPROC) SetWindowLongPtrA( g_hMainWnd, GWLP_WNDPROC, (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); oldstyle = GetWindowLongA( g_hMainWnd, GWL_STYLE); SetWindowLongA( g_hMainWnd, GWL_STYLE, oldstyle | WS_VISIBLE); /* 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; r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)statustext); 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; r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW, (LPARAM)statustext); 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); /* and again */ g_wmdrawitm_ctr = 0; r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW, (LPARAM)statustext); 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); SetWindowLongA( g_hMainWnd, GWL_STYLE, oldstyle); SetWindowLongPtrA( g_hMainWnd, GWLP_WNDPROC, (LONG_PTR)g_wndproc_saved ); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { WNDCLASSW wc; HWND hWnd; WCHAR WindowTextW[256]; char WindowTextA[256]; wc.lpszClassName = L"UnicodeClass"; wc.lpfnWndProc = UnicodeWndProc; wc.style = 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; if (RegisterClassW(&wc) == 0) { fprintf(stderr, "RegisterClassW failed (last error 0x%lu)\n", GetLastError()); return 1; } printf("Unicode class registered, WndProc = 0x%p\n", wc.lpfnWndProc); hWnd = CreateWindowA("UnicodeClass", "Unicode Window", WS_OVERLAPPEDWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (hWnd == NULL) { fprintf(stderr, "CreateWindowA failed (last error 0x%lu)\n", GetLastError()); return 1; } printf("Window created, IsWindowUnicode returns %s\n", IsWindowUnicode(hWnd) ? "TRUE" : "FALSE"); printf("Calling GetWindowTextW\n"); if (! GetWindowTextW(hWnd, WindowTextW, sizeof(WindowTextW) / sizeof(WindowTextW[0]))) { fprintf(stderr, "GetWindowTextW failed (last error 0x%lu)\n", GetLastError()); return 1; } printf("GetWindowTextW returned Unicode string \"%S\"\n", WindowTextW); printf("Calling GetWindowTextA\n"); if (! GetWindowTextA(hWnd, WindowTextA, sizeof(WindowTextA) / sizeof(WindowTextA[0]))) { fprintf(stderr, "GetWindowTextA failed (last error 0x%lu)\n", GetLastError()); return 1; } printf("GetWindowTextA returned Ansi string \"%s\"\n", WindowTextA); printf("\n"); SavedWndProcW = (WNDPROC) GetWindowLongW(hWnd, GWL_WNDPROC); printf("GetWindowLongW returned 0x%p\n", SavedWndProcW); SavedWndProcA = (WNDPROC) GetWindowLongA(hWnd, GWL_WNDPROC); printf("GetWindowLongA returned 0x%p\n", SavedWndProcA); printf("\n"); printf("Subclassing window using SetWindowLongW, new WndProc 0x%p\n", UnicodeSubclassProc); SetWindowLongW(hWnd, GWL_WNDPROC, (LONG) UnicodeSubclassProc); printf("After subclass, IsWindowUnicode %s, WndProcA 0x%lx, WndProcW 0x%lx\n", IsWindowUnicode(hWnd) ? "TRUE" : "FALSE", GetWindowLongA(hWnd, GWL_WNDPROC), GetWindowLongW(hWnd, GWL_WNDPROC)); printf("Calling GetWindowTextW\n"); if (! GetWindowTextW(hWnd, WindowTextW, sizeof(WindowTextW) / sizeof(WindowTextW[0]))) { fprintf(stderr, "GetWindowTextW failed (last error 0x%lu)\n", GetLastError()); return 1; } printf("GetWindowTextW returned Unicode string \"%S\"\n", WindowTextW); printf("\n"); printf("Subclassing window using SetWindowLongA, new WndProc 0x%p\n", AnsiSubclassProc); SetWindowLongA(hWnd, GWL_WNDPROC, (LONG) AnsiSubclassProc); printf("After subclass, IsWindowUnicode %s, WndProcA 0x%lx, WndProcW 0x%lx\n", IsWindowUnicode(hWnd) ? "TRUE" : "FALSE", GetWindowLongA(hWnd, GWL_WNDPROC), GetWindowLongW(hWnd, GWL_WNDPROC)); printf("Calling GetWindowTextW\n"); if (! GetWindowTextW(hWnd, WindowTextW, sizeof(WindowTextW) / sizeof(WindowTextW[0]))) { fprintf(stderr, "GetWindowTextW failed (last error 0x%lu)\n", GetLastError()); return 1; } printf("GetWindowTextW returned Unicode string \"%S\"\n", WindowTextW); DestroyWindow(hWnd); return 0; }
/* some tests designed to show that Horizontal and Vertical * window scroll bar info are not created independently */ static void scrollbar_test_default( DWORD style) { INT min, max, ret; DWORD winstyle; HWND hwnd; SCROLLINFO si = { sizeof( SCROLLINFO), SIF_TRACKPOS }; hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ok( ret || broken( !ret) /* Win 9x/ME */ , "GetScrollRange failed.\n"); /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( min == 0 && max == 0, "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style); else todo_wine ok(( min == 0 && max == 100) || broken( min == 0 && max == 0), /* Win 9x/ME */ "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); ret = GetScrollRange( hwnd, SB_HORZ, &min, &max); ok( ret || broken( !ret) /* Win 9x/ME */ , "GetScrollRange failed.\n"); /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( min == 0 && max == 0, "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style); else todo_wine ok(( min == 0 && max == 100) || broken( min == 0 && max == 0), /* Win 9x/ME */ "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* test GetScrollInfo, vist for vertical SB */ ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should fail if no H or V scroll bar styles are present. Succeed otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); else todo_wine ok( ret || broken( !ret), /* Win 9x/ME */ "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* Same for Horizontal SB */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should fail if no H or V scroll bar styles are present. Succeed otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); else todo_wine ok( ret || broken( !ret), /* Win 9x/ME */ "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* now set the Vertical Scroll range to something that could be the default value it * already has */; ret = SetScrollRange( hwnd, SB_VERT, 0, 100, FALSE); ok( ret, "SetScrollRange failed.\n"); /* and request the Horizontal range */ ret = GetScrollRange( hwnd, SB_HORZ, &min, &max); ok( ret, "GetScrollRange failed.\n"); /* now the range should be 0,100 in ALL cases */ ok( min == 0 && max == 100, "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* See what is different now for GetScrollRange */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* report the windows style */ winstyle = GetWindowLongA( hwnd, GWL_STYLE ); /* WS_VSCROLL added to the window style */ if( !(style & WS_VSCROLL)) { if (bThemeActive || style != WS_HSCROLL) todo_wine ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_VSCROLL), "unexpected style change %8lx expected %8lx\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style | WS_VSCROLL); else ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style || broken((winstyle & (WS_HSCROLL|WS_VSCROLL)) == (WS_HSCROLL|WS_VSCROLL)), /* Win 9x/ME */ "unexpected style change %8lx expected %8x\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style); } /* do the test again with H and V reversed. * Start with a clean window */ DestroyWindow( hwnd); hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); /* Set Horizontal Scroll range to something that could be the default value it * already has */; ret = SetScrollRange( hwnd, SB_HORZ, 0, 100, FALSE); ok( ret, "SetScrollRange failed.\n"); /* and request the Vertical range */ ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ok( ret, "GetScrollRange failed.\n"); /* now the range should be 0,100 in ALL cases */ ok( min == 0 && max == 100, "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* See what is different now for GetScrollRange */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* report the windows style */ winstyle = GetWindowLongA( hwnd, GWL_STYLE ); /* WS_HSCROLL added to the window style */ if( !(style & WS_HSCROLL)) { if (bThemeActive || style != WS_VSCROLL) todo_wine ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_HSCROLL), "unexpected style change %8lx expected %8lx\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style | WS_HSCROLL); else ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style || broken((winstyle & (WS_HSCROLL|WS_VSCROLL)) == (WS_HSCROLL|WS_VSCROLL)), /* Win 9x/ME */ "unexpected style change %8lx expected %8x\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style); } /* Slightly change the test to use SetScrollInfo * Start with a clean window */ DestroyWindow( hwnd); hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); /* set Horizontal position with SetScrollInfo */ si.nPos = 0; si.nMin = 11; si.nMax = 22; si.fMask |= SIF_RANGE; ret = SetScrollInfo( hwnd, SB_HORZ, &si, FALSE); ok( ret, "SetScrollInfo failed. Style is %08x\n", style); /* and request the Vertical range */ ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ok( ret, "GetScrollRange failed.\n"); /* now the range should be 0,100 in ALL cases */ ok( min == 0 && max == 100, "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* See what is different now for GetScrollRange */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* also test if the window scroll bars are enabled */ ret = EnableScrollBar( hwnd, SB_VERT, ESB_ENABLE_BOTH); ok( !ret, "Vertical window scroll bar was not enabled\n"); ret = EnableScrollBar( hwnd, SB_HORZ, ESB_ENABLE_BOTH); ok( !ret, "Horizontal window scroll bar was not enabled\n"); DestroyWindow( hwnd); /* finally, check if adding a WS_[HV]SColl style of a window makes the scroll info * available */ if( style & (WS_HSCROLL | WS_VSCROLL)) return;/* only test if not yet set */ /* Start with a clean window */ DestroyWindow( hwnd); hwnd = CreateWindowExA( 0, "static", "", WS_POPUP , 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should fail */ ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); /* add scroll styles */ winstyle = GetWindowLongA( hwnd, GWL_STYLE ); SetWindowLongW( hwnd, GWL_STYLE, winstyle | WS_VSCROLL | WS_HSCROLL); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should still fail */ ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); /* clean up */ DestroyWindow( hwnd); }
void MCScreenDC::restackwindows(HWND p_window, UINT p_message, WPARAM p_wparam, LPARAM p_lparam) { WINDOWPOS *t_info; MCStack *t_stack; _Drawable t_drawable; t_drawable . handle . window = (MCSysWindowHandle)p_window; t_drawable . type = DC_WINDOW; t_info = (WINDOWPOS *)p_lparam; t_stack = MCdispatcher -> findstackd(&t_drawable); if (t_stack != NULL && t_stack -> getflag(F_DECORATIONS) && (t_stack -> getdecorations() & WD_UTILITY) != 0) return; if ((t_info -> flags & SWP_NOZORDER) != 0 && (t_info -> flags & SWP_NOACTIVATE) != 0) return; // MW-2007-02-11: [[ Bug 3794 ]] Background windows comes to front unexpectedly if ((t_info -> flags & SWP_HIDEWINDOW) != 0) return; HWND t_after; if ((t_info -> flags & SWP_NOZORDER) != 0) t_after = HWND_TOP; else t_after = t_info -> hwndInsertAfter; if ((t_info -> flags & SWP_NOACTIVATE) == 0) { if (t_stack != NULL) MCstacks -> top(t_stack); t_after = HWND_TOP; } MCStacknode *t_node; t_node = MCstacks -> topnode(); if (t_node != NULL) { do { if (t_node -> getstack() == t_stack) break; Window t_current; if (!t_node -> getstack() -> isiconic()) t_current = t_node -> getstack() -> getwindow(); else t_current = NULL; if (t_current != NULL && IsWindowVisible((HWND)t_current -> handle . window) && (GetWindowLongA((HWND)t_current -> handle . window, GWL_EXSTYLE) & WS_EX_TOPMOST) == 0) { if ((t_info -> flags & SWP_NOACTIVATE) == 0) SetWindowPos((HWND)t_current -> handle . window, t_after, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOSENDCHANGING); t_after = (HWND)t_current -> handle . window; } t_node = t_node -> next(); } while(t_node != MCstacks -> topnode()); } if (p_window != backdrop_window && (backdrop_hard || backdrop_active || MCraisewindows)) { if (t_node != NULL && (t_node != MCstacks -> topnode() || t_stack == t_node -> getstack())) do { Window t_current; if (!t_node -> getstack() -> isiconic()) t_current = t_node -> getstack() -> getwindow(); else t_current = NULL; if (t_current != NULL && IsWindowVisible((HWND)t_current -> handle . window) && (GetWindowLongA((HWND)t_current -> handle . window, GWL_EXSTYLE) & WS_EX_TOPMOST) == 0) { UINT t_flags; if (t_node -> getstack() == t_stack) t_flags = t_info -> flags & SWP_NOACTIVATE; else t_flags = SWP_NOACTIVATE; SetWindowPos((HWND)t_current -> handle . window, t_after, 0, 0, 0, 0, t_flags | SWP_NOMOVE | SWP_NOSIZE | SWP_NOSENDCHANGING); t_after = (HWND)t_current -> handle . window; } t_node = t_node -> next(); } while(t_node != MCstacks -> topnode()); if (IsWindowVisible(backdrop_window)) SetWindowPos(backdrop_window, t_after, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOSENDCHANGING | SWP_NOOWNERZORDER); t_info -> flags |= SWP_NOACTIVATE | SWP_NOZORDER; } else { SetWindowPos(t_info -> hwnd, t_after, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOOWNERZORDER); t_info -> flags |= SWP_NOZORDER; } return; }
static void test_gettext(void) { static const CHAR testtip2A[] = "testtip\ttest2"; static const CHAR testtipA[] = "testtip"; HWND hwnd, notify; TTTOOLINFOA toolinfoA; TTTOOLINFOW toolinfoW; LRESULT r; CHAR bufA[10] = ""; WCHAR bufW[10] = { 0 }; DWORD length, style; notify = create_parent_window(); ok(notify != NULL, "Expected notification window to be created\n"); /* For bug 14790 - lpszText is NULL */ hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, 10, 10, 300, 100, NULL, NULL, NULL, 0); ok(hwnd != NULL, "failed to create tooltip wnd\n"); /* use sizeof(TTTOOLINFOA) instead of TTTOOLINFOA_V1_SIZE so that adding it fails on Win9x */ /* otherwise it crashes on the NULL lpszText */ toolinfoA.cbSize = sizeof(TTTOOLINFOA); toolinfoA.hwnd = NULL; toolinfoA.hinst = GetModuleHandleA(NULL); toolinfoA.uFlags = 0; toolinfoA.uId = 0x1234ABCD; toolinfoA.lpszText = NULL; toolinfoA.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoA.rect); r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA); ok(r, "got %ld\n", r); toolinfoA.hwnd = NULL; toolinfoA.uId = 0x1234abcd; toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); ok(!*toolinfoA.lpszText, "lpszText should be empty, got %s\n", toolinfoA.lpszText); toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); todo_wine ok(!r, "got %ld\n", r); ok(toolinfoA.lpszText == NULL, "expected NULL, got %p\n", toolinfoA.lpszText); /* NULL hinst, valid resource id for text */ toolinfoA.cbSize = sizeof(TTTOOLINFOA); toolinfoA.hwnd = NULL; toolinfoA.hinst = NULL; toolinfoA.uFlags = 0; toolinfoA.uId = 0x1233abcd; toolinfoA.lpszText = MAKEINTRESOURCEA(IDS_TBADD1); toolinfoA.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoA.rect); r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA); ok(r, "failed to add a tool\n"); toolinfoA.hwnd = NULL; toolinfoA.uId = 0x1233abcd; toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); ok(!strcmp(toolinfoA.lpszText, "abc"), "got wrong text, %s\n", toolinfoA.lpszText); toolinfoA.hinst = (HINSTANCE)0xdeadbee; r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); todo_wine ok(!r, "got %ld\n", r); ok(toolinfoA.hinst == NULL, "expected NULL, got %p\n", toolinfoA.hinst); r = SendMessageA(hwnd, TTM_DELTOOLA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); /* add another tool with text */ toolinfoA.cbSize = sizeof(TTTOOLINFOA); toolinfoA.hwnd = NULL; toolinfoA.hinst = GetModuleHandleA(NULL); toolinfoA.uFlags = 0; toolinfoA.uId = 0x1235ABCD; strcpy(bufA, testtipA); toolinfoA.lpszText = bufA; toolinfoA.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoA.rect); r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA); ok(r, "Adding the tool to the tooltip failed\n"); length = SendMessageA(hwnd, WM_GETTEXTLENGTH, 0, 0); ok(length == 0, "Expected 0, got %d\n", length); toolinfoA.hwnd = NULL; toolinfoA.uId = 0x1235abcd; toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); ok(!strcmp(toolinfoA.lpszText, testtipA), "expected %s, got %p\n", testtipA, toolinfoA.lpszText); memset(bufA, 0x1f, sizeof(bufA)); toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); todo_wine ok(!r, "got %ld\n", r); ok(!strcmp(toolinfoA.lpszText, testtipA), "expected %s, got %p\n", testtipA, toolinfoA.lpszText); length = SendMessageA(hwnd, WM_GETTEXTLENGTH, 0, 0); ok(length == 0, "Expected 0, got %d\n", length); /* add another with callback text */ toolinfoA.cbSize = sizeof(TTTOOLINFOA); toolinfoA.hwnd = notify; toolinfoA.hinst = GetModuleHandleA(NULL); toolinfoA.uFlags = 0; toolinfoA.uId = 0x1236ABCD; toolinfoA.lpszText = LPSTR_TEXTCALLBACKA; toolinfoA.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoA.rect); r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA); ok(r, "Adding the tool to the tooltip failed\n"); toolinfoA.hwnd = notify; toolinfoA.uId = 0x1236abcd; toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); ok(!strcmp(toolinfoA.lpszText, testcallbackA), "lpszText should be an (%s) string\n", testcallbackA); toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); todo_wine ok(!r, "got %ld\n", r); ok(toolinfoA.lpszText == LPSTR_TEXTCALLBACKA, "expected LPSTR_TEXTCALLBACKA, got %p\n", toolinfoA.lpszText); DestroyWindow(hwnd); DestroyWindow(notify); hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0, 10, 10, 300, 100, NULL, NULL, NULL, 0); ok(hwnd != NULL, "failed to create tooltip wnd\n"); toolinfoW.cbSize = sizeof(TTTOOLINFOW); toolinfoW.hwnd = NULL; toolinfoW.hinst = GetModuleHandleA(NULL); toolinfoW.uFlags = 0; toolinfoW.uId = 0x1234ABCD; toolinfoW.lpszText = NULL; toolinfoW.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoW.rect); r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfoW); ok(!r, "Adding the tool to the tooltip succeeded!\n"); if (0) /* crashes on NT4 */ { toolinfoW.hwnd = NULL; toolinfoW.uId = 0x1234ABCD; toolinfoW.lpszText = bufW; SendMessageW(hwnd, TTM_GETTEXTW, 0, (LPARAM)&toolinfoW); ok(toolinfoW.lpszText[0] == 0, "lpszText should be an empty string\n"); } /* text with embedded tabs */ toolinfoA.cbSize = sizeof(TTTOOLINFOA); toolinfoA.hwnd = NULL; toolinfoA.hinst = GetModuleHandleA(NULL); toolinfoA.uFlags = 0; toolinfoA.uId = 0x1235abce; strcpy(bufA, testtip2A); toolinfoA.lpszText = bufA; toolinfoA.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoA.rect); r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA); ok(r, "got %ld\n", r); toolinfoA.hwnd = NULL; toolinfoA.uId = 0x1235abce; toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); ok(!strcmp(toolinfoA.lpszText, testtipA), "expected %s, got %s\n", testtipA, toolinfoA.lpszText); /* enable TTS_NOPREFIX, original text is retained */ style = GetWindowLongA(hwnd, GWL_STYLE); SetWindowLongA(hwnd, GWL_STYLE, style | TTS_NOPREFIX); toolinfoA.hwnd = NULL; toolinfoA.uId = 0x1235abce; toolinfoA.lpszText = bufA; r = SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(!r, "got %ld\n", r); ok(!strcmp(toolinfoA.lpszText, testtip2A), "expected %s, got %s\n", testtip2A, toolinfoA.lpszText); DestroyWindow(hwnd); }
static void test_button_messages(void) { static const struct { DWORD style; DWORD dlg_code; const struct message *setfocus; const struct message *killfocus; const struct message *setstyle; const struct message *setstate; const struct message *clearstate; const struct message *setcheck; } button[] = { { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON, setfocus_seq, killfocus_seq, setstyle_seq, setstate_seq, setstate_seq, setcheck_ignored_seq }, { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON, setfocus_seq, killfocus_seq, setstyle_seq, setstate_seq, setstate_seq, setcheck_ignored_seq }, { BS_CHECKBOX, DLGC_BUTTON, setfocus_static_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_static_seq }, { BS_AUTOCHECKBOX, DLGC_BUTTON, setfocus_static_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_static_seq }, { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON, setfocus_static_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_radio_redraw_seq }, { BS_3STATE, DLGC_BUTTON, setfocus_static_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_static_seq }, { BS_AUTO3STATE, DLGC_BUTTON, setfocus_static_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_static_seq }, { BS_GROUPBOX, DLGC_STATIC, setfocus_groupbox_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_ignored_seq }, { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON, setfocus_seq, killfocus_seq, setstyle_user_seq, setstate_user_seq, clearstate_seq, setcheck_ignored_seq }, { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON, setfocus_static_seq, killfocus_static_seq, setstyle_static_seq, setstate_static_seq, setstate_static_seq, setcheck_radio_redraw_seq }, { BS_OWNERDRAW, DLGC_BUTTON, setfocus_ownerdraw_seq, killfocus_ownerdraw_seq, setstyle_ownerdraw_seq, setstate_ownerdraw_seq, clearstate_ownerdraw_seq, setcheck_ignored_seq }, }; const struct message *seq; unsigned int i; HWND hwnd, parent; DWORD dlg_code; HFONT zfont; BOOL todo; /* selection with VK_SPACE should capture button window */ hwnd = create_button(BS_CHECKBOX | WS_VISIBLE | WS_POPUP, NULL); ok(hwnd != 0, "Failed to create button window\n"); ReleaseCapture(); SetFocus(hwnd); SendMessageA(hwnd, WM_KEYDOWN, VK_SPACE, 0); ok(GetCapture() == hwnd, "Should be captured on VK_SPACE WM_KEYDOWN\n"); SendMessageA(hwnd, WM_KEYUP, VK_SPACE, 0); DestroyWindow(hwnd); parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, 0, NULL); ok(parent != 0, "Failed to create parent window\n"); for (i = 0; i < sizeof(button)/sizeof(button[0]); i++) { MSG msg; DWORD style, state; trace("%d: button test sequence\n", i); hwnd = create_button(button[i].style, parent); style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_CHILD | BS_NOTIFY); /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */ if (button[i].style == BS_USERBUTTON) ok(style == BS_PUSHBUTTON, "expected style BS_PUSHBUTTON got %x\n", style); else ok(style == button[i].style, "expected style %x got %x\n", button[i].style, style); dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0); ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); SetFocus(0); flush_events(); SetFocus(0); flush_sequences(sequences, NUM_MSG_SEQUENCES); todo = button[i].style != BS_OWNERDRAW; ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus()); SetFocus(hwnd); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setfocus, "SetFocus(hwnd) on a button", todo); todo = button[i].style == BS_OWNERDRAW; SetFocus(0); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].killfocus, "SetFocus(0) on a button", todo); ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus()); SendMessageA(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstyle, "BM_SETSTYLE on a button", TRUE); style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_VISIBLE | WS_CHILD | BS_NOTIFY); /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */ ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style); state = SendMessageA(hwnd, BM_GETSTATE, 0, 0); ok(state == 0, "expected state 0, got %04x\n", state); flush_sequences(sequences, NUM_MSG_SEQUENCES); SendMessageA(hwnd, BM_SETSTATE, TRUE, 0); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstate, "BM_SETSTATE/TRUE on a button", TRUE); state = SendMessageA(hwnd, BM_GETSTATE, 0, 0); ok(state == BST_PUSHED, "expected state 0x0004, got %04x\n", state); style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE); ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style); flush_sequences(sequences, NUM_MSG_SEQUENCES); SendMessageA(hwnd, BM_SETSTATE, FALSE, 0); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].clearstate, "BM_SETSTATE/FALSE on a button", TRUE); state = SendMessageA(hwnd, BM_GETSTATE, 0, 0); ok(state == 0, "expected state 0, got %04x\n", state); style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE); ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style); state = SendMessageA(hwnd, BM_GETCHECK, 0, 0); ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state); flush_sequences(sequences, NUM_MSG_SEQUENCES); if (button[i].style == BS_RADIOBUTTON || button[i].style == BS_AUTORADIOBUTTON) { seq = setcheck_radio_seq; todo = TRUE; } else { seq = setcheck_ignored_seq; todo = FALSE; } SendMessageA(hwnd, BM_SETCHECK, BST_UNCHECKED, 0); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); ok_sequence(sequences, COMBINED_SEQ_INDEX, seq, "BM_SETCHECK on a button", todo); state = SendMessageA(hwnd, BM_GETCHECK, 0, 0); ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state); style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE); ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style); flush_sequences(sequences, NUM_MSG_SEQUENCES); SendMessageA(hwnd, BM_SETCHECK, BST_CHECKED, 0); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); if (button[i].style == BS_PUSHBUTTON || button[i].style == BS_DEFPUSHBUTTON || button[i].style == BS_GROUPBOX || button[i].style == BS_USERBUTTON || button[i].style == BS_OWNERDRAW) { ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setcheck, "BM_SETCHECK on a button", FALSE); state = SendMessageA(hwnd, BM_GETCHECK, 0, 0); ok(state == BST_UNCHECKED, "expected check BST_UNCHECKED, got %04x\n", state); } else { ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setcheck, "BM_SETCHECK on a button", TRUE); state = SendMessageA(hwnd, BM_GETCHECK, 0, 0); ok(state == BST_CHECKED, "expected check BST_CHECKED, got %04x\n", state); } style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE); if (button[i].style == BS_RADIOBUTTON || button[i].style == BS_AUTORADIOBUTTON) ok(style == (button[i].style | WS_TABSTOP), "expected style %04x | WS_TABSTOP got %04x\n", button[i].style, style); else ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style); DestroyWindow(hwnd); } DestroyWindow(parent); hwnd = create_button(BS_PUSHBUTTON, NULL); SetForegroundWindow(hwnd); flush_events(); SetActiveWindow(hwnd); SetFocus(0); flush_sequences(sequences, NUM_MSG_SEQUENCES); SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0); ok_sequence(sequences, COMBINED_SEQ_INDEX, lbuttondown_seq, "WM_LBUTTONDOWN on a button", FALSE); SendMessageA(hwnd, WM_LBUTTONUP, 0, 0); ok_sequence(sequences, COMBINED_SEQ_INDEX, lbuttonup_seq, "WM_LBUTTONUP on a button", TRUE); flush_sequences(sequences, NUM_MSG_SEQUENCES); zfont = GetStockObject(SYSTEM_FONT); SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE); UpdateWindow(hwnd); ok_sequence(sequences, COMBINED_SEQ_INDEX, setfont_seq, "WM_SETFONT on a button", FALSE); DestroyWindow(hwnd); }
/****************************************************************** * WDML_ServerNameProc * * */ static LRESULT CALLBACK WDML_ServerNameProc(HWND hwndServer, UINT iMsg, WPARAM wParam, LPARAM lParam) { HWND hwndClient; HSZ hszApp, hszTop; HDDEDATA hDdeData = 0; WDML_INSTANCE* pInstance; UINT uiLo, uiHi; switch (iMsg) { case WM_DDE_INITIATE: /* wParam -- sending window handle LOWORD(lParam) -- application atom HIWORD(lParam) -- topic atom */ TRACE("WM_DDE_INITIATE message received!\n"); hwndClient = (HWND)wParam; pInstance = WDML_GetInstanceFromWnd(hwndServer); TRACE("idInst=%ld, threadID=0x%lx\n", pInstance->instanceID, GetCurrentThreadId()); if (!pInstance) return 0; /* don't free DDEParams, since this is a broadcast */ UnpackDDElParam(WM_DDE_INITIATE, lParam, &uiLo, &uiHi); hszApp = WDML_MakeHszFromAtom(pInstance, uiLo); hszTop = WDML_MakeHszFromAtom(pInstance, uiHi); if (!(pInstance->CBFflags & CBF_FAIL_CONNECTIONS)) { BOOL self = FALSE; CONVCONTEXT cc; CONVCONTEXT* pcc = NULL; WDML_CONV* pConv; char buf[256]; if (GetWindowThreadProcessId(hwndClient, NULL) == GetWindowThreadProcessId(hwndServer, NULL) && WDML_GetInstanceFromWnd(hwndClient) == WDML_GetInstanceFromWnd(hwndServer)) { self = TRUE; } /* FIXME: so far, we don't grab distant convcontext, so only check if remote is * handled under DDEML, and if so build a default context */ if ((GetClassNameA(hwndClient, buf, sizeof(buf)) && strcmp(buf, WDML_szClientConvClassA) == 0) || (GetClassNameW(hwndClient, (LPWSTR)buf, sizeof(buf)/sizeof(WCHAR)) && lstrcmpW((LPWSTR)buf, WDML_szClientConvClassW) == 0)) { pcc = &cc; memset(pcc, 0, sizeof(*pcc)); pcc->cb = sizeof(*pcc); pcc->iCodePage = IsWindowUnicode(hwndClient) ? CP_WINUNICODE : CP_WINANSI; } if ((pInstance->CBFflags & CBF_FAIL_SELFCONNECTIONS) && self) { TRACE("Don't do self connection as requested\n"); } else if (hszApp && hszTop) { WDML_SERVER* pServer = (WDML_SERVER*)GetWindowLongA(hwndServer, GWL_WDML_SERVER); /* check filters for name service */ if (!pServer->filterOn || DdeCmpStringHandles(pServer->hszService, hszApp) == 0) { /* pass on to the callback */ hDdeData = WDML_InvokeCallback(pInstance, XTYP_CONNECT, 0, 0, hszTop, hszApp, 0, (DWORD)pcc, self); if ((UINT)hDdeData) { pConv = WDML_CreateServerConv(pInstance, hwndClient, hwndServer, hszApp, hszTop); if (pConv && pcc) pConv->wStatus |= ST_ISLOCAL; } } } else if (pInstance->servers) { /* pass on to the callback */ hDdeData = WDML_InvokeCallback(pInstance, XTYP_WILDCONNECT, 0, 0, hszTop, hszApp, 0, (DWORD)pcc, self); if (hDdeData == (HDDEDATA)CBR_BLOCK) { /* MS doc is not consistent here */ FIXME("CBR_BLOCK returned for WILDCONNECT\n"); } else if ((UINT)hDdeData != 0) { HSZPAIR* hszp; hszp = (HSZPAIR*)DdeAccessData(hDdeData, NULL); if (hszp) { int i; for (i = 0; hszp[i].hszSvc && hszp[i].hszTopic; i++) { pConv = WDML_CreateServerConv(pInstance, hwndClient, hwndServer, hszp[i].hszSvc, hszp[i].hszTopic); if (pConv && pcc) pConv->wStatus |= ST_ISLOCAL; } DdeUnaccessData(hDdeData); } if (!WDML_IsAppOwned(hDdeData)) DdeFreeDataHandle(hDdeData); } } } return 0; case WM_DDE_REQUEST: FIXME("WM_DDE_REQUEST message received!\n"); return 0; case WM_DDE_ADVISE: FIXME("WM_DDE_ADVISE message received!\n"); return 0; case WM_DDE_UNADVISE: FIXME("WM_DDE_UNADVISE message received!\n"); return 0; case WM_DDE_EXECUTE: FIXME("WM_DDE_EXECUTE message received!\n"); return 0; case WM_DDE_POKE: FIXME("WM_DDE_POKE message received!\n"); return 0; case WM_DDE_TERMINATE: FIXME("WM_DDE_TERMINATE message received!\n"); return 0; } return DefWindowProcA(hwndServer, iMsg, wParam, lParam); }
bool MainWindow::eventFilter(QObject *o, QEvent *e) { #ifdef WIN32 if (o->inherits("QSizeGrip")){ QSizeGrip *grip = static_cast<QSizeGrip*>(o); QMouseEvent *me; switch (e->type()){ case QEvent::MouseButtonPress: me = static_cast<QMouseEvent*>(e); p = me->globalPos(); s = grip->topLevelWidget()->size(); return true; case QEvent::MouseMove: me = static_cast<QMouseEvent*>(e); if (me->state() != LeftButton) break; QWidget *tlw = grip->topLevelWidget(); QRect rc = tlw->geometry(); if (tlw->testWState(WState_ConfigPending)) break; QPoint np(me->globalPos()); int w = np.x() - p.x() + s.width(); int h = np.y() - p.y() + s.height(); if ( w < 1 ) w = 1; if ( h < 1 ) h = 1; QSize ms(tlw->minimumSizeHint()); ms = ms.expandedTo(minimumSize()); if (w < ms.width()) w = ms.width(); if (h < ms.height()) h = ms.height(); if (!(GetWindowLongA(tlw->winId(), GWL_EXSTYLE) & WS_EX_APPWINDOW)){ int dc = GetSystemMetrics(SM_CYCAPTION); int ds = GetSystemMetrics(SM_CYSMCAPTION); tlw->setGeometry(rc.left(), rc.top() + dc - ds, w, h); }else{ tlw->resize(w, h); } MSG msg; while (PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)); return true; } } if (e->type() == QEvent::ChildInserted){ QChildEvent *ce = static_cast<QChildEvent*>(e); if (ce->child()->inherits("QSizeGrip")) ce->child()->installEventFilter(this); } #endif if (e->type() == QEvent::ChildRemoved){ QChildEvent *ce = static_cast<QChildEvent*>(e); list<QWidget*>::iterator it; for (it = statusWidgets.begin(); it != statusWidgets.end(); ++it){ if (*it == ce->child()){ statusWidgets.erase(it); break; } } if (statusWidgets.size() == 0){ statusBar()->hide(); setGrip(); } } return QMainWindow::eventFilter(o, e); }
static void test_layout(void) { HWND hRebar; REBARBANDINFOA rbi; HIMAGELIST himl; REBARINFO ri; rbsize_results_init(); hRebar = create_rebar_control(); check_sizes(); rbi.cbSize = REBARBANDINFOA_V6_SIZE; rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD; rbi.cx = 200; rbi.cxMinChild = 100; rbi.cyMinChild = 30; rbi.hwndChild = NULL; SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); rbi.fMask |= RBBIM_STYLE; rbi.fStyle = RBBS_CHILDEDGE; SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); rbi.fStyle = 0; rbi.cx = 200; rbi.cxMinChild = 30; rbi.cyMinChild = 30; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); rbi.fStyle = RBBS_CHILDEDGE; rbi.cx = 68; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_BANDBORDERS); check_sizes(); /* a style change won't start a relayout */ rbi.fMask = RBBIM_SIZE; rbi.cx = 66; SendMessageA(hRebar, RB_SETBANDINFOA, 3, (LPARAM)&rbi); check_sizes(); /* here it will be relayouted */ /* this will force a new row */ rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD; rbi.cx = 200; rbi.cxMinChild = 400; rbi.cyMinChild = 30; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rbi); check_sizes(); rbi.fMask = RBBIM_STYLE; rbi.fStyle = RBBS_HIDDEN; SendMessageA(hRebar, RB_SETBANDINFOA, 2, (LPARAM)&rbi); check_sizes(); SendMessageA(hRebar, RB_DELETEBAND, 2, 0); check_sizes(); SendMessageA(hRebar, RB_DELETEBAND, 0, 0); check_sizes(); SendMessageA(hRebar, RB_DELETEBAND, 1, 0); check_sizes(); DestroyWindow(hRebar); hRebar = create_rebar_control(); add_band_w(hRebar, "ABC", 70, 40, 100); add_band_w(hRebar, NULL, 40, 70, 100); add_band_w(hRebar, NULL, 170, 240, 100); add_band_w(hRebar, "MMMMMMM", 60, 60, 100); add_band_w(hRebar, NULL, 200, 200, 100); check_sizes(); SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE); check_sizes(); SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE); check_sizes(); SendMessageA(hRebar, RB_MAXIMIZEBAND, 2, FALSE); check_sizes(); SendMessageA(hRebar, RB_MINIMIZEBAND, 2, 0); check_sizes(); SendMessageA(hRebar, RB_MINIMIZEBAND, 0, 0); check_sizes(); /* an image will increase the band height */ himl = ImageList_LoadImageA(GetModuleHandleA("comctl32"), MAKEINTRESOURCEA(121), 24, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR); ri.cbSize = sizeof(ri); ri.fMask = RBIM_IMAGELIST; ri.himl = himl; ok(SendMessageA(hRebar, RB_SETBARINFO, 0, (LPARAM)&ri), "RB_SETBARINFO failed\n"); rbi.fMask = RBBIM_IMAGE; rbi.iImage = 1; SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi); check_sizes(); /* after removing it everything is back to normal*/ rbi.iImage = -1; SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi); check_sizes(); /* Only -1 means that the image is not present. Other invalid values increase the height */ rbi.iImage = -2; SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi); check_sizes(); DestroyWindow(hRebar); /* VARHEIGHT resizing test on a horizontal rebar */ hRebar = create_rebar_control(); SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_AUTOSIZE); check_sizes(); rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE; rbi.fStyle = RBBS_VARIABLEHEIGHT; rbi.cxMinChild = 50; rbi.cyMinChild = 10; rbi.cyIntegral = 11; rbi.cyChild = 70; rbi.cyMaxChild = 200; rbi.cx = 90; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); rbi.cyChild = 50; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); rbi.cyMinChild = 40; rbi.cyChild = 50; rbi.cyIntegral = 5; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); DestroyWindow(hRebar); /* VARHEIGHT resizing on a vertical rebar */ hRebar = create_rebar_control(); SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | CCS_VERT | RBS_AUTOSIZE); check_sizes(); rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE; rbi.fStyle = RBBS_VARIABLEHEIGHT; rbi.cxMinChild = 50; rbi.cyMinChild = 10; rbi.cyIntegral = 11; rbi.cyChild = 70; rbi.cyMaxChild = 90; rbi.cx = 90; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); rbi.cyChild = 50; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); rbi.cyMinChild = 40; rbi.cyChild = 50; rbi.cyIntegral = 5; rbi.hwndChild = build_toolbar(0, hRebar); SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi); check_sizes(); rbsize_results_free(); DestroyWindow(hRebar); ImageList_Destroy(himl); }