Esempio n. 1
0
static VOID
DisplayOnInit(HWND hwnd,
              PINFO pInfo)
{
    DISPLAY_DEVICEW displayDevice;
    DWORD iDevNum = 0;
    BOOL GotDev = FALSE;

    SetWindowLongPtrW(hwnd,
                      GWLP_USERDATA,
                      (LONG_PTR)pInfo);

    pInfo->hDisplayPage = hwnd;

    SetWindowPos(pInfo->hDisplayPage,
                 NULL,
                 2,
                 22,
                 0,
                 0,
                 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);

        pInfo->hRemote = LoadImageW(hInst,
                                    MAKEINTRESOURCEW(IDI_REMOTE),
                                    IMAGE_ICON,
                                    32,
                                    32,
                                    LR_DEFAULTCOLOR);
        if (pInfo->hRemote)
        {
            SendDlgItemMessageW(pInfo->hDisplayPage,
                                IDC_REMICON,
                                STM_SETICON,
                                (WPARAM)pInfo->hRemote,
                                0);
        }

        pInfo->hColor = LoadImageW(hInst,
                                   MAKEINTRESOURCEW(IDI_COLORS),
                                   IMAGE_ICON,
                                   32,
                                   32,
                                  LR_DEFAULTCOLOR);
        if (pInfo->hColor)
        {
            SendDlgItemMessageW(pInfo->hDisplayPage,
                                IDC_COLORSICON,
                                STM_SETICON,
                                (WPARAM)pInfo->hColor,
                                0);
        }

        pInfo->hSpectrum = LoadImageW(hInst,
                                      MAKEINTRESOURCEW(IDB_SPECT),
                                      IMAGE_BITMAP,
                                      0,
                                      0,
                                      LR_DEFAULTCOLOR);
        if (pInfo->hSpectrum)
        {
            GetObjectW(pInfo->hSpectrum,
                       sizeof(BITMAP),
                       &pInfo->bitmap);
        }

        /* Get video cards list */
        displayDevice.cb = (DWORD)sizeof(DISPLAY_DEVICE);
        while (EnumDisplayDevicesW(NULL, iDevNum, &displayDevice, 0x1))
        {
            if ((displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) != 0)
            {
                if (AddDisplayDevice(pInfo, &displayDevice))
                    GotDev = TRUE;
            }
            iDevNum++;
        }

        if (GotDev)
        {
            FillResolutionsAndColors(pInfo);
            ReLoadDisplayPage(pInfo);
        }
}
Esempio n. 2
0
static VOID
OnInitDialog(IN HWND hwndDlg)
{
    BITMAP bitmap;
    DWORD Result = 0;
    DWORD iDevNum = 0;
    DWORD i;
    DISPLAY_DEVICE displayDevice;
    PDATA pData;

    pData = HeapAlloc(GetProcessHeap(), 0, sizeof(DATA));
    if (pData == NULL)
        return;

    SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pData);

    /* Get video cards list */
    pData->DisplayDeviceList = NULL;
    displayDevice.cb = (DWORD)sizeof(DISPLAY_DEVICE);
    while (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0x1))
    {
        if ((displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0)
        {
            if (AddDisplayDevice(pData, &displayDevice))
                Result++;
        }
        iDevNum++;
    }

    if (Result == 0)
    {
        /* No adapter found */
        EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_BPP), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_RESOLUTION), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_RESOLUTION_TEXT), FALSE);
        EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_ADVANCED), FALSE);
        ShowWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM), SW_HIDE);

        /* Do not initialize the color spectrum bitmaps */
        memset(pData->hSpectrumBitmaps, 0, sizeof(pData->hSpectrumBitmaps));
        return;
    }
    else if (Result == 1)
    {
        MONSL_MONINFO monitors;

        /* Single video adapter */
        SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pData->DisplayDeviceList->DeviceDescription);
        OnDisplayDeviceChanged(hwndDlg, pData, pData->DisplayDeviceList);

        monitors.Position.x = monitors.Position.y = 0;
        monitors.Size.cx = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
        monitors.Size.cy = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
        monitors.Flags = 0;
        SendDlgItemMessage(hwndDlg,
                   IDC_SETTINGS_MONSEL,
                   MSLM_SETMONITORSINFO,
                   1,
                   (LPARAM)&monitors);
    }
    else /* FIXME: Incomplete! */
    {
        PMONSL_MONINFO pMonitors;
        DWORD i;

        SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pData->DisplayDeviceList->DeviceDescription);
        OnDisplayDeviceChanged(hwndDlg, pData, pData->DisplayDeviceList);

        pMonitors = (PMONSL_MONINFO)HeapAlloc(GetProcessHeap(), 0, sizeof(MONSL_MONINFO) * Result);
        if (pMonitors)
        {
            DWORD hack = 1280;
            for (i = 0; i < Result; i++)
            {
                pMonitors[i].Position.x = hack * i;
                pMonitors[i].Position.y = 0;
                pMonitors[i].Size.cx = pData->DisplayDeviceList->CurrentSettings->dmPelsWidth;
                pMonitors[i].Size.cy = pData->DisplayDeviceList->CurrentSettings->dmPelsHeight;
                pMonitors[i].Flags = 0;
            }

            SendDlgItemMessage(hwndDlg,
                       IDC_SETTINGS_MONSEL,
                       MSLM_SETMONITORSINFO,
                       Result,
                       (LPARAM)pMonitors);

            HeapFree(GetProcessHeap(), 0, pMonitors);
        }
    }

    /* Initialize the color spectrum bitmaps */
    for(i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
    {
        pData->hSpectrumBitmaps[i] = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM_4 + i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);

        if (pData->hSpectrumBitmaps[i] != NULL)
        {
            if (GetObjectW(pData->hSpectrumBitmaps[i], sizeof(BITMAP), &bitmap) != 0)
            {
                pData->cxSource[i] = bitmap.bmWidth;
                pData->cySource[i] = bitmap.bmHeight;
            }
            else
            {
                pData->cxSource[i] = 0;
                pData->cySource[i] = 0;
            }
        }
    }
}