Exemple #1
0
/*
 * DlgProcYahooOpts - Connection Options Dialog
 */
static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	YList *l;
	CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );

	switch ( msg ) {
	case WM_INITDIALOG:
		TranslateDialogDefault( hwndDlg );

		ppro = ( CYahooProto* )lParam;
		SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );

		if ( ppro->GetByte( "IgnoreUnknown", 0 )) {
			CheckDlgButton(hwndDlg, IDC_OPT_IGN_UNKNOWN, 1);

			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), 0);
			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), 0);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), 0);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), 0);
		}
		else CheckDlgButton(hwndDlg, IDC_OPT_IGN_LIST, 1);

		/* show our current ignore list */
		LOG(("[DlgProcYahooOptsIgnore] Grabbing current ignore list..."))
		l = (YList *)ppro->GetIgnoreList();
		while (l != NULL) {
			struct yahoo_buddy *b = (struct yahoo_buddy *) l->data;

			LOG(("[DlgProcYahooOptsIgnore] Buddy: %s", b->id ))
			SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)b->id);
			l = l->next;
		}
		LOG(("[DlgProcYahooOptsIgnore] End of Ignore List..."))
		
		return TRUE;

	case WM_COMMAND:
		switch ( LOWORD( wParam )) {
		case IDC_OPT_IGN_UNKNOWN:
		case IDC_OPT_IGN_LIST:
			if (( HWND )lParam != GetFocus()) return 0;

			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
			EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), LOWORD( wParam ) == IDC_OPT_IGN_LIST);
			EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), LOWORD( wParam ) == IDC_OPT_IGN_LIST);

			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_IGN_ADD: 
			if (!ppro->m_bLoggedIn)
				MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to add to Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
			else {
				char id[128];
				int i = GetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, id, sizeof( id ));

				if (i < 3) {
					MessageBoxA(hwndDlg, Translate("Please enter a valid buddy name to ignore."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
					break;
				}

				i = SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_FINDSTRINGEXACT,(WPARAM) -1, (LPARAM)id);
				if (i != LB_ERR ) {
					MessageBoxA(hwndDlg, Translate("The buddy is already on your ignore list. "), Translate("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION);
					break;
				}
				ppro->IgnoreBuddy(id, 0);
				SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)id);
				SetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, "" );
			}
			break;

		case IDC_IGN_REMOVE:
			{
				int i;
				char id[128];

				if (!ppro->m_bLoggedIn) {
					MessageBoxA(hwndDlg, Translate("You need to be connected to Yahoo to remove from the Ignore List."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
					break;
				}

				i = SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETCURSEL, 0, 0);
				if (i == LB_ERR) {
					MessageBoxA(hwndDlg, Translate("Please select a buddy on the ignore list to remove."), Translate("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION);
					break;
				}

				SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_GETTEXT, i, (LPARAM)id);

				ppro->IgnoreBuddy(id, 1);
				SendMessage(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_DELETESTRING, i, 0);
			}	
		}
		break;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
			ppro->SetByte("IgnoreUnknown", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_OPT_IGN_UNKNOWN ));
			return TRUE;
		}
		break;
	}

	return FALSE;
}
Exemple #2
0
// ---------------------------------------------------------------------------
// CWinMenubar::AboutProc()
// Dialog Window proc for About dialog
// ---------------------------------------------------------------------------
BOOL CALLBACK CWinMenubar::AboutProc(HWND hDlg, UINT message, 
                                     WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam); // unless SDK_REGISTRATION is defined
    switch (message) 
    {
    case WM_INITDIALOG:
        {
        TCHAR text[128];
        CWinMenubar* menubar = (CWinMenubar*)lParam;
        HINSTANCE hMod = menubar->ModuleHandle();
        GetWindowText(GetParent(hDlg), text, sizeof(text)/sizeof(text[0]));
        SetWindowText(hDlg, text);

        HBITMAP hBitmap = NULL;
        UINT textScrollID = IDC_ABOUT_TEXT_SCROLL;
        UINT textNoScrollID = IDC_ABOUT_TEXT_NO_SCROLL;
        UINT setTextMsg = WM_SETTEXT;
        WPARAM setTextParam = 0;
        SETTEXTEX setText;
        setText.flags = ST_SELECTION;
        setText.codepage = CP_ACP;

        char* aboutText = NULL;
        if (menubar->iRichEdit)
        {
            aboutText = ReadTextFile(ABOUTBOX_RTF_FILE);
        }
        if (aboutText)
        {
            setTextMsg = EM_SETTEXTEX;
            textScrollID = textNoScrollID = IDC_ABOUT_RICHTEXT;
            setTextParam = (WPARAM)&setText;
            hBitmap = LoadBitmap(hMod,MAKEINTRESOURCE(IDB_JAVA_POWERED));

#ifdef HAVE_WLIB

            HWND hText = GetDlgItem(hDlg, IDC_ABOUT_RICHTEXT);
            SendMessage(hText, EM_SETEVENTMASK, 0, 
            SendMessage(hText, EM_GETEVENTMASK, 0,0) | ENM_LINK);
            SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0);

#endif // HAVE_WLIB

        }

        if (!aboutText && menubar->iRichEdit)
        {
            // Load default about text from the resource
            void* ptr = NULL;
            UINT size = 0;
            HGLOBAL hg = 0;
            HRSRC hr = FindResourceA(hMod,MAKEINTRESOURCEA(IDR_ABOUT_RTF),"RTF");
            if (hr)
            {
                size = SizeofResource(ModuleHandle(), hr);
                hg = LoadResource(ModuleHandle(), hr);
                ptr = LockResource(hg);
            }
            if (ptr)
            {
                aboutText = (char*)Alloc(size+1);
                if (aboutText)
                {
                    memcpy(aboutText, ptr, size);
                    aboutText[size] = 0;
                    setTextMsg = EM_SETTEXTEX;
                    textScrollID = IDC_ABOUT_RICHTEXT;
                    textNoScrollID = IDC_ABOUT_RICHTEXT;
                    hBitmap = LoadBitmap(hMod,MAKEINTRESOURCE(IDB_JAVA_POWERED));
                    setTextParam = (WPARAM)&setText;
                }
                UnlockResource(hg);
            }
        }
        if (aboutText)
        {   
            // Check if we need the scrollbar. 12 lines of text
            // will fit into the edit control.
            HWND hText = GetDlgItem(hDlg, textNoScrollID);
            SendMessageA(hText,setTextMsg,setTextParam,(LPARAM)aboutText);
            if (SendMessageA(hText, EM_GETLINECOUNT,0,0) <= 12)
            {
                // No need for the scrollbar, show the edit
                // control without the WS_VSCROLL style
                ShowWindow(hText, SW_SHOWNORMAL);
            }
            else 
            {
                // We need the vertical scrollbar, show the edit control
                // with the WS_VSCROLL style. Note that  textScrollID and
                // textNoScrollID may point to the same window, so reset
                // the text in the control (bug #DPEV-6JUJSQ)
                hText = GetDlgItem(hDlg, textScrollID);
                SendMessageA(hText,WM_SETTEXT,0,(LPARAM)"");
                SendMessageA(hText,setTextMsg,setTextParam,(LPARAM)aboutText);
                ShowWindow(hText, SW_SHOWNORMAL);
            }            
            
            // Add full SDK name to the RichEdit control by replacing <sdk_name> tag with the 
            // name defined in SdkProductInfo.h. Note that decision between MIDP and C++ SDK 
            // product names is made using CWinMenubar iMidpSdk member.
            static const TCHAR keywordHeading[] = TEXT("<sdk_name>");
            static const UINT keywordHeadingLen = COUNT(keywordHeading)-1;
            
            FINDTEXT findHeading;
            ZeroMemory(&findHeading, sizeof(findHeading));
            findHeading.chrg.cpMax = -1;
            findHeading.lpstrText = (LPTSTR)keywordHeading;
            // Select whole content
            SendMessage(hText, EM_SETSEL, 0, 0);
            // Find from selection
            int pos = SendMessage(hText,EM_FINDTEXT, FR_MATCHCASE|FR_DOWN,
                (LPARAM)&findHeading);
            if (pos >= 0) {       
                // Sdk name tag found         
                IRichEditOle* re = NULL;
                SendMessage(hText, EM_GETOLEINTERFACE, 0, (LPARAM)&re);
                if (re) {
                    // Select SDK name tag and replace it with the full SDK name
                    SendMessage(hText, EM_SETSEL, pos, pos+keywordHeadingLen);
                    if(menubar->iMidpSDK)
                        SendMessage(hText, EM_REPLACESEL, true, (LPARAM)TEXT(SDK_FULL_PRODUCT_NAME_MIDP));
                    else
                        SendMessage(hText, EM_REPLACESEL, true, (LPARAM)TEXT(SDK_FULL_PRODUCT_NAME_CPP));
                    re->Release();
                }
            }
            
            if (hBitmap)
            {
                static const TCHAR keyword[] = TEXT("<java logo>");
                static const UINT keywordLen = COUNT(keyword)-1;

                FINDTEXT find;
                ZeroMemory(&find, sizeof(find));
                find.chrg.cpMax = -1;
                find.lpstrText = (LPTSTR)keyword;
                SendMessage(hText, EM_SETSEL, 0, 0);
                int pos = SendMessage(hText,EM_FINDTEXT, FR_MATCHCASE|FR_DOWN,
                    (LPARAM)&find);
                if (pos >= 0) {
                    IRichEditOle* re = NULL;
                    SendMessage(hText, EM_GETOLEINTERFACE, 0, (LPARAM)&re);
                    if (re) {
                        CImageDataObject* bmp = new CImageDataObject(hBitmap);
                        if (bmp) {
                            SendMessage(hText,EM_SETSEL,pos,pos+keywordLen);
                            bmp->Insert(re);
                            bmp->Release();
                        }
                        re->Release();
                    }
                }
            }
            Free(aboutText);
        }

#ifdef SDK_REGISTRATION

        // Show product key
        if (gRegProductContext)
        {
            HWND hProductKey = GetDlgItem(hDlg, IDC_PRODUCT_KEY);
            const char* szKey = REG_ProductKey(gRegProductContext);
            SetWindowTextA(hProductKey, szKey);
            // The control is created invisible, show it
            ShowWindow(hProductKey, SW_SHOWNORMAL);
            if (REG_ProductStatus(gRegProductContext) != RegRegistered)
            {
                // Show the Register button
                ShowWindow(GetDlgItem(hDlg, IDC_REGISTER), SW_SHOWNORMAL);
            }
        }
                    
#endif // SDK_REGISTRATION

        // Subclass the product name control
        HWND hName = GetDlgItem(hDlg, IDC_PRODUCT_NAME);
        HINSTANCE hInst = (HINSTANCE)GetWindowLong(hDlg,GWL_HINSTANCE);
        if (hName)
        {
            // Allocate TitleData structure. It will be deallocated
            // by TitleWndProc when it receives WM_DESTROY message
            TitleData* data = (TitleData*)malloc(sizeof(TitleData));
            if (data)
            {
                LOGFONTA logFont;
                ZeroMemory(data, sizeof(*data));
                ZeroMemory(&logFont, sizeof(logFont));
                logFont.lfHeight = 24;
                logFont.lfWeight = FW_BOLD;
                logFont.lfCharSet = ANSI_CHARSET;
                logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
                logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
                logFont.lfQuality = ANTIALIASED_QUALITY;
                logFont.lfPitchAndFamily = VARIABLE_PITCH;

                // Try Nokia font first
                strcpy(logFont.lfFaceName, "Nokia Sans");
                data->hFont = CreateFontIndirectA(&logFont);
                if (!data->hFont)
                {
                    // No Nokia font, try Arial then
                    strcpy(logFont.lfFaceName, "Arial");
                    data->hFont = CreateFontIndirectA(&logFont);
                }
                
                // Load bitmaps
                data->hBitmap = LoadBitmapA(hInst, 
                    MAKEINTRESOURCEA(IDB_ABOUT_TOP));

                // load product name from the file
                data->productName = ReadTextFile(PRODUCTNAME_FILE);
                data->productId = menubar->GetProductId();

                // Request initial bitmap
                data->bRepaint = TRUE;

#ifdef SDK_REGISTRATION

                data->hGradientBitmap = LoadBitmapA(hInst, 
                    MAKEINTRESOURCEA(IDB_ABOUT_GRADIENT));

                if (gRegProductContext)
                {
                    data->scrollText = TitleCreateScrollData(hName,
                        gRegProductContext);
                    if (data->scrollText)
                    {
                        // Initial delay
                        SetTimer(hName, SCROLL_DELAY_TIMER, 
                            SCROLL_TIMER_DELAY, NULL);
                    }
                }
#endif // SDK_REGISTRATION
        
                // Subclass the window
                data->superProc = (WNDPROC)GetWindowLong(hName,GWL_WNDPROC);
                SetWindowLong(hName, GWL_USERDATA, (LONG)data);
                SetWindowLong(hName, GWL_WNDPROC, (LONG)TitleWndProc);
            }
        }

#ifdef HAVE_WLIB
        WIN32_CenterWindow(hDlg, NULL);
#endif // HAVE_WLIB
        return TRUE;
        }
        
    case WM_COMMAND:
        switch (wParam)
        {

#ifdef SDK_REGISTRATION

        case IDC_REGISTER:
            if (REG_RegisterNow(gRegProductContext, hDlg))
            {
                TitleStopScroller(hDlg);

                // Update the scroller
                HWND hTitle = GetDlgItem(hDlg, IDC_PRODUCT_NAME);
                ScrollTextData* scroll = TitleCreateScrollData(
                    hTitle, gRegProductContext);

                if (scroll)
                {
                    TitleData* data;
                    data = (TitleData*)GetWindowLong(hTitle,GWL_USERDATA);
                    TitleDeleteScrollData(data->scrollText);
                    data->scrollText = scroll;
                }
            }
            if (REG_ProductStatus(gRegProductContext) == RegRegistered)
            {
                // The button has served its purpose. Hide it
                ShowWindow(GetDlgItem(hDlg, IDC_REGISTER), SW_HIDE);
            }
            return TRUE;

#endif // SDK_REGISTRATION

        case IDOK:
        case IDCANCEL:
            EndDialog(hDlg, wParam);
            return TRUE;
        default:
            return FALSE;
        }

#ifdef HAVE_WLIB // Need wlib to use WIN32_BrowseURL

    case WM_NOTIFY:
        if (((LPNMHDR)lParam)->idFrom == IDC_ABOUT_RICHTEXT)
        {
            char url[256];
            ENLINK* link = (ENLINK*)lParam;
            if (link->msg == WM_LBUTTONDOWN &&
                (link->chrg.cpMax - link->chrg.cpMin) <
                (COUNT(url)/2-1)) // EM_GETTEXTRANGE may think it's in WCHARs
            {
                // Visual effect
                HWND hText = link->nmhdr.hwndFrom;
                SendMessage(hText,EM_SETSEL,link->chrg.cpMin,link->chrg.cpMax);

                // It's not very clear what EM_GETTEXTRANGE message writes
                // into the buffer. Since we use SendMessageA (ANSI API),
                // I would expect that it returns ANSI string as most other
                // text-related messages do. Yet, at least some versions of
                // RichEdit control seem to return UCS-2 characters. Internet
                // search produces conflicting results. Let's be prepared for
                // anything. After all, there are only two possiblities. It's
                // either UCS-2 or ASCII.
                TEXTRANGEA range;
                range.chrg = link->chrg;
                range.lpstrText = url;
                url[0] = url[1] = 0;
                SendMessageA(hText, EM_GETTEXTRANGE, 0, (LPARAM)&range);
                url[COUNT(url)-1] = url[COUNT(url)-2] = 0;
                if (!_wcsnicmp((WCHAR*)url,L"http://",7))
                {
                    // Looks like UCS-2 string to me. Convert it to ASCII
                    LPWSTR w = (WCHAR*)url;
                    LPSTR p = url;
                    do { *p++ =  (char)*w++; } while (*w);
                    *p = 0;
                }

                // Start the default browser
                WIN32_BrowseURL(url);
            }
        }
        // Usually, the return value is ignored
        return FALSE;

#endif // HAVE_WLIB

#ifdef SDK_REGISTRATION

    case WM_CTLCOLORSTATIC:
        // We don't want the product key edit control to erase its
        // background because it's drawn on top of the product name
        // bitmap (white cloud).
        {
            int nDlgCtrlID = GetDlgCtrlID((HWND)lParam);
            switch (nDlgCtrlID) 
            {
            case IDC_PRODUCT_KEY:
                // Return transparent brush for the product key control
                return (BOOL)GetStockObject(HOLLOW_BRUSH);
            }
        }
        return FALSE;

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_MBUTTONDOWN:
        // Stop scrolling on mouse click
        TitleStopScroller(hDlg);
        return FALSE;

#endif // SDK_REGISTRATION

    default:
        return FALSE;
    }
}
Exemple #3
0
static void test_PBM_STEPIT(void)
{
    struct stepit_test
    {
        int min;
        int max;
        int step;
    } stepit_tests[] =
    {
        { 3, 15,  5 },
        { 3, 15, -5 },
        { 3, 15, 50 },
        { -15, 15,  5 },
        { -3, -2, -5 },
        { 0, 0, 1 },
        { 5, 5, 1 },
        { 0, 0, -1 },
        { 5, 5, -1 },
        { 10, 5, 2 },
    };
    HWND progress;
    int i, j;

    for (i = 0; i < ARRAY_SIZE(stepit_tests); i++)
    {
        struct stepit_test *test = &stepit_tests[i];
        PBRANGE range;
        LRESULT ret;

        progress = create_progress(0);

        ret = SendMessageA(progress, PBM_SETRANGE32, test->min, test->max);
        ok(ret != 0, "Unexpected return value.\n");

        SendMessageA(progress, PBM_GETRANGE, 0, (LPARAM)&range);
        ok(range.iLow == test->min && range.iHigh == test->max, "Unexpected range.\n");

        SendMessageA(progress, PBM_SETPOS, test->min, 0);
        SendMessageA(progress, PBM_SETSTEP, test->step, 0);

        for (j = 0; j < test->max; j++)
        {
            int pos = SendMessageA(progress, PBM_GETPOS, 0, 0);
            int current;

            pos += test->step;
            if (test->min != test->max)
            {
                if (pos > test->max)
                    pos = (pos - test->min) % (test->max - test->min) + test->min;
                if (pos < test->min)
                    pos = (pos - test->min) % (test->max - test->min) + test->max;
            }
            else
                pos = test->min;

            SendMessageA(progress, PBM_STEPIT, 0, 0);

            current = SendMessageA(progress, PBM_GETPOS, 0, 0);
            ok(current == pos, "%u: unexpected position %d, expected %d.\n", i, current, pos);
        }

        DestroyWindow(progress);
    }
}
Exemple #4
0
/**********************************************************************
 *		WinHelpA (USER32.@)
 */
BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand, ULONG_PTR dwData )
{
    COPYDATASTRUCT      cds;
    HWND                hDest;
    int                 size, dsize, nlen;
    WINHELP*            lpwh;

    hDest = FindWindowA("MS_WINHELP", NULL);
    if (!hDest) 
    {
        if (wCommand == HELP_QUIT) return TRUE;
        if (WinExec("winhlp32.exe -x", SW_SHOWNORMAL) < 32) 
        {
            ERR("can't start winhlp32.exe -x ?\n");
            return FALSE;
        }
        if (!(hDest = FindWindowA("MS_WINHELP", NULL))) 
        {
            FIXME("Did not find a MS_WINHELP Window\n");
            return FALSE;
        }
    }

    switch (wCommand)
    {
    case HELP_CONTEXT:
    case HELP_SETCONTENTS:
    case HELP_CONTENTS:
    case HELP_CONTEXTPOPUP:
    case HELP_FORCEFILE:
    case HELP_HELPONHELP:
    case HELP_FINDER:
    case HELP_QUIT:
        dsize = 0;
        break;
    case HELP_KEY:
    case HELP_PARTIALKEY:
    case HELP_COMMAND:
        dsize = dwData ? strlen((LPSTR)dwData) + 1 : 0;
        break;
    case HELP_MULTIKEY:
        dsize = ((LPMULTIKEYHELPA)dwData)->mkSize;
        break;
    case HELP_SETWINPOS:
        dsize = ((LPHELPWININFOA)dwData)->wStructSize;
        break;
    default:
        FIXME("Unknown help command %d\n", wCommand);
        return FALSE;
    }
    if (lpHelpFile)
        nlen = strlen(lpHelpFile) + 1;
    else
        nlen = 0;
    size = sizeof(WINHELP) + nlen + dsize;

    lpwh = HeapAlloc(GetProcessHeap(), 0, size);
    if (!lpwh) return FALSE;

    cds.dwData = WINHELP_MAGIC;
    cds.cbData = size;
    cds.lpData = (void*)lpwh;

    lpwh->size = size;
    lpwh->command = wCommand;
    lpwh->data = dwData;
    if (nlen) 
    {
        strcpy(((char*)lpwh) + sizeof(WINHELP), lpHelpFile);
        lpwh->ofsFilename = sizeof(WINHELP);
    } else
        lpwh->ofsFilename = 0;
    if (dsize) 
    {
        memcpy(((char*)lpwh) + sizeof(WINHELP) + nlen, (LPSTR)dwData, dsize);
        lpwh->ofsData = sizeof(WINHELP) + nlen;
    } else
        lpwh->ofsData = 0;
    WINE_TRACE("Sending[%u]: cmd=%u data=%08x fn=%s\n",
               lpwh->size, lpwh->command, lpwh->data,
               lpwh->ofsFilename ? (LPSTR)lpwh + lpwh->ofsFilename : "");

    return SendMessageA(hDest, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
}
Exemple #5
0
VOID OnInitDialog(HWND hwnd)
{
    int i, n;
    double e;
    char buf[64], *p;
    HICON hIcon;

    // set big icon
    hIcon = LoadIconA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1));
    SendMessageA(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
    // set small icon
    hIcon = (HICON)LoadImageA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1),
        IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
    // set window title
    SetWindowText(hwnd, progname);

    for (i = 0; i < hack_argcount; i++)
    {
        SetDlgItemTextA(hwnd, IDC_ARGNAME00 + i, hack_arginfo[i].name);

        switch (hack_arginfo[i].type)
        {
        case t_Bool:
            if (*(Bool *)hack_arginfo[i].data)
                SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, "True");
            else
                SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, "False");
            break;

        case t_Int:
            n = *(INT *)hack_arginfo[i].data;
            SetDlgItemInt(hwnd, IDC_ARGVAL00 + i, n, TRUE);
            break;

        case t_Float:
            e = *(float *)hack_arginfo[i].data;
            sprintf(buf, "%g", e);
            SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, buf);
            break;

        case t_String:
            p = *(char **)hack_arginfo[i].data;
            SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, p);
            break;
        }
    }

    for (; i <= 23; i++)
    {
        ShowWindow(GetDlgItem(hwnd, IDC_ARGNAME00 + i), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_ARGVAL00 + i), SW_HIDE);
    }

    ShowWindow(GetDlgItem(hwnd, IDC_COUNTNAME), SW_HIDE);
    ShowWindow(GetDlgItem(hwnd, IDC_COUNTVAL), SW_HIDE);
    ShowWindow(GetDlgItem(hwnd, IDC_CYCLESNAME), SW_HIDE);
    ShowWindow(GetDlgItem(hwnd, IDC_CYCLESVAL), SW_HIDE);
    ShowWindow(GetDlgItem(hwnd, IDC_SIZENAME), SW_HIDE);
    ShowWindow(GetDlgItem(hwnd, IDC_SIZEVAL), SW_HIDE);

    CenterDialog(hwnd);
}
Exemple #6
0
static void test_wiznavigation(void)
{
    HPROPSHEETPAGE hpsp[4];
    PROPSHEETPAGEA psp[4];
    PROPSHEETHEADERA psh;
    HWND hdlg, control;
    LONG_PTR controlID;
    DWORD style;
    LRESULT defidres;
    BOOL hwndtoindex_supported = TRUE;
    const INT nextID = 12324;
    const INT backID = 12323;

    /* create the property sheet pages */
    memset(psp, 0, sizeof(PROPSHEETPAGEA) * 4);

    psp[0].dwSize = sizeof(PROPSHEETPAGEA);
    psp[0].hInstance = GetModuleHandleA(NULL);
    U(psp[0]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_INTRO);
    psp[0].pfnDlgProc = nav_page_proc;
    hpsp[0] = CreatePropertySheetPageA(&psp[0]);

    psp[1].dwSize = sizeof(PROPSHEETPAGEA);
    psp[1].hInstance = GetModuleHandleA(NULL);
    U(psp[1]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_EDIT);
    psp[1].pfnDlgProc = nav_page_proc;
    hpsp[1] = CreatePropertySheetPageA(&psp[1]);

    psp[2].dwSize = sizeof(PROPSHEETPAGEA);
    psp[2].hInstance = GetModuleHandleA(NULL);
    U(psp[2]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_RADIO);
    psp[2].pfnDlgProc = nav_page_proc;
    hpsp[2] = CreatePropertySheetPageA(&psp[2]);

    psp[3].dwSize = sizeof(PROPSHEETPAGEA);
    psp[3].hInstance = GetModuleHandleA(NULL);
    U(psp[3]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_EXIT);
    psp[3].pfnDlgProc = nav_page_proc;
    hpsp[3] = CreatePropertySheetPageA(&psp[3]);

    /* set up the property sheet dialog */
    memset(&psh, 0, sizeof(psh));
    psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
    psh.dwFlags = PSH_MODELESS | PSH_WIZARD;
    psh.pszCaption = "A Wizard";
    psh.nPages = 4;
    psh.hwndParent = GetDesktopWindow();
    U3(psh).phpage = hpsp;
    hdlg = (HWND)PropertySheetA(&psh);
    ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);

    ok(active_page == 0, "Active page should be 0. Is: %d\n", active_page);

    style = GetWindowLongA(hdlg, GWL_STYLE) & ~(DS_CONTEXTHELP|WS_SYSMENU);
    ok(style == (WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CAPTION|
                 DS_MODALFRAME|DS_SETFONT|DS_3DLOOK),
       "got unexpected style: %x\n", style);

    control = GetFocus();
    controlID = GetWindowLongPtrA(control, GWLP_ID);
    ok(controlID == nextID, "Focus should have been set to the Next button. Expected: %d, Found: %ld\n", nextID, controlID);

    /* simulate pressing the Next button */
    SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
    if (!active_page) hwndtoindex_supported = FALSE;
    if (hwndtoindex_supported)
        ok(active_page == 1, "Active page should be 1 after pressing Next. Is: %d\n", active_page);

    control = GetFocus();
    controlID = GetWindowLongPtrA(control, GWLP_ID);
    ok(controlID == IDC_PS_EDIT1, "Focus should be set to the first item on the second page. Expected: %d, Found: %ld\n", IDC_PS_EDIT1, controlID);

    defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
    ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres));

    /* set the focus to the second edit box on this page */
    SetFocus(GetNextDlgTabItem(hdlg, control, FALSE));

    /* press next again */
    SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
    if (hwndtoindex_supported)
        ok(active_page == 2, "Active page should be 2 after pressing Next. Is: %d\n", active_page);

    control = GetFocus();
    controlID = GetWindowLongPtrA(control, GWLP_ID);
    ok(controlID == IDC_PS_RADIO1, "Focus should have been set to item on third page. Expected: %d, Found %ld\n", IDC_PS_RADIO1, controlID);

    /* back button */
    SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_BACK, 0);
    if (hwndtoindex_supported)
        ok(active_page == 1, "Active page should be 1 after pressing Back. Is: %d\n", active_page);

    control = GetFocus();
    controlID = GetWindowLongPtrA(control, GWLP_ID);
    ok(controlID == IDC_PS_EDIT1, "Focus should have been set to the first item on second page. Expected: %d, Found %ld\n", IDC_PS_EDIT1, controlID);

    defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
    ok(defidres == MAKELRESULT(backID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", backID, LOWORD(defidres));

    /* press next twice */
    SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
    if (hwndtoindex_supported)
        ok(active_page == 2, "Active page should be 2 after pressing Next. Is: %d\n", active_page);
    SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0);
    if (hwndtoindex_supported)
        ok(active_page == 3, "Active page should be 3 after pressing Next. Is: %d\n", active_page);
    else
        active_page = 3;

    control = GetFocus();
    controlID = GetWindowLongPtrA(control, GWLP_ID);
    ok(controlID == nextID, "Focus should have been set to the Next button. Expected: %d, Found: %ld\n", nextID, controlID);

    /* try to navigate away, but shouldn't be able to */
    SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_BACK, 0);
    ok(active_page == 3, "Active page should still be 3 after pressing Back. Is: %d\n", active_page);

    defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
    ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres));

    DestroyWindow(hdlg);
}
Exemple #7
0
static void test_PSM_ADDPAGE(void)
{
    HPROPSHEETPAGE hpsp[5];
    PROPSHEETPAGEA psp;
    PROPSHEETHEADERA psh;
    HWND hdlg, tab;
    BOOL ret;
    DWORD r;

    memset(&psp, 0, sizeof(psp));
    psp.dwSize = sizeof(psp);
    psp.dwFlags = 0;
    psp.hInstance = GetModuleHandleA(NULL);
    U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_MESSAGE_TEST);
    U2(psp).pszIcon = NULL;
    psp.pfnDlgProc = page_dlg_proc_messages;
    psp.lParam = 0;

    /* two page with the same data */
    hpsp[0] = CreatePropertySheetPageA(&psp);
    hpsp[1] = CreatePropertySheetPageA(&psp);
    hpsp[2] = CreatePropertySheetPageA(&psp);

    U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_ERROR);
    hpsp[3] = CreatePropertySheetPageA(&psp);

    psp.dwFlags = PSP_PREMATURE;
    hpsp[4] = CreatePropertySheetPageA(&psp);

    memset(&psh, 0, sizeof(psh));
    psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
    psh.dwFlags = PSH_MODELESS;
    psh.pszCaption = "test caption";
    psh.nPages = 1;
    psh.hwndParent = GetDesktopWindow();
    U3(psh).phpage = hpsp;

    hdlg = (HWND)PropertySheetA(&psh);
    ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);

    /* add pages one by one */
    ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[1]);
    ok(ret == TRUE, "got %d\n", ret);

    /* try with null and invalid value */
    ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, 0);
    ok(ret == FALSE, "got %d\n", ret);

    if (0)
    {
        /* crashes on native */
        ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)INVALID_HANDLE_VALUE);
    }
    /* check item count */
    tab = (HWND)SendMessageA(hdlg, PSM_GETTABCONTROL, 0, 0);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 2, "got %d\n", r);

    ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[2]);
    ok(ret == TRUE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 3, "got %d\n", r);

    /* add property sheet page that can't be created */
    ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[3]);
    ok(ret == TRUE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 4, "got %d\n", r);

    /* select page that can't be created */
    ret = SendMessageA(hdlg, PSM_SETCURSEL, 3, 1);
    ok(ret == TRUE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 3, "got %d\n", r);

    /* test PSP_PREMATURE flag with incorrect property sheet page */
    ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[4]);
    ok(ret == FALSE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 3, "got %d\n", r);

    DestroyWindow(hdlg);
}
Exemple #8
0
static LRESULT CALLBACK 
MainWindowProc(HWND MainWindow, UINT Message, WPARAM wParam, LPARAM lParam)
{
	LRESULT Result = 0;
	switch(Message) {
		case WM_CREATE:
			InitWindowComponents(MainWindow, &Controls);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		case WM_ERASEBKGND:
			// NOTE: Return a non-zero value. Literally.
			Result = !0;
			break;
		case WM_PAINT:
		{
			PAINTSTRUCT PaintStruct;
			HDC DC = BeginPaint(MainWindow, &PaintStruct);
			RECT FillRegion;
			GetClientRect(MainWindow, &FillRegion);
			COLORREF Top = RGB(239, 241, 245);
			COLORREF Bottom = RGB(218, 223, 233);
			DrawGradient(DC, FillRegion, Top, Top, Bottom, Bottom);
			EndPaint(MainWindow, &PaintStruct);
			ReleaseDC(MainWindow, DC);
		} break;
		case WM_COMMAND:
		{
			HWND Ctrl = (HWND)lParam;
			if(HIWORD(wParam) == CBN_SELCHANGE && Ctrl == Controls.ComboBox) {
				DWORD Pos = SendMessageA((HWND)lParam, CB_GETCURSEL, 0, 0);
				window_data *WndData = (window_data*)SendMessageA((HWND)lParam, CB_GETITEMDATA, Pos, 0);
				if(WndData) {
					Controls.CurSelection = WndData;
					HWND Window = WndData->Window;
					WINDOWINFO WindowInfo = {};
					WindowInfo.cbSize = sizeof(WindowInfo);
					if(GetWindowInfo(Window, &WindowInfo)) {
						RECT Rect = WindowInfo.rcWindow;
						LONG Width = Rect.right - Rect.left;
						LONG Height = Rect.bottom - Rect.top;

						// TODO: Display usefull data
						char Buffer[256];
						StringCbPrintfA(Buffer, sizeof(Buffer), "%dx%d starting at (%d,%d)", Width, Height, Rect.left, Rect.top);
						SetWindowTextA(Controls.StaticText, Buffer);
						ShowWindow(Controls.StaticText, TRUE);
					}
					else {
						PRINT_ERR("Could not get window info.\n");
					}
				}
			}
			else if(HIWORD(wParam) == BN_CLICKED) {
				if(Ctrl == Controls.ButtonOK) {
					if(Controls.CurSelection) {
						int UseConfig = SendMessageA(Controls.CheckBox, BM_GETCHECK, 0, 0);
						if(UseConfig == BST_CHECKED) {
							load_file_result LoadResult = LoadWindowSizeFromConfig();
							if(LoadResult.Valid) {
								SetWindowMode(*Controls.CurSelection, LoadResult.Width, LoadResult.Height);
							}
							else {
								int SetToFullscreen = MessageBoxA(MainWindow, "Error loading config.ini.\nSet to fullscreen instead?", 0, MB_YESNO | MB_TASKMODAL);
								if(SetToFullscreen == IDYES) {
									SetFullscreen(*Controls.CurSelection);
								}
							}
						}
						else {
							SetFullscreen(*Controls.CurSelection);
						}
					}
					PostQuitMessage(0);
				}
				else if(Ctrl == Controls.ButtonCancel) {
					PostQuitMessage(0);
				}
				else {
					Result = DefWindowProcA(MainWindow, Message, wParam, lParam);
				}
			}
		} break;
		default:
			Result = DefWindowProcA(MainWindow, Message, wParam, lParam);
	}

	return Result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// DialogProc()
//
////////////////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK ResPickerDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	HWND hControl;
	switch( uMsg )
	{
	case WM_INITDIALOG:
		{
			// Populate the controls.
			char szBuffer[256];
			int i;
			
			// Populate the device drop down.
			hControl = GetDlgItem( hwndDlg, IDC_DEVDROPDOWN );
			for( i=0; i<g_VideoSettings.pDevData->GetDeviceCount(); i++ )
			{
				g_VideoSettings.pDevData->GetDeviceNameByIndex( i, szBuffer, 256 );
				SendMessageA( hControl, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCSTR) szBuffer ) );
			}
			
			// Make the first option, the selected one. Once reg key stuff set up, make the last used device the selected one.
			if( g_VideoSettings.pDevData->GetDeviceCount() > 0 )
			{
				SendMessage( hControl, CB_SETCURSEL, g_VideoSettings.iCurrentDevice, 0 );
			
				// Add display modes for current selection.
				SetModeData( hwndDlg, g_VideoSettings.iCurrentDevice );

				// Add AA settings.
				SetAAData( hwndDlg, g_VideoSettings.iCurrentDevice, 
					g_VideoSettings.iCurrentMode, g_VideoSettings.bWindowed );

				// Set the windowed flag.
				hControl = GetDlgItem( hwndDlg, IDC_WINDOWED );
				SendMessage( hControl, BM_SETCHECK, (
					g_VideoSettings.bWindowed == true ) ? BST_CHECKED : BST_UNCHECKED, 0 );

				// Set the vertical sync flag.
				hControl = GetDlgItem( hwndDlg, IDC_VSYNC );
				SendMessage( hControl, BM_SETCHECK, (
					g_VideoSettings.bWaitForVSync == true ) ? BST_CHECKED : BST_UNCHECKED, 0 );

				// Set graphics settings.
				SetGFXSettings( hwndDlg, g_VideoSettings.iMaxTextureSize, g_VideoSettings.bAutoGenMipmaps );

				// Set data settings.
				SetDataSettings( hwndDlg, g_VideoSettings.bUseTexturePackFile );
			}

			// Centre the dialog box in the middle of the desktop.
			RECT dlgRect, desktopRect;
			int iNewXPos, iNewYPos;
			GetWindowRect( hwndDlg, &dlgRect );
			GetWindowRect( GetDesktopWindow(), &desktopRect );
			iNewXPos = (( desktopRect.right - desktopRect.left ) / 2 ) - (( dlgRect.right - dlgRect.left ) / 2 );
			iNewYPos = (( desktopRect.bottom - desktopRect.top ) / 2 ) - (( dlgRect.bottom - dlgRect.top ) / 2 );

			SetWindowPos( hwndDlg, HWND_TOP, iNewXPos, iNewYPos, 0, 0, SWP_NOSIZE );
		}
		break;

    case WM_COMMAND: 
        switch (LOWORD(wParam)) 
        { 
            case IDOK: 
				// Update parameters.
				if( GetModeData( hwndDlg, true ) == true )
				{
	                EndDialog(hwndDlg, wParam); 
					return TRUE;
				}
				MessageBoxA( hwndDlg, "Selected mode could not be validated.", "Invalid mode selection", MB_OK );
				return FALSE;			// Do nothing.

            case IDCANCEL: 
				GetModeData( hwndDlg, false );
                EndDialog(hwndDlg, wParam); 
                return TRUE;

        }
		switch ( HIWORD ( wParam ) )
		{
		case CBN_SELCHANGE:
			// Change of device?
			hControl = GetDlgItem( hwndDlg, IDC_DEVDROPDOWN );
			if( LOWORD(wParam) == GetDlgCtrlID( hControl ) )
			{
				g_VideoSettings.iCurrentDevice = SendMessage( hControl, CB_GETCURSEL, 0, 0 );
				_ASSERT( g_VideoSettings.iCurrentDevice != CB_ERR );

				// Set the mode data for the new device.
				SetModeData( hwndDlg, g_VideoSettings.iCurrentDevice );
				return FALSE;
			}
			// Change of resolution?
			hControl = GetDlgItem( hwndDlg, IDC_RESDROPDOWN );
			if( LOWORD(wParam) == GetDlgCtrlID( hControl ) )
			{
				g_VideoSettings.iCurrentMode = SendMessage( hControl, CB_GETCURSEL, 0, 0 );
				_ASSERT( g_VideoSettings.iCurrentMode != CB_ERR );

				SetAAData(	hwndDlg,
							g_VideoSettings.iCurrentDevice,
							g_VideoSettings.iCurrentMode,
							g_VideoSettings.bWindowed );
				return FALSE;
			}
			// Change of FSAA setting?
			hControl = GetDlgItem( hwndDlg, IDC_ANTIALIAS );
			if( LOWORD(wParam) == GetDlgCtrlID( hControl ) )
			{
				g_VideoSettings.iCurrentAASetting = SendMessage( hControl, CB_GETCURSEL, 0, 0 );
				_ASSERT( g_VideoSettings.iCurrentAASetting != CB_ERR );
				return FALSE;
			}
			return FALSE;

		case BN_CLICKED:
			hControl = GetDlgItem( hwndDlg, IDC_WINDOWED );
			if( LOWORD(wParam) == GetDlgCtrlID( hControl ) )
			{
				// Update the state.
				if( SendMessage( hControl, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
				{
					g_VideoSettings.bWindowed = true;
				}	
				else
				{
					g_VideoSettings.bWindowed = false;
				}
				SetAAData(	hwndDlg,
							g_VideoSettings.iCurrentDevice,
							g_VideoSettings.iCurrentMode,
							g_VideoSettings.bWindowed );
			}
			break;
		}
	}
	return FALSE;
}
Exemple #10
0
static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
			CMsnProto* proto = (CMsnProto*)lParam;

			SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);

			char tBuffer[MAX_PATH];
			if (!db_get_static(NULL, proto->m_szModuleName, "Password", tBuffer, sizeof(tBuffer))) {
				tBuffer[16] = 0;
				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
			}
			SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_SETLIMITTEXT, 16, 0);

			HWND wnd = GetDlgItem(hwndDlg, IDC_HANDLE2);
			DBVARIANT dbv;
			if (!proto->getTString("Nick", &dbv)) {
				SetWindowText(wnd, dbv.ptszVal);
				db_free(&dbv);
			}
			EnableWindow(wnd, proto->msnLoggedIn);
			EnableWindow(GetDlgItem(hwndDlg, IDC_MOBILESEND), proto->msnLoggedIn &&
				proto->getByte("MobileEnabled", 0) && proto->getByte("MobileAllowed", 0));

			CheckDlgButton(hwndDlg, IDC_MOBILESEND, proto->getByte("MobileAllowed", 0) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_SENDFONTINFO, proto->getByte("SendFontInfo", 1) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MANAGEGROUPS, proto->getByte("ManageServer", 1) ? BST_CHECKED : BST_UNCHECKED);

			int tValue = proto->getByte("RunMailerOnHotmail", 0);
			CheckDlgButton(hwndDlg, IDC_RUN_APP_ON_HOTMAIL, tValue ? BST_CHECKED : BST_UNCHECKED);
			EnableWindow(GetDlgItem(hwndDlg, IDC_MAILER_APP), tValue);
			EnableWindow(GetDlgItem(hwndDlg, IDC_ENTER_MAILER_APP), tValue);

			if (!db_get_static(NULL, proto->m_szModuleName, "MailerPath", tBuffer, sizeof(tBuffer)))
				SetDlgItemTextA(hwndDlg, IDC_MAILER_APP, tBuffer);

			if (!proto->msnLoggedIn) {
				EnableWindow(GetDlgItem(hwndDlg, IDC_MANAGEGROUPS), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS), FALSE);
			}
			else CheckDlgButton(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS, proto->msnOtherContactsBlocked ? BST_CHECKED : BST_UNCHECKED);
		}
		return TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK) {
			Utils_OpenUrl("https://signup.live.com");
			return TRUE;
		}

		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
			switch (LOWORD(wParam)) {
			case IDC_HANDLE:        case IDC_PASSWORD: case IDC_HANDLE2:
			case IDC_GATEWAYSERVER: case IDC_YOURHOST: case IDC_DIRECTSERVER:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		}

		if (HIWORD(wParam) == BN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDC_SENDFONTINFO:
			case IDC_DISABLE_ANOTHER_CONTACTS:
			case IDC_MOBILESEND:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;

			case IDC_MANAGEGROUPS:
				if (IsDlgButtonChecked(hwndDlg, IDC_MANAGEGROUPS)) {
					if (IDYES == MessageBox(hwndDlg,
						TranslateT("Server groups import may change your contact list layout after next login. Do you want to upload your groups to the server?"),
						TranslateT("MSN Protocol"), MB_YESNOCANCEL)) {
						CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
						proto->MSN_UploadServerGroups(NULL);
					}
				}
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;

			case IDC_RUN_APP_ON_HOTMAIL:
				{
					BOOL tIsChosen = IsDlgButtonChecked(hwndDlg, IDC_RUN_APP_ON_HOTMAIL);
					EnableWindow(GetDlgItem(hwndDlg, IDC_MAILER_APP), tIsChosen);
					EnableWindow(GetDlgItem(hwndDlg, IDC_ENTER_MAILER_APP), tIsChosen);
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
				break;

			case IDC_ENTER_MAILER_APP:
				char szFile[MAX_PATH + 2];
				{
					HWND tEditField = GetDlgItem(hwndDlg, IDC_MAILER_APP);

					GetWindowTextA(tEditField, szFile, _countof(szFile));

					size_t tSelectLen = 0;

					if (szFile[0] == '\"') {
						char* p = strchr(szFile + 1, '\"');
						if (p != NULL) {
							*p = '\0';
							memmove(szFile, szFile + 1, mir_strlen(szFile));
							tSelectLen += 2;
							goto LBL_Continue;
						}
					}

					char* p = strchr(szFile, ' ');
					if (p != NULL) *p = '\0';
LBL_Continue:
					tSelectLen += mir_strlen(szFile);

					OPENFILENAMEA ofn = { 0 };
					ofn.lStructSize = sizeof(ofn);
					ofn.hwndOwner = hwndDlg;
					ofn.nMaxFile = _countof(szFile);
					ofn.lpstrFile = szFile;
					ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
					if (GetOpenFileNameA(&ofn) != TRUE)
						break;

					if (strchr(szFile, ' ') != NULL) {
						char tmpBuf[MAX_PATH + 2];
						mir_snprintf(tmpBuf, "\"%s\"", szFile);
						mir_strcpy(szFile, tmpBuf);
					}

					SendMessage(tEditField, EM_SETSEL, 0, tSelectLen);
					SendMessageA(tEditField, EM_REPLACESEL, TRUE, LPARAM(szFile));
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
			}
		}
		break;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
			bool reconnectRequired = false;
			TCHAR screenStr[MAX_PATH];
			char  password[100], szEmail[MSN_MAX_EMAIL_LEN];
			DBVARIANT dbv;

			CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

			GetDlgItemTextA(hwndDlg, IDC_HANDLE, szEmail, _countof(szEmail));
			if (mir_strcmp(_strlwr(szEmail), proto->MyOptions.szEmail)) {
				reconnectRequired = true;
				mir_strcpy(proto->MyOptions.szEmail, szEmail);
				proto->setString("e-mail", szEmail);
				proto->setString("wlid", szEmail);
				proto->setDword("netId", (proto->MyOptions.netId = proto->GetMyNetID()));
			}

			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, _countof(password));
			if (!proto->getString("Password", &dbv)) {
				if (mir_strcmp(password, dbv.pszVal)) {
					reconnectRequired = true;
					proto->setString("Password", password);
				}
				db_free(&dbv);
			}
			else {
				reconnectRequired = true;
				proto->setString("Password", password);
			}

#ifdef OBSOLETE
			GetDlgItemText(hwndDlg, IDC_HANDLE2, screenStr, _countof(screenStr));
			if (!proto->getTString("Nick", &dbv)) {
				if (mir_tstrcmp(dbv.ptszVal, screenStr))
					proto->MSN_SendNickname(screenStr);
				db_free(&dbv);
			}
			else proto->MSN_SendNickname(screenStr);

			BYTE mblsnd = IsDlgButtonChecked(hwndDlg, IDC_MOBILESEND) == BST_CHECKED;
			if (mblsnd != proto->getByte("MobileAllowed", 0)) {
				proto->msnNsThread->sendPacket("PRP", "MOB %c", mblsnd ? 'Y' : 'N');
				proto->MSN_SetServerStatus(proto->m_iStatus);
			}

			unsigned tValue = IsDlgButtonChecked(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS);
			if (tValue != proto->msnOtherContactsBlocked && proto->msnLoggedIn) {
				proto->msnOtherContactsBlocked = tValue;
				proto->msnNsThread->sendPacket("BLP", tValue ? "BL" : "AL");
				proto->MSN_ABUpdateAttr(NULL, "MSN.IM.BLP", tValue ? "0" : "1");
				break;
			}
#endif

			proto->setByte("SendFontInfo", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SENDFONTINFO));
			proto->setByte("RunMailerOnHotmail", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RUN_APP_ON_HOTMAIL));
			proto->setByte("ManageServer", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MANAGEGROUPS));

			GetDlgItemText(hwndDlg, IDC_MAILER_APP, screenStr, _countof(screenStr));
			proto->setTString("MailerPath", screenStr);

			if (reconnectRequired && proto->msnLoggedIn)
				MessageBox(hwndDlg,
				TranslateT("The changes you have made require you to reconnect to the MSN Messenger network before they take effect"),
				TranslateT("MSN Options"), MB_OK);

			proto->LoadOptions();
			return TRUE;
		}
		break;
	}

	return FALSE;
}
LRESULT CALLBACK ScanWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch ( msg )
    {
		case WM_CREATE:
		{
			RECT rc;
			GetClientRect( hWnd, &rc );

			g_hWnd_tab = CreateWindowEx( WS_EX_CONTROLPARENT, WC_TABCONTROL, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_TABSTOP | WS_VISIBLE, 10, 10, rc.right - 20, rc.bottom - 50, hWnd, NULL, NULL, NULL );

			TCITEMA ti = { 0 };
			ti.mask = TCIF_PARAM | TCIF_TEXT;	// The tab will have text and an lParam value.
			ti.pszText = "Scan Directory";
			ti.lParam = ( LPARAM )0;
			SendMessageA( g_hWnd_tab, TCM_INSERTITEMA, 0, ( LPARAM )&ti );	// Insert a new tab at the end.

			ti.pszText = "Load ESE Database";
			ti.lParam = ( LPARAM )1;
			SendMessageA( g_hWnd_tab, TCM_INSERTITEMA, 1, ( LPARAM )&ti );	// Insert a new tab at the end.

			SendMessage( g_hWnd_tab, WM_SETFONT, ( WPARAM )hFont, 0 );

			// Set the tab's font before we get the item rect so that we have an accurate height.
			RECT rc_tab;
			GetClientRect( g_hWnd_tab, &rc );
			SendMessage( g_hWnd_tab, TCM_GETITEMRECT, 0, ( LPARAM )&rc_tab );

			g_hWnd_scan_tab = CreateWindowEx( WS_EX_CONTROLPARENT, L"scan_tab", NULL, WS_CHILD | WS_TABSTOP | WS_VISIBLE, 10, ( rc_tab.bottom + rc_tab.top ) + 8, rc.right - 20, rc.bottom - ( ( rc_tab.bottom + rc_tab.top ) + 16 ), g_hWnd_tab, NULL, NULL, NULL );

			g_hWnd_btn_details = CreateWindowA( WC_BUTTONA, "Show Details \xBB", WS_CHILD | WS_TABSTOP | WS_VISIBLE, 0, 0, 0, 0, hWnd, ( HMENU )BTN_DETAILS, NULL, NULL );

			g_hWnd_btn_scan = CreateWindowA( WC_BUTTONA, "Scan", BS_DEFPUSHBUTTON | WS_CHILD | WS_TABSTOP | WS_VISIBLE, 0, 0, 0, 0, hWnd, ( HMENU )BTN_SCAN, NULL, NULL );
			g_hWnd_btn_cancel = CreateWindowA( WC_BUTTONA, "Cancel", WS_CHILD | WS_TABSTOP | WS_VISIBLE, 0, 0, 0, 0, hWnd, ( HMENU )BTN_CANCEL, NULL, NULL );

			// Make pretty font.
			SendMessage( g_hWnd_btn_details, WM_SETFONT, ( WPARAM )hFont, 0 );
			SendMessage( g_hWnd_btn_scan, WM_SETFONT, ( WPARAM )hFont, 0 );
			SendMessage( g_hWnd_btn_cancel, WM_SETFONT, ( WPARAM )hFont, 0 );

			return 0;
		}
		break;

		case WM_CHANGE_CURSOR:
		{
			// SetCursor must be called from the window thread.
			if ( wParam == TRUE )
			{
				wait_cursor = LoadCursor( NULL, IDC_APPSTARTING );	// Arrow + hourglass.
				SetCursor( wait_cursor );
			}
			else
			{
				SetCursor( LoadCursor( NULL, IDC_ARROW ) );	// Default arrow.
				wait_cursor = NULL;
			}
		}
		break;

		case WM_SETCURSOR:
		{
			if ( wait_cursor != NULL )
			{
				SetCursor( wait_cursor );	// Keep setting our cursor if it reverts back to the default.
				return TRUE;
			}

			DefWindowProc( hWnd, msg, wParam, lParam );
			return FALSE;
		}
		break;

		case WM_COMMAND:
		{
			switch( LOWORD( wParam ) )
			{
				case IDOK:
				case BTN_SCAN:
				{
					if ( g_kill_scan == false )
					{
						EnableWindow( g_hWnd_btn_scan, FALSE );
						g_kill_scan = true;
						break;
					}

					int length = SendMessage( g_hWnd_path[ tab_index ], WM_GETTEXT, MAX_PATH, ( LPARAM )g_filepath );
					if ( length >= 3 )
					{
						// We need to have at least the drive path. Example: "C:\"
						if ( g_filepath[ 1 ] == L':' && g_filepath[ 2 ] == L'\\' )
						{
							// Remove any trailing "\" from the path.
							if ( g_filepath[ length - 1 ] == L'\\' )
							{
								g_filepath[ length - 1 ] = '\0';
							}

							// Now get our extension filters.
							length = SendMessage( g_hWnd_extensions[ tab_index ], WM_GETTEXT, MAX_PATH, ( LPARAM )( g_extension_filter + 1 ) );
							if ( length > 0 )
							{
								g_extension_filter[ 0 ] = L'|';					// Append the delimiter to the beginning of the string.
								g_extension_filter[ length + 1 ] = L'|';		// Append the delimiter to the end of the string.
								g_extension_filter[ length + 2 ] = L'\0';
								_wcslwr_s( g_extension_filter, length + 3 );	// Set them to lowercase for later comparison.
							}
							else
							{
								g_extension_filter[ 0 ] = L'\0';
							}

							g_include_folders = SendMessage( g_hWnd_chk_folders[ tab_index ], BM_GETCHECK, 0, 0 ) ? true : false;

							g_retrieve_extended_information = SendMessage( g_hWnd_extended_information, BM_GETCHECK, 0, 0 ) ? true : false;

							scan_type = tab_index;	// scan_type will allow the correct windows to update regardless of the selected tab.

							// If use_scanner == false, then read the ese database.
							CloseHandle( ( HANDLE )_beginthreadex( NULL, 0, &map_entries, ( void * )scan_type, 0, NULL ) );
						}
						else
						{
							MessageBoxA( hWnd, "You must specify a valid path.", PROGRAM_CAPTION_A, MB_APPLMODAL | MB_ICONWARNING );
						}
					}
				}
				break;

				case BTN_CANCEL:
				{
					SendMessage( hWnd, WM_CLOSE, 0, 0 );
				}
				break;

				case BTN_DETAILS:
				{
					g_show_details = !g_show_details;

					// Hiding the details will allow for a faster scan since it doesn't have to update our controls.
					if ( g_show_details == true )
					{
						SendMessageA( g_hWnd_btn_details, WM_SETTEXT, 0, ( LPARAM )"Hide Details \xAB" );
						ShowWindow( g_hWnd_static3, SW_SHOW );
						ShowWindow( g_hWnd_static4, SW_SHOW );
						ShowWindow( g_hWnd_static5, SW_SHOW );
						ShowWindow( g_hWnd_hashing[ tab_index ], SW_SHOW );
						ShowWindow( g_hWnd_static_hash[ tab_index ], SW_SHOW );
						ShowWindow( g_hWnd_static_count[ tab_index ], SW_SHOW );
					}
					else
					{
						SendMessageA( g_hWnd_btn_details, WM_SETTEXT, 0, ( LPARAM )"Show Details \xBB" );
						ShowWindow( g_hWnd_static3, SW_HIDE );
						ShowWindow( g_hWnd_static4, SW_HIDE );
						ShowWindow( g_hWnd_static5, SW_HIDE );
						ShowWindow( g_hWnd_hashing[ 0 ], SW_HIDE );
						ShowWindow( g_hWnd_hashing[ 1 ], SW_HIDE );
						ShowWindow( g_hWnd_static_hash[ 0 ], SW_HIDE );
						ShowWindow( g_hWnd_static_hash[ 1 ], SW_HIDE );
						ShowWindow( g_hWnd_static_count[ 0 ], SW_HIDE );
						ShowWindow( g_hWnd_static_count[ 1 ], SW_HIDE );
					}

					// Adjust the window height.
					RECT rc;
					GetWindowRect( hWnd, &rc );
					SetWindowPos( hWnd, NULL, 0, 0, rc.right - rc.left, MIN_HEIGHT - ( g_show_details == true ? 25 : 115 ), SWP_NOMOVE );
				}
				break;
			}

			return 0;
		}
		break;

		case WM_NOTIFY:
		{
			// Get our listview codes.
			switch ( ( ( LPNMHDR )lParam )->code )
			{
				case TCN_SELCHANGING:		// The tab that's about to lose focus
				{
					NMHDR *nmhdr = ( NMHDR * )lParam;

					int index = SendMessage( nmhdr->hwndFrom, TCM_GETCURSEL, 0, 0 );		// Get the selected tab
					if ( index == 0 || index == 1 )
					{
						ShowWindow( g_hWnd_path[ index ], SW_HIDE );
						ShowWindow( g_hWnd_extensions[ index ], SW_HIDE );
						ShowWindow( g_hWnd_chk_folders[ index ], SW_HIDE );
						ShowWindow( g_hWnd_hashing[ index ], SW_HIDE );
						ShowWindow( g_hWnd_static_hash[ index ], SW_HIDE );
						ShowWindow( g_hWnd_static_count[ index ], SW_HIDE );

						if ( index == 1 )
						{
							ShowWindow( g_hWnd_extended_information, SW_HIDE );
						}
					}

					return FALSE;
				}
				break;

				case TCN_SELCHANGE:			// The tab that gains focus
                {
					NMHDR *nmhdr = ( NMHDR * )lParam;

					int index = SendMessage( nmhdr->hwndFrom, TCM_GETCURSEL, 0, 0 );		// Get the selected tab
					if ( index == 0 || index == 1 )
					{
						SendMessageA( g_hWnd_static1, WM_SETTEXT, 0, ( LPARAM )( index == 0 ? "Initial scan directory:" : "Extensible Storage Engine Database file:" ) );

						ShowWindow( g_hWnd_path[ index ], SW_SHOW );
						ShowWindow( g_hWnd_extensions[ index ], SW_SHOW );
						ShowWindow( g_hWnd_chk_folders[ index ], SW_SHOW );

						if ( g_show_details == true )
						{
							ShowWindow( g_hWnd_hashing[ index ], SW_SHOW );
							ShowWindow( g_hWnd_static_hash[ index ], SW_SHOW );
							ShowWindow( g_hWnd_static_count[ index ], SW_SHOW );
						}

						if ( index == 1 )
						{
							ShowWindow( g_hWnd_extended_information, SW_SHOW );
						}

						// If we're scanning, then enable the scan button. Otherwise, check for a valid path.
						EnableWindow( g_hWnd_btn_scan, ( g_kill_scan == false || SendMessage( g_hWnd_path[ index ], WM_GETTEXTLENGTH, 0, 0 ) >= 3 ) ? TRUE : FALSE );

						tab_index = index;
					}

					return FALSE;
                }
				break;
			}

			return FALSE;
		}
		break;

		case WM_SIZE:
		{
			RECT rc;
			GetClientRect( hWnd, &rc );

			// Allow our controls to move in relation to the parent window.
			HDWP hdwp = BeginDeferWindowPos( 4 );
			DeferWindowPos( hdwp, g_hWnd_tab, HWND_TOP, 10, 10, rc.right - 20, rc.bottom - 50, SWP_NOZORDER );
			DeferWindowPos( hdwp, g_hWnd_btn_details, HWND_TOP, 10, rc.bottom - 32, 100, 23, SWP_NOZORDER );
			DeferWindowPos( hdwp, g_hWnd_btn_scan, HWND_TOP, rc.right - 175, rc.bottom - 32, 80, 23, SWP_NOZORDER );
			DeferWindowPos( hdwp, g_hWnd_btn_cancel, HWND_TOP, rc.right - 90, rc.bottom - 32, 80, 23, SWP_NOZORDER );
			EndDeferWindowPos( hdwp );

			RECT rc_tab;
			GetClientRect( g_hWnd_tab, &rc );
			SendMessage( g_hWnd_tab, TCM_GETITEMRECT, 0, ( LPARAM )&rc_tab );

			SetWindowPos( g_hWnd_scan_tab, HWND_TOP, 10, ( rc_tab.bottom + rc_tab.top ) + 8, rc.right - 20, rc.bottom - ( ( rc_tab.bottom + rc_tab.top ) + 16 ), SWP_NOZORDER );

			return 0;
		}
		break;

		case WM_GETMINMAXINFO:
		{
			// Set the minimum dimensions that the window can be sized to.
			( ( MINMAXINFO * )lParam )->ptMinTrackSize.x = MIN_WIDTH;
			( ( MINMAXINFO * )lParam )->ptMinTrackSize.y = MIN_HEIGHT - ( g_show_details == true ? 25 : 115 );
			( ( MINMAXINFO * )lParam )->ptMaxTrackSize.y = MIN_HEIGHT - ( g_show_details == true ? 25 : 115 );

			return 0;
		}
		break;

		case WM_ACTIVATE:
		{
			// 0 = inactive, > 0 = active
			g_hWnd_active = ( wParam == 0 ? NULL : hWnd );

            return FALSE;
		}
		break;

		case WM_CLOSE:
		{
			g_kill_scan = true;

			// Reenable the main window.
			EnableWindow( g_hWnd_main, TRUE );
			SetForegroundWindow( g_hWnd_main );

			ShowWindow( hWnd, SW_HIDE );
		}
		break;

		case WM_ALERT:
		{
			MessageBoxA( hWnd, ( LPCSTR )lParam, PROGRAM_CAPTION_A, MB_APPLMODAL | ( wParam == 1 ? MB_ICONINFORMATION : MB_ICONWARNING ) | MB_SETFOREGROUND );
		}
		break;

		case WM_PROPAGATE:
		{
			if ( wParam == 1 )
			{
				g_kill_scan = false;

				EnableWindow( g_hWnd_path[ 0 ], FALSE );
				EnableWindow( g_hWnd_path[ 1 ], FALSE );
				EnableWindow( g_hWnd_load, FALSE );
				EnableWindow( g_hWnd_extensions[ 0 ], FALSE );
				EnableWindow( g_hWnd_extensions[ 1 ], FALSE );
				EnableWindow( g_hWnd_chk_folders[ 0 ], FALSE );
				EnableWindow( g_hWnd_chk_folders[ 1 ], FALSE );
				EnableWindow( g_hWnd_extended_information, FALSE );

				// We're scanning. Set the button's text to "Stop".
				SendMessageA( g_hWnd_btn_scan, WM_SETTEXT, 0, ( LPARAM )"Stop" );
			}
			else if ( wParam == 2 )
			{
				// Clear the current file info if we finished the scan without stopping.
				if ( g_kill_scan == false )
				{
					SendMessage( g_hWnd_hashing[ scan_type ], WM_SETTEXT, 0, 0 );
					SendMessageA( g_hWnd_static_hash[ scan_type ], WM_SETTEXT, 0, 0 );
				}

				g_kill_scan = true;

				EnableWindow( g_hWnd_path[ 0 ], TRUE );
				EnableWindow( g_hWnd_path[ 1 ], TRUE );
				EnableWindow( g_hWnd_load, TRUE );
				EnableWindow( g_hWnd_extensions[ 0 ], TRUE );
				EnableWindow( g_hWnd_extensions[ 1 ], TRUE );
				EnableWindow( g_hWnd_chk_folders[ 0 ], TRUE );
				EnableWindow( g_hWnd_chk_folders[ 1 ], TRUE );
				EnableWindow( g_hWnd_extended_information, TRUE );

				// We've stopped/finished scanning. Set the button's text to "Scan".
				SendMessageA( g_hWnd_btn_scan, WM_SETTEXT, 0, ( LPARAM )"Scan" );
				EnableWindow( g_hWnd_btn_scan, ( SendMessage( g_hWnd_path[ tab_index ], WM_GETTEXTLENGTH, 0, 0 ) >= 3 ) ? TRUE : FALSE );
			}
			else if ( wParam == 3 )
			{
				SendMessage( g_hWnd_hashing[ scan_type ], WM_SETTEXT, 0, lParam );
			}
			else if ( wParam == 4 )
			{
				SendMessageA( g_hWnd_static_hash[ scan_type ], WM_SETTEXT, 0, lParam );
			}
			else if ( wParam == 5 )
			{
				SendMessageA( g_hWnd_static_count[ scan_type ], WM_SETTEXT, 0, lParam );
			}
			else
			{
				g_kill_scan = true;

				// Reset text information.
				SendMessage( g_hWnd_hashing[ 0 ], WM_SETTEXT, 0, 0 );
				SendMessage( g_hWnd_hashing[ 1 ], WM_SETTEXT, 0, 0 );
				SendMessageA( g_hWnd_static_hash[ 0 ], WM_SETTEXT, 0, 0 );
				SendMessageA( g_hWnd_static_hash[ 1 ], WM_SETTEXT, 0, 0 );
				SendMessageA( g_hWnd_static_count[ 0 ], WM_SETTEXT, 0, 0 );
				SendMessageA( g_hWnd_static_count[ 1 ], WM_SETTEXT, 0, 0 );
				SendMessageA( g_hWnd_btn_scan, WM_SETTEXT, 0, ( LPARAM )"Scan" );
				EnableWindow( g_hWnd_btn_scan, ( SendMessage( g_hWnd_path[ tab_index ], WM_GETTEXTLENGTH, 0, 0 ) >= 3 ) ? TRUE : FALSE );

				SendMessage( g_hWnd_tab, TCM_SETCURFOCUS, 0, 0 );

				// Disable the main window.
				EnableWindow( g_hWnd_main, FALSE );

				// Set the window above all other windows.
				SetForegroundWindow( hWnd );
				SetWindowPos( hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
				ShowWindow( hWnd, SW_SHOW );
			}
		}
		break;

		default:
		{
			return DefWindowProc( hWnd, msg, wParam, lParam );
		}
		break;
	}
	return TRUE;
}
Exemple #12
0
static void test_IFolderView(void)
{
    IShellFolder *desktop, *folder;
    FOLDERSETTINGS settings;
    IShellView *view;
    IShellBrowser *browser;
    IFolderView2 *fv2;
    IFolderView *fv;
    HWND hwnd_view, hwnd_list;
    PITEMID_CHILD pidl;
    HRESULT hr;
    INT ret, count;
    POINT pt;
    LONG ref1, ref2;
    RECT r;

    hr = SHGetDesktopFolder(&desktop);
    ok(hr == S_OK, "got (0x%08x)\n", hr);

    hr = IShellFolder_CreateViewObject(desktop, NULL, &IID_IShellView, (void**)&view);
    ok(hr == S_OK, "got (0x%08x)\n", hr);

    hr = IShellView_QueryInterface(view, &IID_IFolderView, (void**)&fv);
    if (hr != S_OK)
    {
        win_skip("IFolderView not supported by desktop folder\n");
        IShellView_Release(view);
        IShellFolder_Release(desktop);
        return;
    }

    /* call methods before window creation */
    hr = IFolderView_GetSpacing(fv, NULL);
    ok(hr == S_FALSE || broken(hr == S_OK) /* win7 */, "got (0x%08x)\n", hr);

    pidl = (void*)0xdeadbeef;
    hr = IFolderView_Item(fv, 0, &pidl);
    ok(hr == E_INVALIDARG || broken(hr == E_FAIL) /* < Vista */, "got (0x%08x)\n", hr);
    ok(pidl == 0 || broken(pidl == (void*)0xdeadbeef) /* < Vista */, "got %p\n", pidl);

if (0)
{
    /* crashes on Vista and Win2k8 - List not created yet case */
    IFolderView_GetSpacing(fv, &pt);

    /* crashes on XP */
    IFolderView_GetSelectionMarkedItem(fv, NULL);
    IFolderView_GetFocusedItem(fv, NULL);

    /* crashes on Vista+ */
    IFolderView_Item(fv, 0, NULL);
}

    browser = IShellBrowserImpl_Construct();

    settings.ViewMode = FVM_ICON;
    settings.fFlags = 0;
    hwnd_view = (HWND)0xdeadbeef;
    r.left = r.top = 0;
    r.right = r.bottom = 100;
    hr = IShellView_CreateViewWindow(view, NULL, &settings, browser, &r, &hwnd_view);
    ok(hr == S_OK, "got (0x%08x)\n", hr);
    ok(IsWindow(hwnd_view), "got %p\n", hwnd_view);

    hwnd_list = subclass_listview(hwnd_view);
    if (!hwnd_list)
    {
        win_skip("Failed to subclass ListView control\n");
        IShellBrowser_Release(browser);
        IFolderView_Release(fv);
        IShellView_Release(view);
        IShellFolder_Release(desktop);
        return;
    }

    /* IFolderView::GetSpacing */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    hr = IFolderView_GetSpacing(fv, NULL);
    ok(hr == S_OK, "got (0x%08x)\n", hr);
    ok_sequence(sequences, LISTVIEW_SEQ_INDEX, empty_seq, "IFolderView::GetSpacing, empty", FALSE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    hr = IFolderView_GetSpacing(fv, &pt);
    ok(hr == S_OK, "got (0x%08x)\n", hr);
    /* fails with empty sequence on win7 for unknown reason */
    if (sequences[LISTVIEW_SEQ_INDEX]->count)
    {
        ok_sequence(sequences, LISTVIEW_SEQ_INDEX, folderview_getspacing_seq, "IFolderView::GetSpacing", FALSE);
        ok(pt.x > 0, "got %d\n", pt.x);
        ok(pt.y > 0, "got %d\n", pt.y);
        ret = SendMessageA(hwnd_list, LVM_GETITEMSPACING, 0, 0);
        ok(pt.x == LOWORD(ret) && pt.y == HIWORD(ret), "got (%d, %d)\n", LOWORD(ret), HIWORD(ret));
    }

    /* IFolderView::ItemCount */
if (0)
{
    /* crashes on XP */
    IFolderView_ItemCount(fv, SVGIO_ALLVIEW, NULL);
}

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    IFolderView_ItemCount(fv, SVGIO_ALLVIEW, &count);

    /* IFolderView::GetSelectionMarkedItem */
if (0)
{
    /* crashes on XP */
    IFolderView_GetSelectionMarkedItem(fv, NULL);
}

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    hr = IFolderView_GetSelectionMarkedItem(fv, &ret);
    if (count)
        ok(hr == S_OK, "got (0x%08x)\n", hr);
    else
        ok(hr == S_FALSE, "got (0x%08x)\n", hr);
    ok_sequence(sequences, LISTVIEW_SEQ_INDEX, folderview_getselectionmarked_seq,
                "IFolderView::GetSelectionMarkedItem", FALSE);

    /* IFolderView::GetFocusedItem */
    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    hr = IFolderView_GetFocusedItem(fv, &ret);
    if (count)
        ok(hr == S_OK, "got (0x%08x)\n", hr);
    else
        ok(hr == S_FALSE, "got (0x%08x)\n", hr);
    ok_sequence(sequences, LISTVIEW_SEQ_INDEX, folderview_getfocused_seq,
                "IFolderView::GetFocusedItem", FALSE);

    /* IFolderView::GetFolder, just return pointer */
if (0)
{
    /* crashes on XP */
    IFolderView_GetFolder(fv, NULL, (void**)&folder);
    IFolderView_GetFolder(fv, NULL, NULL);
}

    hr = IFolderView_GetFolder(fv, &IID_IShellFolder, NULL);
    ok(hr == E_POINTER, "got (0x%08x)\n", hr);

    ref1 = IShellFolder_AddRef(desktop);
    IShellFolder_Release(desktop);
    hr = IFolderView_GetFolder(fv, &IID_IShellFolder, (void**)&folder);
    ok(hr == S_OK, "got (0x%08x)\n", hr);
    ref2 = IShellFolder_AddRef(desktop);
    IShellFolder_Release(desktop);
    ok(ref1 == ref2 || ref1 + 1 == ref2, /* >= vista */
       "expected same refcount, got %d\n", ref2);
    ok(desktop == folder, "\n");

    hr = IFolderView_QueryInterface(fv, &IID_IFolderView2, (void**)&fv2);
    if (hr != S_OK)
        win_skip("IFolderView2 is not supported.\n");
    if (fv2) IFolderView2_Release(fv2);

    IShellBrowser_Release(browser);
    IFolderView_Release(fv);
    IShellView_Release(view);
    IShellFolder_Release(desktop);
}
Exemple #13
0
static void test_status_control(void)
{
    HWND hWndStatus;
    int r;
    int nParts[] = {50, 150, -1};
    int checkParts[] = {0, 0, 0};
    int borders[] = {0, 0, 0};
    RECT rc;
    CHAR charArray[20];
    HICON hIcon;
    char ch;
    char chstr[10] = "Inval id";
    COLORREF crColor = RGB(0,0,0);

    hWndStatus = create_status_control(WS_VISIBLE | SBT_TOOLTIPS, 0);

    /* Divide into parts and set text */
    r = SendMessageA(hWndStatus, SB_SETPARTS, 3, (LPARAM)nParts);
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_POPOUT|0,    (LPARAM)"First");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_OWNERDRAW|1, (LPARAM)"Second");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, SBT_NOBORDERS|2, (LPARAM)"Third");
    expect(TRUE,r);

    /* Get RECT Information */
    r = SendMessageA(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
    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);
    r = SendMessageA(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
    expect(FALSE,r);
    /* Get text length and text */
    r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 0, 0);
    expect(5,LOWORD(r));
    expect(SBT_POPOUT,HIWORD(r));
    r = SendMessageW(hWndStatus, WM_GETTEXTLENGTH, 0, 0);
    ok(r == 5 || broken(0x02000005 /* NT4 */), "Expected 5, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 1, 0);
    expect(0,LOWORD(r));
    expect(SBT_OWNERDRAW,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTLENGTHA, 2, 0);
    expect(5,LOWORD(r));
    expect(SBT_NOBORDERS,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 2, (LPARAM) charArray);
    ok(strcmp(charArray,"Third") == 0, "Expected Third, got %s\n", charArray);
    expect(5,LOWORD(r));
    expect(SBT_NOBORDERS,HIWORD(r));

    /* Get parts and borders */
    r = SendMessageA(hWndStatus, SB_GETPARTS, 3, (LPARAM)checkParts);
    ok(r == 3, "Expected 3, got %d\n", r);
    expect(50,checkParts[0]);
    expect(150,checkParts[1]);
    expect(-1,checkParts[2]);
    r = SendMessageA(hWndStatus, SB_GETBORDERS, 0, (LPARAM)borders);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);
    expect(0,borders[0]);
    expect(2,borders[1]);
    expect(2,borders[2]);

    /* Test resetting text with different characters */
    r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)"First@Again");
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, 1, (LPARAM)"Invalid\tChars\\7\7");
        expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_SETTEXTA, 2, (LPARAM)"InvalidChars\\n\n");
        expect(TRUE,r);

    /* Get text again */
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 0, (LPARAM) charArray);
    ok(strcmp(charArray,"First@Again") == 0, "Expected First@Again, got %s\n", charArray);
    expect(11,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 1, (LPARAM) charArray);
    ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);

    expect(16,LOWORD(r));
    expect(0,HIWORD(r));
    r = SendMessageA(hWndStatus, SB_GETTEXTA, 2, (LPARAM) charArray);
    ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);

    expect(15,LOWORD(r));
    expect(0,HIWORD(r));

    /* test more nonprintable chars */
    for(ch = 0x00; ch < 0x7F; ch++) {
        chstr[5] = ch;
        r = SendMessageA(hWndStatus, SB_SETTEXTA, 0, (LPARAM)chstr);
        expect(TRUE,r);
        r = SendMessageA(hWndStatus, SB_GETTEXTA, 0, (LPARAM)charArray);
        /* 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);
    }

    /* Set background color */
    crColor = SendMessageA(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
    ok(crColor == CLR_DEFAULT ||
       broken(crColor == RGB(0,0,0)), /* win95 */
       "Expected 0x%.8x, got 0x%.8x\n", CLR_DEFAULT, crColor);
    crColor = SendMessageA(hWndStatus, SB_SETBKCOLOR , 0, CLR_DEFAULT);
    ok(crColor == RGB(255,0,0) ||
       broken(crColor == RGB(0,0,0)), /* win95 */
       "Expected 0x%.8x, got 0x%.8x\n", RGB(255,0,0), crColor);

    /* Add an icon to the status bar */
    hIcon = LoadIconA(NULL, (LPCSTR)IDI_QUESTION);
    r = SendMessageA(hWndStatus, SB_SETICON, 1, 0);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_SETICON, 1, (LPARAM) hIcon);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_SETICON, 1, 0);
    ok(r != 0 ||
       broken(r == 0), /* win95 */
       "Expected non-zero, got %d\n", r);

    /* Set the Unicode format */
    r = SendMessageA(hWndStatus, SB_SETUNICODEFORMAT, FALSE, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_SETUNICODEFORMAT, TRUE, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETUNICODEFORMAT, 0, 0);
    ok(r == TRUE ||
       broken(r == FALSE), /* win95 */
       "Expected TRUE, got %d\n", r);

    /* Reset number of parts */
    r = SendMessageA(hWndStatus, SB_SETPARTS, 2, (LPARAM)nParts);
    expect(TRUE,r);
    r = SendMessageA(hWndStatus, SB_GETPARTS, 0, 0);
    ok(r == 2, "Expected 2, got %d\n", r);
    r = SendMessageA(hWndStatus, SB_SETPARTS, 0, 0);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETPARTS, 0, 0);
    ok(r == 2, "Expected 2, got %d\n", r);

    /* Set the minimum height and get rectangle information again */
    SendMessageA(hWndStatus, SB_SETMINHEIGHT, 50, 0);
    r = SendMessageA(hWndStatus, WM_SIZE, 0, 0);
    expect(0,r);
    r = SendMessageA(hWndStatus, SB_GETRECT, 0, (LPARAM)&rc);
    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);
    r = SendMessageA(hWndStatus, SB_GETRECT, -1, (LPARAM)&rc);
    expect(FALSE,r);
    r = SendMessageA(hWndStatus, SB_GETRECT, 3, (LPARAM)&rc);
    expect(FALSE,r);

    /* Set the ToolTip text */
    SendMessageA(hWndStatus, SB_SETTIPTEXTA, 0,(LPARAM) "Tooltip Text");
    lstrcpyA(charArray, "apple");
    SendMessageA(hWndStatus, SB_GETTIPTEXTA, MAKEWPARAM (0, 20),(LPARAM) charArray);
    ok(strcmp(charArray,"Tooltip Text") == 0 ||
        broken(!strcmp(charArray, "apple")), /* win95 */
        "Expected Tooltip Text, got %s\n", charArray);

    /* Make simple */
    SendMessageA(hWndStatus, SB_SIMPLE, TRUE, 0);
    r = SendMessageA(hWndStatus, SB_ISSIMPLE, 0, 0);
    ok(r == TRUE ||
       broken(r == FALSE), /* win95 */
       "Expected TRUE, got %d\n", r);

    DestroyWindow(hWndStatus);
}
Exemple #14
0
static void test_height(void)
{
    LOGFONTA lf;
    HFONT hFont, hFontSm;
    RECT rc1, rc2;
    HWND hwndStatus = CreateWindowA(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
        0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
    HDC hdc;

    GetClientRect(hwndStatus, &rc1);
    hFont = CreateFontA(32, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
        OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Tahoma");

    g_wmsize_count = 0;
    SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
    if (!g_wmsize_count)
    {
        skip("Status control not resized in win95, skipping broken tests.\n");
        return;
    }
    ok(g_wmsize_count > 0, "WM_SETFONT should issue WM_SIZE\n");

    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 42, rc2); /* GetTextMetrics returns invalid tmInternalLeading for this font */

    g_wmsize_count = 0;
    SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
    ok(g_wmsize_count > 0, "WM_SETFONT should issue WM_SIZE\n");

    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 42, rc2);

    /* minheight < fontsize - no effects*/
    SendMessageA(hwndStatus, SB_SETMINHEIGHT, 12, 0);
    SendMessageA(hwndStatus, WM_SIZE, 0, 0);
    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 42, rc2);

    /* minheight > fontsize - has an effect after WM_SIZE */
    SendMessageA(hwndStatus, SB_SETMINHEIGHT, 60, 0);
    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 42, rc2);
    SendMessageA(hwndStatus, WM_SIZE, 0, 0);
    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 62, rc2);

    /* font changed to smaller than minheight - has an effect */
    SendMessageA(hwndStatus, SB_SETMINHEIGHT, 30, 0);
    expect_rect(0, 0, 672, 62, rc2);
    SendMessageA(hwndStatus, WM_SIZE, 0, 0);
    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 42, rc2);
    hFontSm = CreateFontA(9, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
        OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Tahoma");
    SendMessageA(hwndStatus, WM_SETFONT, (WPARAM)hFontSm, TRUE);
    GetClientRect(hwndStatus, &rc2);
    expect_rect(0, 0, 672, 32, rc2);

    /* test the height formula */
    ZeroMemory(&lf, sizeof(lf));
    SendMessageA(hwndStatus, SB_SETMINHEIGHT, 0, 0);
    hdc = GetDC(NULL);

    /* 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));

    EnumFontFamiliesExA(hdc, &lf, (FONTENUMPROCA)check_height_family_enumproc, (LPARAM)hwndStatus, 0);
    ReleaseDC(NULL, hdc);

    DestroyWindow(hwndStatus);
    DeleteObject(hFont);
    DeleteObject(hFontSm);
}
Exemple #15
0
static DWORD WINAPI clipboard_thread(void *param)
{
    HWND win = param;
    BOOL r;
    HANDLE handle;
    UINT count, old_seq = 0, seq;

    if (pGetClipboardSequenceNumber) old_seq = pGetClipboardSequenceNumber();

    EnterCriticalSection(&clipboard_cs);
    SetLastError(0xdeadbeef);
    next_wnd = SetClipboardViewer(win);
    ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError());
    LeaveCriticalSection(&clipboard_cs);
    if (pAddClipboardFormatListener)
    {
        r = pAddClipboardFormatListener(win);
        ok( r, "AddClipboardFormatListener failed err %d\n", GetLastError());
    }

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( seq == old_seq, "sequence changed\n" );
    }
    count = SendMessageA( win, WM_USER + 1, 0, 0 );
    ok( count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    r = OpenClipboard(win);
    ok(r, "OpenClipboard failed: %d\n", GetLastError());

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( seq == old_seq, "sequence changed\n" );
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    r = EmptyClipboard();
    ok(r, "EmptyClipboard failed: %d\n", GetLastError());

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );
    count = SendMessageA( win, WM_USER+3, 0, 0 );
    ok( !count, "WM_DESTROYCLIPBOARD received\n" );

    r = EmptyClipboard();
    ok(r, "EmptyClipboard failed: %d\n", GetLastError());
    /* sequence changes again, even though it was already empty */
    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );
    count = SendMessageA( win, WM_USER+3, 0, 0 );
    ok( count, "WM_DESTROYCLIPBOARD not received\n" );

    handle = SetClipboardData( CF_TEXT, create_text() );
    ok(handle != 0, "SetClipboardData failed: %d\n", GetLastError());

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        todo_wine ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    SetClipboardData( CF_UNICODETEXT, 0 );

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        todo_wine ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    SetClipboardData( CF_UNICODETEXT, 0 );  /* same data again */

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        todo_wine ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    EnterCriticalSection(&clipboard_cs);
    r = CloseClipboard();
    ok(r, "CloseClipboard failed: %d\n", GetLastError());
    LeaveCriticalSection(&clipboard_cs);

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( count, "WM_DRAWCLIPBOARD not received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    todo_wine ok( count || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" );

    r = OpenClipboard(win);
    ok(r, "OpenClipboard failed: %d\n", GetLastError());

    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( seq == old_seq, "sequence changed\n" );
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    SetClipboardData( CF_WAVE, 0 );
    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        todo_wine ok( (int)(seq - old_seq) > 0, "sequence unchanged\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    r = CloseClipboard();
    ok(r, "CloseClipboard failed: %d\n", GetLastError());
    if (pGetClipboardSequenceNumber)
    {
        /* no synthesized format, so CloseClipboard doesn't change the sequence */
        seq = pGetClipboardSequenceNumber();
        todo_wine ok( seq == old_seq, "sequence changed\n" );
        old_seq = seq;
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( count, "WM_DRAWCLIPBOARD not received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    todo_wine ok( count || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" );

    r = OpenClipboard(win);
    ok(r, "OpenClipboard failed: %d\n", GetLastError());
    r = CloseClipboard();
    ok(r, "CloseClipboard failed: %d\n", GetLastError());
    /* nothing changed */
    if (pGetClipboardSequenceNumber)
    {
        seq = pGetClipboardSequenceNumber();
        ok( seq == old_seq, "sequence changed\n" );
    }
    count = SendMessageA( win, WM_USER+1, 0, 0 );
    ok( !count, "WM_DRAWCLIPBOARD received\n" );
    count = SendMessageA( win, WM_USER+2, 0, 0 );
    ok( !count, "WM_CLIPBOARDUPDATE received\n" );

    r = OpenClipboard(0);
    ok(r, "OpenClipboard failed: %d\n", GetLastError());
    r = EmptyClipboard();
    ok(r, "EmptyClipboard failed: %d\n", GetLastError());
    r = CloseClipboard();
    ok(r, "CloseClipboard failed: %d\n", GetLastError());

    r = PostMessageA(win, WM_USER, 0, 0);
    ok(r, "PostMessage failed: %d\n", GetLastError());
    return 0;
}
BOOL CALLBACK NavDialog::run_dlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	long yPos;
    int LineStart;
    int LineVisible;
    int Delta;

	switch (Message) 
	{
		case WM_INITDIALOG:
		{
            // Here, I modify window styles (set H and V redraw)
            SetClassLong(hWnd, GCL_STYLE, CS_HREDRAW | CS_VREDRAW);
            m_hWnd = hWnd;
            ReadyToDraw = FALSE;
    		break;
		}

	    case WM_PAINT:
		{
            ReadyToDraw = TRUE;
            return OnPaint(hWnd);
		}

		case WM_NOTIFY:
		{
			//return DockingDlgInterface::run_dlgProc(hWnd, Message, wParam, lParam);
			break;
		}

		case WM_DESTROY:
		{
            // Delete objects
            DeleteDC(m_hMemDC1);
            DeleteDC(m_hMemDC2);
            DeleteDC(m_hMemDCView);
            DeleteObject(m_hMemBMP1);
            DeleteObject(m_hMemBMP2);
            DeleteObject(m_hMemBMPView);

            PostQuitMessage(0); 
			break;
		}

        case WM_LBUTTONDOWN:
            POINT pt;
            SetCapture(hWnd);
            yPos = HIWORD(lParam);
            current_line = yPos * m_ScaleFactor;
            LineVisible = SendMessageA(_nppData._scintillaMainHandle, SCI_LINESONSCREEN, 0, 0);
            LineStart = SendMessageA(_nppData._scintillaMainHandle, SCI_GETFIRSTVISIBLELINE, 0, 0);
            Delta = current_line - LineVisible/2 - LineStart;
            SendMessageA(_nppData._scintillaMainHandle, SCI_LINESCROLL, 0, (LPARAM)Delta);
            SendMessageA(_nppData._scintillaMainHandle, SCI_GOTOLINE, (WPARAM)current_line, 0);
            break;

        case WM_LBUTTONUP:
            ReleaseCapture();
            break;

        case WM_MOUSEMOVE:
            long start;
			long next_line;
            int LineStart;
            int LineVisible;
            if (GetCapture() == hWnd) 
            { 
                yPos = HIWORD(lParam);
                next_line = yPos * m_ScaleFactor;
				Delta = next_line - current_line;
				SendMessageA(_nppData._scintillaMainHandle, SCI_LINESCROLL, 0, (LPARAM)Delta);
				SendMessageA(_nppData._scintillaMainHandle, SCI_GOTOLINE, (WPARAM)next_line, 0);
				current_line = next_line;
            }
            break;

		default:
			return DockingDlgInterface::run_dlgProc(hWnd, Message, wParam, lParam);
	}

	return FALSE;
}
Exemple #17
0
void CluiProtocolStatusChanged( int parStatus, const char* szProto )
{
	int protoCount,i;
	PROTOACCOUNT **accs;
	int *partWidths,partCount;
	int borders[3];
	int status;
	int toshow;
	wchar_t *szStatus = NULL;
	char *szMaxProto = NULL;
	int maxOnline = 0, onlineness = 0;
	WORD maxStatus = ID_STATUS_OFFLINE, wStatus = ID_STATUS_OFFLINE;
	DBVARIANT dbv = {0};
	int iIcon = 0;
	HICON hIcon = 0;
	int rdelta = Skin::metrics.cLeft + Skin::metrics.cRight;
	BYTE windowStyle;

	if (pcli->hwndStatus == 0 || cfg::shutDown)
		return;

	Proto_EnumAccounts( &protoCount, &accs );
	if (protoCount == 0)
		return;

	FreeProtocolData();
	cfg::maxStatus = ID_STATUS_OFFLINE;
	g_maxProto[0] = 0;

	SendMessage(pcli->hwndStatus,SB_GETBORDERS,0,(LPARAM)&borders);

	partWidths=(int*)_alloca(( protoCount+1)*sizeof(int));

	if (cfg::dat.bEqualSections) {
		RECT rc;
		int part;
		GetClientRect(pcli->hwndStatus,&rc);
		rc.right-=borders[0]*2;
		toshow=0;
		for ( i=0; i < protoCount; i++ )
			if ( pcli->pfnGetProtocolVisibility( accs[i]->szModuleName ))
				toshow++;

		if ( toshow > 0 ) {
			for ( part=0, i=0; i < protoCount; i++ ) {
				if ( !pcli->pfnGetProtocolVisibility( accs[i]->szModuleName ))
					continue;

				partWidths[ part ] = ((rc.right-rc.left-rdelta)/toshow)*(part+1) + Skin::metrics.cLeft;
				if ( part == toshow-1 )
					partWidths[ part ] += Skin::metrics.cRight;
				part++;
			}
		}
		partCount=toshow;
	}
	else {
		HDC hdc;
		SIZE textSize;
		BYTE showOpts = cfg::getByte("CLUI","SBarShow",1);
		int x;
		HFONT hofont;
		wchar_t szName[32];
		PROTOACCOUNT* pa;

		hdc=GetDC(NULL);
		hofont = reinterpret_cast<HFONT>(SelectObject(hdc,(HFONT)SendMessage(pcli->hwndStatus,WM_GETFONT,0,0)));

		for ( partCount=0,i=0; i < protoCount; i++ ) {      //count down since built in ones tend to go at the end
			int idx = pcli->pfnGetAccountIndexByPos( i );
			if ( idx == -1 )
				continue;

			pa = accs[idx];
			if ( !pcli->pfnGetProtocolVisibility( pa->szModuleName ))
				continue;

			x=2;
			if (showOpts & 1)
				x += 16;
			if (showOpts & 2) {
				lstrcpyn( szName, pa->tszAccountName, _countof(szName));
				szName[ _countof(szName)-1 ] = 0;
				if (( showOpts & 4 ) && lstrlen(szName) < sizeof(szName)-1 )
					lstrcat( szName, _T(" "));
				GetTextExtentPoint32( hdc, szName, lstrlen(szName), &textSize );
				x += textSize.cx + GetSystemMetrics(SM_CXBORDER) * 4; // The SB panel doesnt allocate enough room
			}
			if (showOpts & 4) {
				wchar_t* modeDescr = pcli->pfnGetStatusModeDescription( CallProtoService(accs[i]->szModuleName,PS_GETSTATUS,0,0 ), 0 );
				GetTextExtentPoint32(hdc, modeDescr, lstrlen(modeDescr), &textSize );
				x += textSize.cx + GetSystemMetrics(SM_CXBORDER) * 4; // The SB panel doesnt allocate enough room
			}
			partWidths[partCount]=(partCount?partWidths[partCount-1]:Skin::metrics.cLeft)+ x + 2;
			partCount++;
		}
		SelectObject(hdc,hofont);
		ReleaseDC(NULL,hdc);
	}
	if (partCount==0) {
		SendMessage(pcli->hwndStatus,SB_SIMPLE,TRUE,0);
		return;
	}
	SendMessage(pcli->hwndStatus,SB_SIMPLE,FALSE,0);

	partWidths[partCount-1]=-1;
	windowStyle = Skin::metrics.bWindowStyle;
	//SendMessage(pcli->hwndStatus,SB_SETMINHEIGHT, 12 + ((windowStyle == SETTING_WINDOWSTYLE_THINBORDER || windowStyle == SETTING_WINDOWSTYLE_NOBORDER) ? 3 : 0), 0);
	SendMessage(pcli->hwndStatus, SB_SETPARTS, partCount, (LPARAM)partWidths);

	for ( partCount=0, i=0; i < protoCount; i++ ) {      //count down since built in ones tend to go at the end
		ProtocolData *PD;
		PROTOACCOUNT *pa;
		int caps1, caps2;

		int idx = pcli->pfnGetAccountIndexByPos( i );
		if ( idx == -1 )
			continue;

		pa = accs[idx];
		if ( !pcli->pfnGetProtocolVisibility( pa->szModuleName ))
			continue;

		status = CallProtoService( pa->szModuleName,PS_GETSTATUS,0,0);
		PD = ( ProtocolData* )mir_alloc(sizeof(ProtocolData));
		PD->RealName = mir_strdup( pa->szModuleName );
		PD->protopos = partCount;
		{
			int flags;
			flags = SBT_OWNERDRAW;
			if ( cfg::getByte("CLUI","SBarBevel", 1)==0 )
				flags |= SBT_NOBORDERS;
			SendMessageA( pcli->hwndStatus, SB_SETTEXTA, partCount|flags,(LPARAM)PD );
		}
		caps2 = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
		caps1 = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
		if((caps1 & PF1_IM) && (caps2 & (PF2_LONGAWAY | PF2_SHORTAWAY))) {
			onlineness = CLC::getStatusOnlineness(status, false);
			if(onlineness > maxOnline) {
				maxStatus = status;
				maxOnline = onlineness;
				szMaxProto = pa->szModuleName;
			}
		}
		partCount++;
	}
	// update the clui button

	if (!db_get(NULL, "CList", "PrimaryStatus", &dbv)) {
		if (dbv.type == DBVT_ASCIIZ && lstrlenA(dbv.pszVal) > 1) {
			wStatus = (WORD) CallProtoService(dbv.pszVal, PS_GETSTATUS, 0, 0);
			iIcon = CLC::IconFromStatusMode(dbv.pszVal, (int) wStatus, 0, &hIcon);
		}
		mir_free(dbv.pszVal);
	} else {
		wStatus = maxStatus;
		iIcon = CLC::IconFromStatusMode((wStatus >= ID_STATUS_CONNECTING && wStatus < ID_STATUS_OFFLINE) ? szMaxProto : NULL, (int) wStatus, 0, &hIcon);
		cfg::maxStatus = (int)wStatus;
		if(szMaxProto) {
			lstrcpynA(g_maxProto, szMaxProto, 100);
			g_maxProto[99] = 0;
		}
	}
	/*
	* this is used globally (actually, by the clist control only) to determine if
	* any protocol is "in connection" state. If true, then the clist discards redraws
	* and uses timer based sort and redraw handling. This can improve performance
	* when connecting multiple protocols significantly.
	*/
	//g_isConnecting = (wStatus >= ID_STATUS_CONNECTING && wStatus < ID_STATUS_OFFLINE);

	szStatus = pcli->pfnGetStatusModeDescription(wStatus, 0);

	/*
	* set the global status icon and display the global (most online) status mode on the
	* status mode button
	*/

	if (szStatus) {
		if(pcli->hwndContactList && IsWindow(GetDlgItem(pcli->hwndContactList, IDC_TBGLOBALSTATUS)) && IsWindow(GetDlgItem(pcli->hwndContactList, IDC_TBTOPSTATUS))) {
			SendMessage(GetDlgItem(pcli->hwndContactList, IDC_TBGLOBALSTATUS), WM_SETTEXT, 0, (LPARAM) szStatus);
			if(!hIcon) {
				SendMessage(GetDlgItem(pcli->hwndContactList, IDC_TBGLOBALSTATUS), BM_SETIMLICON, (WPARAM) CLC::hClistImages, (LPARAM) iIcon);
                if(CLUI::buttonItems == NULL)
                    SendMessage(GetDlgItem(pcli->hwndContactList, IDC_TBTOPSTATUS), BM_SETIMLICON, (WPARAM) CLC::hClistImages, (LPARAM) iIcon);
			}
			else {
				SendMessage(GetDlgItem(pcli->hwndContactList, IDC_TBGLOBALSTATUS), BM_SETIMAGE, IMAGE_ICON, (LPARAM) hIcon);
                if(CLUI::buttonItems == NULL)
                    SendMessage(GetDlgItem(pcli->hwndContactList, IDC_TBTOPSTATUS), BM_SETIMAGE, IMAGE_ICON, (LPARAM) hIcon);
			}
			InvalidateRect(GetDlgItem(pcli->hwndContactList, IDC_TBGLOBALSTATUS), NULL, TRUE);
			InvalidateRect(GetDlgItem(pcli->hwndContactList, IDC_TBTOPSTATUS), NULL, TRUE);
			SFL_Update(hIcon, iIcon, CLC::hClistImages, szStatus, TRUE);
	}	}
    return;
}
Exemple #18
0
DWORD WINAPI ProgressMainLoop(LPVOID pv)
{    
    MSG msg;     
    DWORD cyVScroll;
    HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); //(ANSI_FIXED_FONT);
    WCHAR wzStr[1024];

    if(g_fInitCommonControls)
    {
        InitCommonControls();
        g_fInitCommonControls = FALSE;
    }
    g_ulCount = 0;
    if(g_fRegisterClass)
    {
        _ASSERTE(g_hResources != NULL);
        WNDCLASSW  wndClass;

        wndClass.style          = CS_HREDRAW|CS_VREDRAW|CS_NOCLOSE;
        wndClass.lpfnWndProc    = ProgBoxWndProc;
        wndClass.cbClsExtra     = 0;
        wndClass.cbWndExtra     = 0;
        wndClass.hInstance      = g_hInstance;
        wndClass.hIcon          = WszLoadIcon(g_hResources,MAKEINTRESOURCE(IDI_ICON2));
        wndClass.hCursor        = NULL;
        wndClass.hbrBackground  = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
        wndClass.lpszMenuName   = NULL; 
        wndClass.lpszClassName  = L"ProgressBox";

        if (WszRegisterClass(&wndClass) == 0) return 0;

        g_fRegisterClass = FALSE;
    }
    cyVScroll = GetSystemMetrics(SM_CYVSCROLL); 
    if(g_hwndProgBox = WszCreateWindowEx (0,
                                    RstrW(IDS_PROGRESSBOX), //"ProgressBox",
                                    RstrW(IDS_DISASSEMBLING), //"Disassembling",
                                    WS_VISIBLE | WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_CLIPCHILDREN,
                                    400, 200, 400, 8*cyVScroll,
                                    HWND_DESKTOP, 
                                    (HMENU)0, 
                                    g_hInstance,
                                    NULL))
    {
        GetClientRect(g_hwndProgBox, &rcClient);
        
        if(g_hwndFromFile = WszCreateWindowEx (0,
                                        L"STATIC",
                                        L"",
                                        WS_CHILD|WS_VISIBLE|SS_CENTER,
                                        rcClient.left, rcClient.bottom-6*cyVScroll,rcClient.right, cyVScroll,
                                        g_hwndProgBox, 
                                        (HMENU)0, 
                                        g_hInstance,
                                        NULL))
        {
            SendMessageA(g_hwndFromFile,WM_SETFONT,(LPARAM)hFont,FALSE);
            WCHAR* wzFileName = UtfToUnicode(g_szInputFile);
            if(wcslen(wzFileName) <= 60) swprintf_s(wzStr,1024,RstrW(IDS_PB_FILE) /*"File  %s"*/,wzFileName);
            else 
            {
                WCHAR * p=wzFileName;
                while(p = wcschr(p,L'\\'))
                {
                    if(wcslen(p) <= 60) break;
                    p++;
                }
                if(p == NULL) p = &wzFileName[wcslen(wzFileName)-50];
                swprintf_s(wzStr,1024,RstrW(IDS_PB_FILE1) /*"File ...%s"*/,p);
            }
            WszSendMessage(g_hwndFromFile, WM_SETTEXT,0,(LPARAM)wzStr);
        }
        if(g_hwndToFile = WszCreateWindowEx (0,
                                        L"STATIC",
                                        L"",
                                        WS_CHILD|WS_VISIBLE|SS_CENTER,
                                        rcClient.left, rcClient.bottom-5*cyVScroll,rcClient.right, cyVScroll,
                                        g_hwndProgBox, 
                                        (HMENU)0, 
                                        g_hInstance,
                                        NULL))
        {
            SendMessageA(g_hwndToFile,WM_SETFONT,(LPARAM)hFont,FALSE);
            WCHAR* wzFileName = UtfToUnicode(g_szOutputFile);
            if(wcslen(wzFileName) <= 60) swprintf_s(wzStr,1024,RstrW(IDS_PB_TOFILE) /*"To file  %s"*/,wzFileName);
            else 
            {
                WCHAR * p=wzFileName;
                while(p = wcschr(p,L'\\'))
                {
                    if(wcslen(p) <= 60) break;
                    p++;
                }
                if(p == NULL) p = &wzFileName[wcslen(wzFileName)-50];
                swprintf_s(wzStr,1024,RstrW(IDS_PB_TOFILE1) /*"To file ...%s"*/,p);
            }
            WszSendMessage(g_hwndToFile, WM_SETTEXT,0,(LPARAM)wzStr);
        }
        if(g_hwndTally = WszCreateWindowEx (0,
                                        L"STATIC",
                                        L"",
                                        WS_CHILD|WS_VISIBLE|SS_CENTER,
                                        rcClient.left, rcClient.bottom-4*cyVScroll,rcClient.right, cyVScroll,
                                        g_hwndProgBox, 
                                        (HMENU)0, 
                                        g_hInstance,
                                        NULL))
        {
            SendMessageA(g_hwndTally,WM_SETFONT,(LPARAM)hFont,FALSE);
            if(g_ulCount <= g_NumClasses) swprintf_s(wzStr,1024,RstrW(IDS_PB_CLASSESDONE) /*"%d classes, %d done"*/,g_NumClasses,g_ulCount);
            else swprintf_s(wzStr,1024,RstrW(IDS_PB_GLOBALSDONE) /*"%d global methods, %d done"*/,g_ulRange-g_NumClasses,g_ulCount-g_NumClasses);
            WszSendMessage(g_hwndTally, WM_SETTEXT,0,(LPARAM)wzStr);
        }
        if(g_hwndProgress = WszCreateWindowEx (0,
                                        PROGRESS_CLASS,
                                        L"",
                                        WS_CHILD|WS_VISIBLE|SS_CENTER, // SS_CENTER gives smooth progress and solid bar
                                        rcClient.left, rcClient.bottom-3*cyVScroll,rcClient.right, cyVScroll,
                                        g_hwndProgBox, 
                                        (HMENU)0, 
                                        g_hInstance,
                                        NULL))
        {
            // Set the range for the progress bar.
            SendMessageA (g_hwndProgress, PBM_SETRANGE, 0L, MAKELPARAM(0, g_ulRange));
            // Set the step.
            SendMessageA (g_hwndProgress, PBM_SETSTEP, (WPARAM)1, 0L);
        }
        if(g_hwndCancel = WszCreateWindowEx (0,
                                        L"BUTTON",
                                        RstrW(IDS_PB_CANCEL), //"Cancel",
                                        WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON|BS_TEXT,
                                        rcClient.left+150, rcClient.bottom-3*cyVScroll/2,rcClient.right-300, 4*cyVScroll/3,
                                        g_hwndProgBox, 
                                        (HMENU)IDC_CANCEL, 
                                        g_hInstance,
                                        NULL))
        {
            SendMessageA(g_hwndCancel,WM_SETFONT,(LPARAM)hFont,FALSE);
        }
    }
    SetEvent(g_hThreadReady);
    while (WszGetMessage(&msg, NULL, 0, 0)) 
    { 
        TranslateMessage(&msg); 
        WszDispatchMessage(&msg); 
    }
    return 0;
}
Exemple #19
0
static void test_custom_default_button(void)
{
    HWND hdlg;
    PROPSHEETPAGEA psp[1];
    PROPSHEETHEADERA psh;
    MSG msg;
    LRESULT result;

    psp[0].dwSize = sizeof (PROPSHEETPAGEA);
    psp[0].dwFlags = PSP_USETITLE;
    psp[0].hInstance = GetModuleHandleA(NULL);
    U(psp[0]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON);
    U2(psp[0]).pszIcon = NULL;
    psp[0].pfnDlgProc = page_with_custom_default_button_dlg_proc;
    psp[0].pszTitle = "Page1";
    psp[0].lParam = 0;

    psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
    psh.dwFlags = PSH_PROPSHEETPAGE | PSH_MODELESS;
    psh.hwndParent = GetDesktopWindow();
    psh.hInstance = GetModuleHandleA(NULL);
    U(psh).pszIcon = NULL;
    psh.pszCaption =  "PropertySheet1";
    psh.nPages = 1;
    U3(psh).ppsp = psp;
    U2(psh).nStartPage = 0;

    /* The goal of the test is to make sure that the Add button is pressed
     * when the ENTER key is pressed and a different control, a combobox,
     * has the keyboard focus. */
    add_button_has_been_pressed = FALSE;

    /* Create the modeless property sheet. */
    hdlg = (HWND)PropertySheetA(&psh);
    ok(hdlg != INVALID_HANDLE_VALUE, "Cannot create the property sheet\n");

    /* Set the Add button as the default button. */
    SendMessageA(hdlg, DM_SETDEFID, (WPARAM)IDC_PS_PUSHBUTTON1, 0);

    /* Make sure the default button is the Add button. */
    result = SendMessageA(hdlg, DM_GETDEFID, 0, 0);
    ok(DC_HASDEFID == HIWORD(result), "The property sheet does not have a default button\n");
    ok(IDC_PS_PUSHBUTTON1 == LOWORD(result), "The default button is not the Add button\n");

    /* At this point, the combobox should have keyboard focus, so we press ENTER.
     * Pull the lever, Kronk! */
    keybd_event(VK_RETURN, 0, 0, 0);

    /* Process all the messages in the queue for this thread. */
    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
    {
        /* (!PropSheet_IsDialogMessage(hdlg, &msg)) */
        if (!((BOOL)SendMessageA(hdlg, PSM_ISDIALOGMESSAGE, 0, (LPARAM)&msg)))
        {
            TranslateMessage(&msg);
            DispatchMessageA(&msg);
        }
    }

    ok(add_button_has_been_pressed, "The Add button has not been pressed!\n");

    DestroyWindow(hdlg);
}
Exemple #20
0
/**
 * 
 *  rct2: 0x00407F2E
 */
void osinterface_progressbar_setmax(int max)
{
	SendMessageA(RCT2_GLOBAL(RCT2_ADDRESS_PROGRESSBAR_HWND, HWND), PBM_SETRANGE, MAKEWPARAM(0, max), 0);
	SendMessageA(RCT2_GLOBAL(RCT2_ADDRESS_PROGRESSBAR_HWND, HWND), PBM_SETSTEP, 1, 0);
}
Exemple #21
0
static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static char path[XFIRE_MAX_STATIC_STRING_LEN] = "";
	static WCHAR wpath[256];
	static HICON gameicon = 0;
	static HICON voiceicon = 0;
	static MCONTACT uhandle = 0;
	static HWND listbox;
	LVCOLUMNA pcol;

	switch (msg)
	{
	case WM_INITDIALOG:
	{
		TranslateDialogDefault(hwndDlg);

		ghwndDlg = hwndDlg;

		listbox = GetDlgItem(hwndDlg, IDC_GAMEINFOLIST);
		pcol.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
		pcol.pszText = "Key";
		pcol.cx = 65;
		pcol.fmt = LVCFMT_LEFT;
		SendMessageA(listbox, LVM_INSERTCOLUMNA, 1, (LPARAM)&pcol);
		pcol.cx = 80;
		pcol.pszText = "Value";
		SendMessageA(listbox, LVM_INSERTCOLUMNA, 2, (LPARAM)&pcol);

		HFONT hFont;
		LOGFONT lfFont;

		memset(&lfFont, 0x00, sizeof(lfFont));
		memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);

		lfFont.lfHeight = 13;
		lfFont.lfWeight = FW_BOLD;
		lfFont.lfCharSet = ANSI_CHARSET;
		lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
		lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
		lfFont.lfQuality = DEFAULT_QUALITY;

		// Create the font from the LOGFONT structure passed.
		hFont = CreateFontIndirect(&lfFont);

		SendMessageA(listbox, WM_SETFONT, (WPARAM)hFont, TRUE);

		return TRUE;
	}
	case WM_CTLCOLORSTATIC:
	{
		break;
	}

	case WM_NOTIFY:
	{
		switch (((LPNMHDR)lParam)->idFrom)
		{

		case 0:
		{
			switch (((LPNMHDR)lParam)->code)
			{

			case PSN_INFOCHANGED:
			{
				char* szProto;
				MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
				uhandle = hContact; //handle sichern

				if (hContact == NULL)
					szProto = protocolname;
				else
					szProto = GetContactProto(hContact);

				if (szProto == NULL)
					break;

				//alle items aus der liste entfernen
				SendMessage(listbox, LVM_DELETEALLITEMS, 0, 0);

				if (hContact)
				{
					DBVARIANT dbv;
					if (!db_get(hContact, protocolname, "Username", &dbv))
					{
						int usernamesize = mir_strlen(dbv.pszVal) + 1;
						char* username = new char[usernamesize];
						if (username)
						{
							strcpy_s(username, usernamesize, dbv.pszVal);
							mir_forkthread(LoadProfilStatus, (LPVOID)username);
						}
						//LoadProfilStatus
						db_free(&dbv);
					}

					if (!db_get(hContact, protocolname, "GameInfo", &dbv))
					{
						setGameInfo(listbox, dbv.pszVal);
						db_free(&dbv);
					}

					addToList(listbox, hContact, "Servername", "ServerName");
					addToList(listbox, hContact, "GameType", "GameType");
					addToList(listbox, hContact, "Map", "Map");
					addToList(listbox, hContact, "Players", "Players");

					SetItemTxt(hwndDlg, IDC_DNICK, "Nick", hContact, 0);
					SetItemTxt(hwndDlg, IDC_DUSERNAME, "Username", hContact, 0);

					SetItemTxt(hwndDlg, IDC_GIP, "ServerIP", hContact, 0);
					SetItemTxt(hwndDlg, IDC_VIP, "VServerIP", hContact, 0);
					SetItemTxt(hwndDlg, IDC_GPORT, "Port", hContact, 1);
					SetItemTxt(hwndDlg, IDC_VPORT, "VPort", hContact, 1);

					SetItemTxt(hwndDlg, IDC_GAME, "RGame", hContact, 0);
					SetItemTxt(hwndDlg, IDC_VNAME, "RVoice", hContact, 0);

					//render icons
					{
						DBVARIANT dbv;

						if (!db_get(hContact, protocolname, "GameId", &dbv))
						{
							SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
							db_free(&dbv);
						}
						if (!db_get(hContact, protocolname, "VoiceId", &dbv))
						{
							SendDlgItemMessage(hwndDlg, IDC_VOICEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
							db_free(&dbv);
						}

						if (db_get(hContact, protocolname, "ServerIP", &dbv))
						{
							EnableWindow(GetDlgItem(hwndDlg, IDC_COPYGAME), FALSE);
							db_free(&dbv);
						}
						if (db_get(hContact, protocolname, "VServerIP", &dbv))
						{
							EnableWindow(GetDlgItem(hwndDlg, IDC_COPYVOICE), FALSE);
							db_free(&dbv);
						}

						//ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE)
					}
				}
			}
				break;
			}
		}
			break;
		}
	}
		break;
	case WM_COMMAND:
	{
		switch (wParam)
		{
		case IDC_COPYGAME:
			GetIPPortUDetails(uhandle, "ServerIP", "Port");
			break;
		case IDC_COPYVOICE:
			GetIPPortUDetails(uhandle, "VServerIP", "VPort");
			break;
		}
	}
	}
	return FALSE;
}
Exemple #22
0
/**
 * 
 *  rct2: 0x00407F60
 */
void osinterface_progressbar_setpos(int pos)
{
	SendMessageA(RCT2_GLOBAL(RCT2_ADDRESS_PROGRESSBAR_HWND, HWND), PBM_SETPOS, MAKEWPARAM(pos, 0), 0);
}
Exemple #23
0
static void layout_test(void)
{
    HWND hRebar = NULL;
    REBARBANDINFO rbi;
    HIMAGELIST himl;
    REBARINFO ri;

    rebuild_rebar(&hRebar);
    check_sizes();
    rbi.cbSize = sizeof(rbi);
    rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
    rbi.cx = 200;
    rbi.cxMinChild = 100;
    rbi.cyMinChild = 30;
    rbi.hwndChild = NULL;
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.fMask |= RBBIM_STYLE;
    rbi.fStyle = RBBS_CHILDEDGE;
    SendMessageA(hRebar, RB_INSERTBAND, -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_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.fStyle = RBBS_CHILDEDGE;
    rbi.cx = 68;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    SetWindowLong(hRebar, GWL_STYLE, GetWindowLong(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_SETBANDINFO, 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_INSERTBAND, 1, (LPARAM)&rbi);
    check_sizes();

    rbi.fMask = RBBIM_STYLE;
    rbi.fStyle = RBBS_HIDDEN;
    SendMessageA(hRebar, RB_SETBANDINFO, 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();

    rebuild_rebar(&hRebar);
    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_LoadImage(LoadLibrary("comctl32"), MAKEINTRESOURCE(121), 24, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
    ri.cbSize = sizeof(ri);
    ri.fMask = RBIM_IMAGELIST;
    ri.himl = himl;
    ok(SendMessage(hRebar, RB_SETBARINFO, 0, (LPARAM)&ri), "RB_SETBARINFO failed\n");
    rbi.fMask = RBBIM_IMAGE;
    rbi.iImage = 1;
    SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi);
    check_sizes();

    /* after removing it everything is back to normal*/
    rbi.iImage = -1;
    SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi);
    check_sizes();

    /* Only -1 means that the image is not present. Other invalid values increase the height */
    rbi.iImage = -2;
    SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi);
    check_sizes();

    /* VARHEIGHT resizing test on a horizontal rebar */
    rebuild_rebar(&hRebar);
    SetWindowLong(hRebar, GWL_STYLE, GetWindowLong(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_INSERTBAND, -1, (LPARAM)&rbi);

    rbi.cyChild = 50;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);

    rbi.cyMinChild = 40;
    rbi.cyChild = 50;
    rbi.cyIntegral = 5;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    /* VARHEIGHT resizing on a vertical rebar */
    rebuild_rebar(&hRebar);
    SetWindowLong(hRebar, GWL_STYLE, GetWindowLong(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_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.cyChild = 50;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.cyMinChild = 40;
    rbi.cyChild = 50;
    rbi.cyIntegral = 5;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    DestroyWindow(hRebar);
}
Exemple #24
0
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     // код уведомления
	UINT idChild = LOWORD(wParam);     // идентификатор дочернего окна
	HWND hwndChild = (HWND)lParam;     // дескриптор дочернего 
	PAINTSTRUCT ps;
	
	switch (message){
	case WM_CREATE:{
		PWINDOWINFO pwi = malloc(sizeof(WINDOWINFO));
		if (!pwi){
			CloseWindowMy(hwnd);
			break;
		}
		GetWindowInfo(hwnd, pwi);
		int w = pwi->rcClient.right - pwi->rcClient.left;
		int h = pwi->rcClient.bottom - pwi->rcClient.top;
		free(pwi);
		HWND hwndExit = CreateWindowA("button", "закрыть", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, 0, h - 30, w / 2, 30, hwnd, (HMENU)ID_BUTTON_EXIT, NULL, NULL);
		HWND hwndTurn = CreateWindowA("button", "свернуть", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, w / 2, h - 30, w / 2, 30, hwnd, (HMENU)ID_BUTTON_TURN, NULL, NULL);
		HWND hwndAutoRun = CreateWindowA("button", NULL, WS_CHILD | BS_AUTOCHECKBOX | WS_VISIBLE, 300, 131, 15, 15, hwnd, (HMENU)ID_BUTTON_AUTORUN, NULL, NULL);
		HWND hwndHotKey = CreateWindowA("Edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_READONLY, 230, 10, 50, 20, hwnd, (HMENU)ID_EDIT_HOTKEY, NULL, NULL);
		glbOldEditProc = SetWindowLongW(hwndHotKey, GWL_WNDPROC, (LONG)newEditProc); //замена процесса обработки сообщений едита 
		ShowWindow(hwndHotKey, SW_NORMAL);
		ShowWindow(hwndExit, SW_NORMAL);
		ShowWindow(hwndAutoRun, SW_NORMAL);
		ShowWindow(hwndTurn, SW_NORMAL);
		UINT ChekAutoRunResult = ChekAutoRun(); //проверяем, есть ли автозагрузка 
		if (ChekAutoRunResult == MYERROR){

			CloseWindowMy(hwnd);
			break;

		}
		else if (ChekAutoRunResult == SUCCESS)
			SendMessageA(hwndAutoRun, BM_SETCHECK, 1, 0); //устанавливаем галочку автозагрузки, если она есть
		CreatIcon(hwnd);
		INT hotKeyCode = SetHotKeyToEdit(hwndHotKey);
		if (hotKeyCode == MYERROR){//установка горячей клавиши
			CloseWindowMy(hwnd);
			break;
		}
		pInitHotKeyDll(hotKeyCode,hwndHotKey); //в длл ее
		break;
	}

	case WM_ICON:{
		switch (lParam)  {
		case WM_LBUTTONDBLCLK:{
			ShowWindow(hwnd, SW_NORMAL); // работа с иконкой

			break;
		}
		default:
			break;
		}
		break;
	}
	case WM_COMMAND:{
		if (idChild == ID_BUTTON_EXIT){
			CloseWindowMy(hwnd);  
		}
		if (idChild == ID_BUTTON_TURN){

			ShowWindow(hwnd, SW_HIDE);

		}


		if (idChild == ID_BUTTON_AUTORUN){ // если захотели автозагрузку
			LRESULT result = SendMessageA(hwndChild, BM_GETCHECK, 0, 0);
			if (result == BST_CHECKED){ //если галочка ставится
				char *szFileName = malloc(MAX_LENGTH);
				if (!szFileName){
					CloseWindowMy(hwnd);







					break;
				}
				memset(szFileName, 0, MAX_LENGTH);


				GetModuleFileNameA(NULL, szFileName, MAX_PATH);

				if (SetAutoRunToReg((LPBYTE)szFileName, strlen(szFileName)) == MYERROR){//добавляем наше приложение в автозагрузку
					glbPaintError = MYERROR;
					SendMessageA(hwndChild, BM_SETCHECK, 0, 0); // если вдруг что-то пошло не так, выводим ошибку
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0,0);



				}
				else{
					glbPaintError = SUCCESS;
					InvalidateRect(hwnd, 0,0);
					SendMessageA(hwnd, WM_PAINT, 0, 0);
				}
			}
			else {
				if (SetAutoRunToReg(NULL, 0) == MYERROR){//удаляем наше приложение из автозагрузки dsfdsSDFDSFsdfdasdsadASDSADfdfdsfSDFDSS
					glbPaintError = MYERROR;
					SendMessageA(hwndChild, BM_SETCHECK, 1, 0);
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0,0);

				}
				else{
					glbPaintError = SUCCESS;
					InvalidateRect(hwnd, 0, 0);
					SendMessageA(hwnd, WM_PAINT, 0, 0);


				}

			}
		}
		break;
	}




	case WM_PAINT:{


		HDC hdc = BeginPaint(hwnd, &ps);
		HBRUSH hBrush = CreateSolidBrush(RGB(0xff, 0xff, 0xff));
		HPEN hPen = CreatePen(PS_SOLID, 2, RGB(0xff, 0xff, 0xff));
		SelectObject(hdc, hPen);
		SelectObject(hdc, hBrush);        


		 
		WINDOWINFO wi;
		GetWindowInfo(hwnd, &wi);
		int w = wi.rcClient.right - wi.rcClient.left;
		int h = wi.rcClient.bottom - wi.rcClient.top;

		Rectangle(hdc, 0, 0, w, h);
		TextOutA(hdc, 10, 10, "Клавиша для переключения:", 25);
		TextOutA(hdc, 10, 30, "Для смены клавиши, нажмите мышкой на рамку,", 42);
		TextOutA(hdc, 10, 50, "Затем нажмите нужную клавишу из списка:", 39);
		TextOutA(hdc, 10, 70, "1. Shift", 8);
		TextOutA(hdc, 10, 85, "2. Pause", 8);
		TextOutA(hdc, 10, 100, "3. ctrl", 7);
		TextOutA(hdc, 10, 130, "Запуск Свичера при загрузке Windows:", 36);


		if (glbPaintError == MYERROR){

			TextOutA(hdc, 10, 115, "Не удается изменить состояние автозагрузки.", 43);

		}
		EndPaint(hwnd, &ps);
	}

	default:
		return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}
Exemple #25
0
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);
}
Exemple #26
0
LRESULT WINAPI
RealDefWindowProcA(HWND hWnd,
                   UINT Msg,
                   WPARAM wParam,
                   LPARAM lParam)
{
    LRESULT Result = 0;
    PWND Wnd;

    Wnd = ValidateHwnd(hWnd);

    if ( !Wnd &&
         Msg != WM_CTLCOLORMSGBOX &&
         Msg != WM_CTLCOLORBTN    &&
         Msg != WM_CTLCOLORDLG    &&
         Msg != WM_CTLCOLORSTATIC )
       return 0;

    SPY_EnterMessage(SPY_DEFWNDPROC, hWnd, Msg, wParam, lParam);
    switch (Msg)
    {
        case WM_NCCREATE:
        {
            if ( Wnd &&
                 Wnd->style & (WS_HSCROLL | WS_VSCROLL) )
            {
               if (!Wnd->pSBInfo)
               {
                  SCROLLINFO si = {sizeof si, SIF_ALL, 0, 100, 0, 0, 0};
                  SetScrollInfo( hWnd, SB_HORZ, &si, FALSE );
                  SetScrollInfo( hWnd, SB_VERT, &si, FALSE );
               }
            }

            if (lParam)
            {
                LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
                /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
                 * may have child window IDs instead of window name */
                if (HIWORD(cs->lpszName))
                {
                    DefSetText(hWnd, (PCWSTR)cs->lpszName, TRUE);
                }
                Result = 1;
            }
            break;
        }

        case WM_GETTEXTLENGTH:
        {
            PWSTR buf;
            ULONG len;

            if (Wnd != NULL && Wnd->strName.Length != 0)
            {
                buf = DesktopPtrToUser(Wnd->strName.Buffer);
                if (buf != NULL &&
                    NT_SUCCESS(RtlUnicodeToMultiByteSize(&len,
                                                         buf,
                                                         Wnd->strName.Length)))
                {
                    Result = (LRESULT) len;
                }
            }
            else Result = 0L;

            break;
        }

        case WM_GETTEXT:
        {
            PWSTR buf = NULL;
            PSTR outbuf = (PSTR)lParam;
            UINT copy;

            if (Wnd != NULL && wParam != 0)
            {
                if (Wnd->strName.Buffer != NULL)
                    buf = DesktopPtrToUser(Wnd->strName.Buffer);
                else
                    outbuf[0] = L'\0';

                if (buf != NULL)
                {
                    if (Wnd->strName.Length != 0)
                    {
                        copy = min(Wnd->strName.Length / sizeof(WCHAR), wParam - 1);
                        Result = WideCharToMultiByte(CP_ACP,
                                                     0,
                                                     buf,
                                                     copy,
                                                     outbuf,
                                                     wParam,
                                                     NULL,
                                                     NULL);
                        outbuf[Result] = '\0';
                    }
                    else
                        outbuf[0] = '\0';
                }
            }
            break;
        }

        case WM_SETTEXT:
        {
            DefSetText(hWnd, (PCWSTR)lParam, TRUE);

            if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
                UserPaintCaption(hWnd);
            Result = 1;
            break;
        }

        case WM_IME_KEYDOWN:
        {
            Result = PostMessageA(hWnd, WM_KEYDOWN, wParam, lParam);
            break;
        }

        case WM_IME_KEYUP:
        {
            Result = PostMessageA(hWnd, WM_KEYUP, wParam, lParam);
            break;
        }

        case WM_IME_CHAR:
        {
            if (HIBYTE(wParam))
                PostMessageA(hWnd, WM_CHAR, HIBYTE(wParam), lParam);
            PostMessageA(hWnd, WM_CHAR, LOBYTE(wParam), lParam);
            break;
        }

        case WM_IME_STARTCOMPOSITION:
        case WM_IME_COMPOSITION:
        case WM_IME_ENDCOMPOSITION:
        case WM_IME_SELECT:
        case WM_IME_NOTIFY:
        {
            HWND hwndIME;

            hwndIME = DefWndImmGetDefaultIMEWnd(hWnd);
            if (hwndIME)
                Result = SendMessageA(hwndIME, Msg, wParam, lParam);
            break;
        }

        case WM_IME_SETCONTEXT:
        {
            HWND hwndIME;

            hwndIME = DefWndImmGetDefaultIMEWnd(hWnd);
            if (hwndIME)
                Result = DefWndImmIsUIMessageA(hwndIME, Msg, wParam, lParam);
            break;
        }

        /* fall through */
        default:
            Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, FALSE);
    }

    SPY_ExitMessage(SPY_RESULT_DEFWND, hWnd, Msg, Result, wParam, lParam);
    return Result;
}
Exemple #27
0
/*
 * Tests if a progress bar repaints itself immediately when it receives
 * some specific messages.
 */
static void test_redraw(void)
{
    RECT client_rect, rect;
    HWND hProgressWnd;
    LRESULT ret;

    GetClientRect(hProgressParentWnd, &rect);
    hProgressWnd = CreateWindowExA(0, PROGRESS_CLASSA, "", WS_CHILD | WS_VISIBLE,
      0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
    ok(hProgressWnd != NULL, "Failed to create progress bar.\n");
    progress_wndproc = (WNDPROC)SetWindowLongPtrA(hProgressWnd, GWLP_WNDPROC, (LPARAM)progress_subclass_proc);

    ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
    ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
    flush_events();
    update_window(hProgressParentWnd);

    SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
    SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
    SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
    update_window(hProgressWnd);

    /* PBM_SETPOS */
    ok(SendMessageA(hProgressWnd, PBM_SETPOS, 50, 0) == 10, "PBM_SETPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");

    /* PBM_DELTAPOS */
    ok(SendMessageA(hProgressWnd, PBM_DELTAPOS, 15, 0) == 50, "PBM_DELTAPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_DELTAPOS: The progress bar should be redrawn immediately\n");

    /* PBM_SETPOS */
    ok(SendMessageA(hProgressWnd, PBM_SETPOS, 80, 0) == 65, "PBM_SETPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");

    /* PBM_STEPIT */
    ok(SendMessageA(hProgressWnd, PBM_STEPIT, 0, 0) == 80, "PBM_STEPIT must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_STEPIT: The progress bar should be redrawn immediately\n");
    ret = SendMessageA(hProgressWnd, PBM_GETPOS, 0, 0);
    if (ret == 0)
        win_skip("PBM_GETPOS needs comctl32 > 4.70\n");
    else
        ok(ret == 100, "PBM_GETPOS returned a wrong position : %d\n", (UINT)ret);

    /* PBM_SETRANGE and PBM_SETRANGE32:
    Usually the progress bar doesn't repaint itself immediately. If the
    position is not in the new range, it does.
    Don't test this, it may change in future Windows versions. */

    SendMessageA(hProgressWnd, PBM_SETPOS, 0, 0);
    update_window(hProgressWnd);

    /* increase to 10 - no background erase required */
    erased = FALSE;
    SetRectEmpty(&last_paint_rect);
    SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
    GetClientRect(hProgressWnd, &client_rect);
    ok(EqualRect(&last_paint_rect, &client_rect), "last_paint_rect was %s instead of %s\n",
       wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
    update_window(hProgressWnd);
    ok(!erased, "Progress bar shouldn't have erased the background\n");

    /* decrease to 0 - background erase will be required */
    erased = FALSE;
    SetRectEmpty(&last_paint_rect);
    SendMessageA(hProgressWnd, PBM_SETPOS, 0, 0);
    GetClientRect(hProgressWnd, &client_rect);
    ok(EqualRect(&last_paint_rect, &client_rect), "last_paint_rect was %s instead of %s\n",
       wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
    update_window(hProgressWnd);
    ok(erased, "Progress bar should have erased the background\n");

    DestroyWindow(hProgressWnd);
}
Exemple #28
0
LRESULT WINAPI
User32DefWindowProc(HWND hWnd,
		    UINT Msg,
		    WPARAM wParam,
		    LPARAM lParam,
		    BOOL bUnicode)
{
    PWND pWnd = NULL;
    if (hWnd)
    {
       pWnd = ValidateHwnd(hWnd);
       if (!pWnd) return 0;
    }

    switch (Msg)
    {
	case WM_NCPAINT:
	{
            return DefWndNCPaint(hWnd, (HRGN)wParam, -1);
        }

        case WM_NCCALCSIZE:
        {
            return DefWndNCCalcSize(hWnd, (BOOL)wParam, (RECT*)lParam);
        }

        case WM_POPUPSYSTEMMENU:
        {
            /* This is an undocumented message used by the windows taskbar to
               display the system menu of windows that belong to other processes. */
            HMENU menu = GetSystemMenu(hWnd, FALSE);

            if (menu)
                TrackPopupMenu(menu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON,
                               LOWORD(lParam), HIWORD(lParam), 0, hWnd, NULL);
            return 0;
        }

        case WM_NCACTIVATE:
        {
            return DefWndNCActivate(hWnd, wParam, lParam);
        }

        case WM_NCHITTEST:
        {
            POINT Point;
            Point.x = GET_X_LPARAM(lParam);
            Point.y = GET_Y_LPARAM(lParam);
            return (DefWndNCHitTest(hWnd, Point));
        }

        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
            iF10Key = iMenuSysKey = 0;
            break;

        case WM_NCLBUTTONDOWN:
        {
            return (DefWndNCLButtonDown(hWnd, wParam, lParam));
        }

        case WM_LBUTTONDBLCLK:
            return (DefWndNCLButtonDblClk(hWnd, HTCLIENT, lParam));

        case WM_NCLBUTTONDBLCLK:
        {
            return (DefWndNCLButtonDblClk(hWnd, wParam, lParam));
        }

        case WM_NCRBUTTONDOWN:
            return NC_HandleNCRButtonDown( hWnd, wParam, lParam );

        case WM_RBUTTONUP:
        {
            POINT Pt;

            Pt.x = GET_X_LPARAM(lParam);
            Pt.y = GET_Y_LPARAM(lParam);
            ClientToScreen(hWnd, &Pt);
            lParam = MAKELPARAM(Pt.x, Pt.y);
            if (bUnicode)
            {
                SendMessageW(hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, lParam);
            }
            else
            {
                SendMessageA(hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, lParam);
            }
            break;
        }

        case WM_NCRBUTTONUP:
          /*
           * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
           * in Windows), but what _should_ we do? According to MSDN :
           * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
           * message to the window". When is it appropriate?
           */
            break;

        case WM_CONTEXTMENU:
        {
            if (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CHILD)
            {
                if (bUnicode)
                {
                    SendMessageW(GetParent(hWnd), Msg, wParam, lParam);
                }
                else
                {
                    SendMessageA(GetParent(hWnd), WM_CONTEXTMENU, wParam, lParam);
                }
            }
            else
            {
                POINT Pt;
                LONG_PTR Style;
                LONG HitCode;

                Style = GetWindowLongPtrW(hWnd, GWL_STYLE);

                Pt.x = GET_X_LPARAM(lParam);
                Pt.y = GET_Y_LPARAM(lParam);
                if (Style & WS_CHILD)
                {
                    ScreenToClient(GetParent(hWnd), &Pt);
                }

                HitCode = DefWndNCHitTest(hWnd, Pt);

                if (HitCode == HTCAPTION || HitCode == HTSYSMENU)
                {
                    HMENU SystemMenu;
                    UINT Flags;

                    if((SystemMenu = GetSystemMenu(hWnd, FALSE)))
                    {
                      MenuInitSysMenuPopup(SystemMenu, GetWindowLongPtrW(hWnd, GWL_STYLE),
                                           GetClassLongPtrW(hWnd, GCL_STYLE), HitCode);

                      if(HitCode == HTCAPTION)
                        Flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON;
                      else
                        Flags = TPM_LEFTBUTTON;

                      TrackPopupMenu(SystemMenu, Flags,
                                     Pt.x, Pt.y, 0, hWnd, NULL);
                    }
                }
	    }
            break;
        }

        case WM_PRINT:
        {
            DefWndPrint(hWnd, (HDC)wParam, lParam);
            return (0);
        }

        case WM_SYSCOLORCHANGE:
        {
            /* force to redraw non-client area */
            DefWndNCPaint(hWnd, HRGN_WINDOW, -1);
            /* Use InvalidateRect to redraw client area, enable
             * erase to redraw all subcontrols otherwise send the
             * WM_SYSCOLORCHANGE to child windows/controls is required
             */
            InvalidateRect(hWnd,NULL,TRUE);
            return (0);
        }

        case WM_PAINTICON:
        case WM_PAINT:
        {
            PAINTSTRUCT Ps;
            HDC hDC;

            /* If already in Paint and Client area is not empty just return. */
            if (pWnd->state2 & WNDS2_STARTPAINT && !IsRectEmpty(&pWnd->rcClient))
            {
               ERR("In Paint and Client area is not empty!\n");
               return 0;
            }

            hDC = BeginPaint(hWnd, &Ps);
            if (hDC)
            {
                HICON hIcon;

                if (IsIconic(hWnd) && ((hIcon = (HICON)GetClassLongPtrW( hWnd, GCLP_HICON))))
                {
                    RECT ClientRect;
                    INT x, y;
                    GetClientRect(hWnd, &ClientRect);
                    x = (ClientRect.right - ClientRect.left -
                         GetSystemMetrics(SM_CXICON)) / 2;
                    y = (ClientRect.bottom - ClientRect.top -
                         GetSystemMetrics(SM_CYICON)) / 2;
                    DrawIcon(hDC, x, y, hIcon);
                }
                EndPaint(hWnd, &Ps);
            }
            return (0);
        }

        case WM_CLOSE:
            DestroyWindow(hWnd);
            return (0);

        case WM_MOUSEACTIVATE:
            if (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CHILD)
            {
                LONG Ret = SendMessageW(GetParent(hWnd), WM_MOUSEACTIVATE, wParam, lParam);
                if (Ret) return (Ret);
            }
            return ( (HIWORD(lParam) == WM_LBUTTONDOWN && LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE );

        case WM_ACTIVATE:
            /* The default action in Windows is to set the keyboard focus to
             * the window, if it's being activated and not minimized */
            if (LOWORD(wParam) != WA_INACTIVE &&
                !(GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_MINIMIZE))
            {
                //ERR("WM_ACTIVATE %p\n",hWnd);
                SetFocus(hWnd);
            }
            break;

        case WM_MOUSEWHEEL:
            if (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CHILD)
                return SendMessageW( GetParent(hWnd), WM_MOUSEWHEEL, wParam, lParam);
            break;

        case WM_ERASEBKGND:
        case WM_ICONERASEBKGND:
        {
            RECT Rect;
            HBRUSH hBrush = (HBRUSH)GetClassLongPtrW(hWnd, GCL_HBRBACKGROUND);

            if (NULL == hBrush)
            {
                return 0;
            }
            if (GetClassLongPtrW(hWnd, GCL_STYLE) & CS_PARENTDC)
            {
                /* can't use GetClipBox with a parent DC or we fill the whole parent */
                GetClientRect(hWnd, &Rect);
                DPtoLP((HDC)wParam, (LPPOINT)&Rect, 2);
            }
            else
            {
                GetClipBox((HDC)wParam, &Rect);
            }
            FillRect((HDC)wParam, &Rect, hBrush);
            return (1);
        }

        case WM_CTLCOLORMSGBOX:
        case WM_CTLCOLOREDIT:
        case WM_CTLCOLORLISTBOX:
        case WM_CTLCOLORBTN:
        case WM_CTLCOLORDLG:
        case WM_CTLCOLORSTATIC:
        case WM_CTLCOLORSCROLLBAR:
	    return (LRESULT) DefWndControlColor((HDC)wParam, Msg - WM_CTLCOLORMSGBOX);

        case WM_CTLCOLOR:
            return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam));

        case WM_SETCURSOR:
        {
            LONG_PTR Style = GetWindowLongPtrW(hWnd, GWL_STYLE);

            if (Style & WS_CHILD)
            {
                /* with the exception of the border around a resizable wnd,
                 * give the parent first chance to set the cursor */
                if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT)
                {
                    HWND parent = GetParent( hWnd );
                    if (bUnicode)
                    {
                       if (parent != GetDesktopWindow() &&
                           SendMessageW( parent, WM_SETCURSOR, wParam, lParam))
                          return TRUE;
                    }
                    else
                    {
                       if (parent != GetDesktopWindow() &&                    
                           SendMessageA( parent, WM_SETCURSOR, wParam, lParam))
                          return TRUE;
                    }
                }
            }
            return (DefWndHandleSetCursor(hWnd, wParam, lParam, Style));
        }

        case WM_SYSCOMMAND:
            return (DefWndHandleSysCommand(hWnd, wParam, lParam));

        case WM_KEYDOWN:
            if(wParam == VK_F10) iF10Key = VK_F10;
            break;

        case WM_SYSKEYDOWN:
        {
            if (HIWORD(lParam) & KF_ALTDOWN)
            {   /* Previous state, if the key was down before this message,
                   this is a cheap way to ignore autorepeat keys. */
                if ( !(HIWORD(lParam) & KF_REPEAT) )
                {
                   if ( ( wParam == VK_MENU  ||
                          wParam == VK_LMENU ||
                          wParam == VK_RMENU ) && !iMenuSysKey )
                       iMenuSysKey = 1;
                   else
                       iMenuSysKey = 0;
                }

                iF10Key = 0;

                if (wParam == VK_F4) /* Try to close the window */
                {
                   HWND top = GetAncestor(hWnd, GA_ROOT);
                   if (!(GetClassLongPtrW(top, GCL_STYLE) & CS_NOCLOSE))
                      PostMessageW(top, WM_SYSCOMMAND, SC_CLOSE, 0);
                }
                else if (wParam == VK_SNAPSHOT) // Alt-VK_SNAPSHOT?
                {
                   HWND hwnd = hWnd;
                   while (GetParent(hwnd) != NULL)
                   {
                       hwnd = GetParent(hwnd);
                   }
                   DefWndScreenshot(hwnd);
                }
                else if ( wParam == VK_ESCAPE || wParam == VK_TAB ) // Alt-Tab/ESC Alt-Shift-Tab/ESC
                {
                   WPARAM wParamTmp;
                   HWND Active = GetActiveWindow(); // Noticed MDI problem.
                   if (!Active)
                   {
                      FIXME("WM_SYSKEYDOWN VK_ESCAPE no active\n");
                      break;
                   }
                   wParamTmp = GetKeyState(VK_SHIFT) & 0x8000 ? SC_PREVWINDOW : SC_NEXTWINDOW;
                   SendMessageW( Active, WM_SYSCOMMAND, wParamTmp, wParam );
                }
            }
            else if( wParam == VK_F10 )
            {
                if (GetKeyState(VK_SHIFT) & 0x8000)
                    SendMessageW( hWnd, WM_CONTEXTMENU, (WPARAM)hWnd, MAKELPARAM(-1, -1) );
                iF10Key = 1;
            }
            break;
        }

        case WM_KEYUP:
        case WM_SYSKEYUP:
        {
           /* Press and release F10 or ALT */
            if (((wParam == VK_MENU || wParam == VK_LMENU || wParam == VK_RMENU)
                 && iMenuSysKey) || ((wParam == VK_F10) && iF10Key))
                SendMessageW( GetAncestor( hWnd, GA_ROOT ), WM_SYSCOMMAND, SC_KEYMENU, 0L );
            iMenuSysKey = iF10Key = 0;
            break;
        }

        case WM_SYSCHAR:
        {
            iMenuSysKey = 0;
            if (wParam == VK_RETURN && IsIconic(hWnd))
            {
                PostMessageW( hWnd, WM_SYSCOMMAND, SC_RESTORE, 0L );
                break;
            }
            if ((HIWORD(lParam) & KF_ALTDOWN) && wParam)
            {
                if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
                if (wParam == VK_SPACE && (GetWindowLongPtrW( hWnd, GWL_STYLE ) & WS_CHILD))
                    SendMessageW( GetParent(hWnd), Msg, wParam, lParam );
                else
                    SendMessageW( hWnd, WM_SYSCOMMAND, SC_KEYMENU, wParam );
            }
            else /* check for Ctrl-Esc */
                if (wParam != VK_ESCAPE) MessageBeep(0);
            break;
        }

        case WM_CANCELMODE:
        {
            iMenuSysKey = 0;
            /* FIXME: Check for a desktop. */
            //if (!(GetWindowLongPtrW( hWnd, GWL_STYLE ) & WS_CHILD)) EndMenu();
            MENU_EndMenu( hWnd );
            if (GetCapture() == hWnd)
            {
                ReleaseCapture();
            }
            break;
        }

        case WM_VKEYTOITEM:
        case WM_CHARTOITEM:
            return (-1);
/*
        case WM_DROPOBJECT:
            return DRAG_FILE;
*/
        case WM_QUERYDROPOBJECT:
        {
            if (GetWindowLongPtrW(hWnd, GWL_EXSTYLE) & WS_EX_ACCEPTFILES)
            {
                return(1);
            }
            break;
        }

        case WM_QUERYDRAGICON:
        {
            UINT Len;
            HICON hIcon;

            hIcon = (HICON)GetClassLongPtrW(hWnd, GCL_HICON);
            if (hIcon)
            {
                return ((LRESULT)hIcon);
            }
            for (Len = 1; Len < 64; Len++)
            {
                if ((hIcon = LoadIconW(NULL, MAKEINTRESOURCEW(Len))) != NULL)
                {
                    return((LRESULT)hIcon);
                }
            }
            return ((LRESULT)LoadIconW(0, IDI_APPLICATION));
        }

        case WM_ISACTIVEICON:
        {
           BOOL isai;
           isai = (pWnd->state & WNDS_ACTIVEFRAME) != 0;
           return isai;
        }

        case WM_NOTIFYFORMAT:
        {
            if (lParam == NF_QUERY)
                return IsWindowUnicode(hWnd) ? NFR_UNICODE : NFR_ANSI;
            break;
        }

        case WM_SETICON:
        {
           return DefWndSetIcon(pWnd, wParam, lParam);
        }

        case WM_GETICON:
        {
           return DefWndGetIcon(pWnd, wParam, lParam);
        }

        case WM_HELP:
        {
            if (bUnicode)
            {
                SendMessageW(GetParent(hWnd), Msg, wParam, lParam);
            }
            else
            {
                SendMessageA(GetParent(hWnd), Msg, wParam, lParam);
            }
            break;
        }

        case WM_SYSTIMER:
        {
          THRDCARETINFO CaretInfo;
          switch(wParam)
          {
            case 0xffff: /* Caret timer */
              /* switch showing byte in win32k and get information about the caret */
              if(NtUserxSwitchCaretShowing(&CaretInfo) && (CaretInfo.hWnd == hWnd))
              {
                DrawCaret(hWnd, &CaretInfo);
              }
              break;
          }
          break;
        }

        case WM_QUERYOPEN:
        case WM_QUERYENDSESSION:
        {
            return (1);
        }

        case WM_INPUTLANGCHANGEREQUEST:
        {
            HKL NewHkl;

            if(wParam & INPUTLANGCHANGE_BACKWARD
               && wParam & INPUTLANGCHANGE_FORWARD)
            {
                return FALSE;
            }

            //FIXME: What to do with INPUTLANGCHANGE_SYSCHARSET ?

            if(wParam & INPUTLANGCHANGE_BACKWARD) NewHkl = (HKL) HKL_PREV;
            else if(wParam & INPUTLANGCHANGE_FORWARD) NewHkl = (HKL) HKL_NEXT;
            else NewHkl = (HKL) lParam;

            NtUserActivateKeyboardLayout(NewHkl, 0);

            return TRUE;
        }

        case WM_INPUTLANGCHANGE:
        {
            int count = 0;
            HWND *win_array = WIN_ListChildren( hWnd );

            if (!win_array)
                break;
            while (win_array[count])
                SendMessageW( win_array[count++], WM_INPUTLANGCHANGE, wParam, lParam);
            HeapFree(GetProcessHeap(),0,win_array);
            break;
        }

        case WM_QUERYUISTATE:
        {
            LRESULT Ret = 0;
            PWND Wnd = ValidateHwnd(hWnd);
            if (Wnd != NULL)
            {
                if (Wnd->HideFocus)
                    Ret |= UISF_HIDEFOCUS;
                if (Wnd->HideAccel)
                    Ret |= UISF_HIDEACCEL;
            }
            return Ret;
        }

        case WM_CHANGEUISTATE:
        {
            BOOL AlwaysShowCues = FALSE;
            WORD Action = LOWORD(wParam);
            WORD Flags = HIWORD(wParam);
            PWND Wnd;

            SystemParametersInfoW(SPI_GETKEYBOARDCUES, 0, &AlwaysShowCues, 0);
            if (AlwaysShowCues)
                break;

            Wnd= ValidateHwnd(hWnd);
            if (!Wnd || lParam != 0)
                break;

            if (Flags & ~(UISF_HIDEFOCUS | UISF_HIDEACCEL | UISF_ACTIVE))
                break;

            if (Flags & UISF_ACTIVE)
            {
                WARN("WM_CHANGEUISTATE does not yet support UISF_ACTIVE!\n");
            }

            if (Action == UIS_INITIALIZE)
            {
                PDESKTOPINFO Desk = GetThreadDesktopInfo();
                if (Desk == NULL)
                    break;

                Action = Desk->LastInputWasKbd ? UIS_CLEAR : UIS_SET;
                Flags = UISF_HIDEFOCUS | UISF_HIDEACCEL;

                /* We need to update wParam in case we need to send out messages */
                wParam = MAKEWPARAM(Action, Flags);
            }

            switch (Action)
            {
                case UIS_SET:
                    /* See if we actually need to change something */
                    if ((Flags & UISF_HIDEFOCUS) && !Wnd->HideFocus)
                        break;
                    if ((Flags & UISF_HIDEACCEL) && !Wnd->HideAccel)
                        break;

                    /* Don't need to do anything... */
                    return 0;

                case UIS_CLEAR:
                    /* See if we actually need to change something */
                    if ((Flags & UISF_HIDEFOCUS) && Wnd->HideFocus)
                        break;
                    if ((Flags & UISF_HIDEACCEL) && Wnd->HideAccel)
                        break;

                    /* Don't need to do anything... */
                    return 0;

                default:
                    WARN("WM_CHANGEUISTATE: Unsupported Action 0x%x\n", Action);
                    break;
            }

            if ((Wnd->style & WS_CHILD) && Wnd->spwndParent != NULL)
            {
                /* We're a child window and we need to pass this message down until
                   we reach the root */
                hWnd = UserHMGetHandle((PWND)DesktopPtrToUser(Wnd->spwndParent));
            }
            else
            {
                /* We're a top level window, we need to change the UI state */
                Msg = WM_UPDATEUISTATE;
            }

            if (bUnicode)
                return SendMessageW(hWnd, Msg, wParam, lParam);
            else
                return SendMessageA(hWnd, Msg, wParam, lParam);
        }

        case WM_UPDATEUISTATE:
        {
            BOOL Change = TRUE;
            BOOL AlwaysShowCues = FALSE;
            WORD Action = LOWORD(wParam);
            WORD Flags = HIWORD(wParam);
            PWND Wnd;

            SystemParametersInfoW(SPI_GETKEYBOARDCUES, 0, &AlwaysShowCues, 0);
            if (AlwaysShowCues)
                break;

            Wnd = ValidateHwnd(hWnd);
            if (!Wnd || lParam != 0)
                break;

            if (Flags & ~(UISF_HIDEFOCUS | UISF_HIDEACCEL | UISF_ACTIVE))
                break;

            if (Flags & UISF_ACTIVE)
            {
                WARN("WM_UPDATEUISTATE does not yet support UISF_ACTIVE!\n");
            }

            if (Action == UIS_INITIALIZE)
            {
                PDESKTOPINFO Desk = GetThreadDesktopInfo();
                if (Desk == NULL)
                    break;

                Action = Desk->LastInputWasKbd ? UIS_CLEAR : UIS_SET;
                Flags = UISF_HIDEFOCUS | UISF_HIDEACCEL;

                /* We need to update wParam for broadcasting the update */
                wParam = MAKEWPARAM(Action, Flags);
            }

            switch (Action)
            {
                case UIS_SET:
                    /* See if we actually need to change something */
                    if ((Flags & UISF_HIDEFOCUS) && !Wnd->HideFocus)
                        break;
                    if ((Flags & UISF_HIDEACCEL) && !Wnd->HideAccel)
                        break;

                    /* Don't need to do anything... */
                    Change = FALSE;
                    break;

                case UIS_CLEAR:
                    /* See if we actually need to change something */
                    if ((Flags & UISF_HIDEFOCUS) && Wnd->HideFocus)
                        break;
                    if ((Flags & UISF_HIDEACCEL) && Wnd->HideAccel)
                        break;

                    /* Don't need to do anything... */
                    Change = FALSE;
                    break;

                default:
                    WARN("WM_UPDATEUISTATE: Unsupported Action 0x%x\n", Action);
                    return 0;
            }

            /* Pack the information and call win32k */
            if (Change)
            {
                if (!NtUserxUpdateUiState(hWnd, Flags | ((DWORD)Action << 3)))
                    break;
            }

            /* Always broadcast the update to all children */
            EnumChildWindows(hWnd,
                             UserSendUiUpdateMsg,
                             (LPARAM)wParam);

            break;
        }

/* Move to Win32k !*/
        case WM_SHOWWINDOW:
            if (!lParam) break; // Call when it is necessary.
        case WM_SYNCPAINT:
        case WM_SETREDRAW:
        case WM_CLIENTSHUTDOWN:
        case WM_GETHOTKEY:
        case WM_SETHOTKEY:
        case WM_WINDOWPOSCHANGING:
        case WM_WINDOWPOSCHANGED:
        case WM_APPCOMMAND:
        {
            LRESULT lResult;
            NtUserMessageCall( hWnd, Msg, wParam, lParam, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, !bUnicode);
            return lResult;
        }
    }
    return 0;
}
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	if( combo1 && (HWND)lParam == combo1->GetHandle() )
		combo1->ProcessCommands(wParam, lParam);
	else if( combo2 && (HWND)lParam == combo2->GetHandle() )
		combo2->ProcessCommands(wParam, lParam);

	switch( msg )
	{
	case WM_CLOSE:
		ShowWindow(hWnd, SW_HIDE);
		DestroyWindow(hWnd);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	case WM_VSCROLL:
	case WM_HSCROLL:
		if( (HWND)lParam == trackbar )
		{
			switch( LOWORD(wParam) )
			{
			case TB_LINEUP:
			case TB_LINEDOWN:
			case TB_PAGEUP:
			case TB_PAGEDOWN: {
				// page up/down or arrows were pressed
				unsigned short pos =
					(unsigned short)SendMessageA(trackbar, TBM_GETPOS, 0, 0);

				SetTimer(hWnd, IDC_TIMER, (6 - pos) * 20, 0);
				} break;

			case TB_THUMBTRACK: {
				// the thumb was dragged
				unsigned short pos = HIWORD(wParam);
				SetTimer(hWnd, IDC_TIMER, (6 - pos) * 20, 0);
				} break;
			}
		}

		break;

	case WM_COMMAND:
		// standard controls
		switch( LOWORD(wParam) )
		{
		case IDM_EXIT_ITEM:
			SendMessage(hWnd, WM_CLOSE, 0, 0);
			break;

		case IDM_ABOUT_ITEM:
			MessageBoxA(hwnd, "WinAPI tutorial 2", "About", MB_OK);
			break;

		case IDC_BUTTON1:
			DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), hWnd, &DialogProc);
			break;
		}

		break;

	case WM_TIMER:
		if( animgif )
			animgif->NextFrame();

		InvalidateRect(spinner, 0, TRUE);
		break;

	case WM_DRAWITEM: {
		LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;

		if( pDIS->hwndItem == spinner && animgif )
			animgif->Draw();
		else if( pDIS->hwndItem == combo1->GetHandle() )
			combo1->Render(pDIS);
		else if( pDIS->hwndItem == combo2->GetHandle() )
			combo2->Render(pDIS);

		} break;

	case WM_KEYUP:
		switch(wParam)
		{
		case VK_ESCAPE:
			SendMessage(hWnd, WM_CLOSE, 0, 0);
			break;
		}
		break;
	
	default:
		break;
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
Exemple #30
0
static void test_pager(void)
{
    HWND pager;
    RECT rect, rect2;

    pager = create_pager_control( PGS_HORZ );
    if (!pager)
    {
        win_skip( "Pager control not supported\n" );
        return;
    }

    register_child_wnd_class();

    child1_wnd = CreateWindowA( "Pager test child class", "button", WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 300, 300,
                           pager, 0, GetModuleHandleA(0), 0 );
    child2_wnd = CreateWindowA("Pager test child class", "button", WS_CHILD | WS_BORDER, 0, 0, 300, 300,
        pager, 0, GetModuleHandleA(0), 0);

    flush_sequences( sequences, NUM_MSG_SEQUENCES );
    SendMessageA( pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd );
    ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "set child", FALSE);
    GetWindowRect( pager, &rect );
    ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
        "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top );

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    SendMessageA(pager, PGM_SETCHILD, 0, (LPARAM)child2_wnd);
    ok_sequence(sequences, PAGER_SEQ_INDEX, switch_child_seq, "switch to invisible child", FALSE);
    GetWindowRect(pager, &rect);
    ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
        "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top);
    ok(!IsWindowVisible(child2_wnd), "Child window 2 is visible\n");

    flush_sequences(sequences, NUM_MSG_SEQUENCES);
    SendMessageA(pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd);
    ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "switch to visible child", FALSE);
    GetWindowRect(pager, &rect);
    ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
        "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top);

    flush_sequences( sequences, NUM_MSG_SEQUENCES );
    SendMessageA( pager, PGM_SETPOS, 0, 10 );
    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_seq, "set pos", TRUE);
    GetWindowRect( pager, &rect );
    ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
        "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top );

    flush_sequences( sequences, NUM_MSG_SEQUENCES );
    SendMessageA( pager, PGM_SETPOS, 0, 10 );
    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_empty_seq, "set pos empty", TRUE);

    flush_sequences( sequences, NUM_MSG_SEQUENCES );
    SendMessageA( pager, PGM_SETPOS, 0, 9 );
    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_seq, "set pos", TRUE);

    DestroyWindow( pager );

    /* Test if resizing works */
    pager = create_pager_control( CCS_NORESIZE );
    ok(pager != NULL, "failed to create pager control\n");

    GetWindowRect( pager, &rect );
    MoveWindow( pager, 0, 0, 200, 100, TRUE );
    GetWindowRect( pager, &rect2 );
    ok(rect2.right - rect2.left > rect.right - rect.left, "expected pager window to resize, %s\n",
        wine_dbgstr_rect( &rect2 ));

    DestroyWindow( pager );

    pager = create_pager_control( CCS_NORESIZE | PGS_HORZ );
    ok(pager != NULL, "failed to create pager control\n");

    GetWindowRect( pager, &rect );
    MoveWindow( pager, 0, 0, 100, 200, TRUE );
    GetWindowRect( pager, &rect2 );
    ok(rect2.bottom - rect2.top > rect.bottom - rect.top, "expected pager window to resize, %s\n",
        wine_dbgstr_rect( &rect2 ));

    DestroyWindow( pager );
}