示例#1
0
INT_PTR CALLBACK BtrfsDeviceAdd::DeviceAddDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    try {
        switch (uMsg) {
            case WM_INITDIALOG:
            {
                EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
                populate_device_tree(GetDlgItem(hwndDlg, IDC_DEVICE_TREE));
                EnableWindow(GetDlgItem(hwndDlg, IDOK), false);
                break;
            }

            case WM_COMMAND:
                switch (HIWORD(wParam)) {
                    case BN_CLICKED:
                        switch (LOWORD(wParam)) {
                            case IDOK:
                                AddDevice(hwndDlg);
                            return true;

                            case IDCANCEL:
                                EndDialog(hwndDlg, 0);
                            return true;
                        }
                    break;
                }
            break;

            case WM_NOTIFY:
                switch (((LPNMHDR)lParam)->code) {
                    case TVN_SELCHANGEDW:
                    {
                        NMTREEVIEWW* nmtv = (NMTREEVIEWW*)lParam;
                        TVITEMW tvi;
                        bool enable = false;

                        RtlZeroMemory(&tvi, sizeof(TVITEMW));
                        tvi.hItem = nmtv->itemNew.hItem;
                        tvi.mask = TVIF_PARAM | TVIF_HANDLE;

                        if (SendMessageW(GetDlgItem(hwndDlg, IDC_DEVICE_TREE), TVM_GETITEMW, 0, (LPARAM)&tvi))
                            sel = tvi.lParam == 0 ? nullptr : (device*)tvi.lParam;
                        else
                            sel = nullptr;

                        if (sel)
                            enable = (!sel->is_disk || !sel->has_parts) && !sel->multi_device;

                        EnableWindow(GetDlgItem(hwndDlg, IDOK), enable);
                        break;
                    }
                }
            break;
        }
    } catch (const exception& e) {
        error_message(hwndDlg, e.what());
    }

    return false;
}
示例#2
0
void CDialog::CTab::CreateTabWindow(short x, short y, short w, short h, HWND owner)
{
    const DWORD style = DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
    const DWORD exStyle = WS_EX_CONTROLPARENT;
    Show(L"", x, y, w, h, style, exStyle, owner, true);

    EnableThemeDialogTexture(m_Window, ETDT_ENABLETAB);
}
示例#3
0
BOOL xpt_EnableThemeDialogTexture(HWND hwnd, DWORD flags)
{
    BOOL res = FALSE;
    xptlock();
    res = EnableThemeDialogTexture(hwnd, flags);
    xptunlock();
    return res;
}
示例#4
0
文件: tabs.cpp 项目: pezcode/FireFly
bool SetTabThemeTexture(HWND Window, bool Enable)
{
	assert(IsWindow(Window));

	if(VisualStylesEnabled())
	{
		return (S_OK == EnableThemeDialogTexture(Window, Enable ? ETDT_ENABLETAB : ETDT_DISABLE));
	}
	return false;
}
示例#5
0
static BOOL CALLBACK TabProcHook (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_INITDIALOG) {
		EnableThemeDialogTexture (hWnd, ETDT_ENABLETAB);
		SetWindowLong (hWnd, GWL_USERDATA, lParam);
		((TabPage*)lParam)->hTab = hWnd;
	}
	TabPage *pTab = (TabPage*)GetWindowLong (hWnd, GWL_USERDATA);
	if (pTab) return pTab->DlgProc (hWnd, uMsg, wParam, lParam);
	else      return FALSE;
}
示例#6
0
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_INITDIALOG: {
            EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
            SendDlgItemMessage(hwndDlg, IDC_NUMPLAYERSUD, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_NUMPLAYERS), 0);
            return TRUE;
        }

        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_FULLSCREEN:
                    populateVideoModes(FALSE);
                    return TRUE;
                case IDC_SINGLEPLAYER:
                case IDC_MULTIPLAYER:
                    multiplayerModeClicked(LOWORD(wParam));
                    return TRUE;
                case IDC_PEERTOPEER:
                    peerToPeerModeClicked();
                    return TRUE;
                case IDC_HOSTSLIST:
                    if (HIWORD(wParam) == EN_SETFOCUS) {
                        WCHAR text[100];
                        EDITBALLOONTIP tip = {
                            sizeof(EDITBALLOONTIP),
                            0,
                            text,
                            TTI_NONE
                        };
                        if (IsDlgButtonChecked(hwndDlg, IDC_PEERTOPEER) == BST_CHECKED) {
                            MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, "Leave empty to host the game.", -1, text, 100);
                        } else {
                            MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, "List each address in order. Use "
                                "* to indicate this machine's position.", -1, text, 100);
                        }
                        SendDlgItemMessage(hwndDlg, IDC_HOSTSLIST, EM_SHOWBALLOONTIP, 0, (LPARAM)&tip);
                        return TRUE;
                    } else if (HIWORD(wParam) == EN_SETFOCUS) {
                        SendDlgItemMessage(hwndDlg, IDC_HOSTSLIST, EM_HIDEBALLOONTIP, 0, 0);
                        return TRUE;
                    }
                    break;
                default: break;
            }
            break;
        default: break;
    }
    return FALSE;
}
示例#7
0
	void make_child(HWND wnd)
	{
		//HWND wnd_destroy = child;
		if (child)
		{
			ShowWindow(child, SW_HIDE);
			DestroyWindow(child);
			child=0;
		}

		HWND wnd_tab = GetDlgItem(wnd, IDC_TAB1);
		
		RECT tab;
		
		GetWindowRect(wnd_tab,&tab);
		MapWindowPoints(HWND_DESKTOP, wnd, (LPPOINT)&tab, 2);
		
		TabCtrl_AdjustRect(wnd_tab,FALSE,&tab);
		
		unsigned count = tabsize(g_tabs);
		if (cfg_child >= count) cfg_child = 0;

		if (cfg_child < count && cfg_child >= 0)
		{
			child = g_tabs[cfg_child]->create(wnd);
		}
	
		//SetWindowPos(wnd_tab,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		
		if (child) 
		{
			//uxtheme_ptr uxtheme_api;
			//if (uxtheme_handle::g_create(uxtheme_api))
			{
				EnableThemeDialogTexture(child, ETDT_ENABLETAB);
			}
		}

		SetWindowPos(child, 0, tab.left, tab.top, tab.right-tab.left, tab.bottom-tab.top, SWP_NOZORDER);
		SetWindowPos(wnd_tab,HWND_BOTTOM,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		
		ShowWindow(child, SW_SHOWNORMAL);
	}
示例#8
0
BOOL PropSheetPage2_OnInitDialog(
    _In_ HWND hwndDlg,
    _In_ HWND hwndFocus,
    _Inout_ LPARAM lParam
    )
{
    // Set the fonts.
    InitializeFont(GetDlgItem(hwndDlg, IDC_MAINHEADER), -17, FW_SEMIBOLD);
   
    // Set the default radio button state to 'do not accept'.
    Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO2), BST_CHECKED);
   
    LoadEulaText(hwndDlg);

    // Enable the themed dialog background texture.
    EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);

    return TRUE;
}
示例#9
0
BOOL PropSheetPage4_OnInitDialog(
    _In_ HWND hwndDlg,
    _In_ HWND hwndFocus,
    _Inout_ LPARAM lParam
    )
{
    EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);

    InitializeFont(GetDlgItem(hwndDlg, IDC_MAINHEADER), -17, FW_SEMIBOLD);
    InitializeFont(GetDlgItem(hwndDlg, IDC_MAINHEADER1), -12, FW_SEMIBOLD);

    SetWindowSubclass(
        GetDlgItem(hwndDlg, IDC_PROGRESS1),
        SubclassWindowProc,
        IDC_PROGRESS1,
        0
        );

    return TRUE;
}
示例#10
0
	void make_child()
	{
		//HWND wnd_destroy = child;
		if (m_wnd_child)
		{
			ShowWindow(m_wnd_child, SW_HIDE);
			DestroyWindow(m_wnd_child);
			m_wnd_child=NULL;
		}

		HWND wnd_tab = GetDlgItem(m_wnd, IDC_TAB1);
		
		RECT tab;
		
		GetWindowRect(wnd_tab,&tab);
		MapWindowPoints(HWND_DESKTOP, m_wnd, (LPPOINT)&tab, 2);
		
		TabCtrl_AdjustRect(wnd_tab,FALSE,&tab);
		
		unsigned count = tabsize(g_tabs_appearance);
		if (cfg_child_appearance >= count) cfg_child_appearance = 0;

		if (cfg_child_appearance < count && cfg_child_appearance >= 0)
		{
			m_wnd_child = g_tabs_appearance[cfg_child_appearance]->create(m_wnd);
		}

		//SetWindowPos(child,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		
		if (m_wnd_child) 
		{
			EnableThemeDialogTexture(m_wnd_child, ETDT_ENABLETAB);
		}

		SetWindowPos(m_wnd_child, 0, tab.left, tab.top, tab.right-tab.left, tab.bottom-tab.top, SWP_NOZORDER);
		SetWindowPos(wnd_tab,HWND_BOTTOM,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		
		ShowWindow(m_wnd_child, SW_SHOWNORMAL);
		//UpdateWindow(child);
	}
示例#11
0
BOOL PropSheetPage1_OnInitDialog(
    _In_ HWND hwndDlg,
    _In_ HWND hwndFocus,
    _Inout_ LPARAM lParam
    )
{
    LoadSetupIcons(hwndDlg);
    LoadSetupImage(hwndDlg);

    // Center the dialog window on the desktop
    PhCenterWindow(GetParent(hwndDlg), NULL);
    SetForegroundWindow(GetParent(hwndDlg));

    // Set the fonts
    InitializeFont(GetDlgItem(hwndDlg, IDC_MAINHEADER), 24, FW_SEMIBOLD);
    InitializeFont(GetDlgItem(hwndDlg, IDC_SUBHEADER), 0, FW_NORMAL);

    // Enable the themed dialog background texture.
    EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);

    return TRUE;
}
示例#12
0
static void ThemeDialogBackground(HWND hwnd, BOOL tabbed)
{
	EnableThemeDialogTexture(hwnd, (tabbed ? ETDT_ENABLE : ETDT_DISABLE) | ETDT_USETABTEXTURE);
}
示例#13
0
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_INITDIALOG:
		{
			HWND hTabControl = GetDlgItem(hwndDlg, IDC_TAB1);

			TCITEM tci;
			tci.mask = TCIF_TEXT | TCIF_IMAGE;
			tci.iImage = -1;

			tci.pszText = tab_label[0];
			TabCtrl_InsertItem(hTabControl, 0, &tci);

			tci.pszText = tab_label[1];
			TabCtrl_InsertItem(hTabControl, 1, &tci);

			//if(dcPlatform != 2 && (!isPSemulator || multitap > 0))
			if (!isPSemulator || multitap > 0)
			{
				tci.pszText = tab_label[2];
				TabCtrl_InsertItem(hTabControl, 2, &tci);

				tci.pszText = tab_label[3];
				TabCtrl_InsertItem(hTabControl, 3, &tci);
			}

			hChild = CreateDialog((HINSTANCE)lParam, MAKEINTRESOURCE(IDD_INTAB), hwndDlg, DialogProc2);
			EnableThemeDialogTexture(hChild, ETDT_ENABLETAB);

			EnableWindow(GetDlgItem(hwndDlg, IDC_MULTITAP), isPSemulator);
			EnableWindow(GetDlgItem(hwndDlg, IDC_SWAPPORTS), isPSemulator);
			
			CheckDlgButton(hwndDlg, IDC_SWAPPORTS, SwapPortsEnabled ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_PROCPRIORITY, bPriority ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_SCREENSAVER, bKeepAwake ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hwndDlg, IDC_MULTITAP, multitap % 4);

			ShowWindow(hwndDlg, SW_SHOW);
		} break;

	case WM_COMMAND:
		{
			s16 command = LOWORD(wParam);

			switch(command)
			{
			case IDC_PROCPRIORITY:
				bPriority = IsDlgButtonChecked(hwndDlg, IDC_PROCPRIORITY) == BST_CHECKED;
				break;

			case IDC_SWAPPORTS:
				SwapPortsEnabled = IsDlgButtonChecked(hwndDlg, IDC_SWAPPORTS) == BST_CHECKED;
				break;



			case IDC_SCREENSAVER:
				bKeepAwake = IsDlgButtonChecked(hwndDlg, IDC_SCREENSAVER) == BST_CHECKED;
				break;

			case IDC_MULTITAP:
				{
					multitap = IsDlgButtonChecked(hwndDlg, IDC_MULTITAP) & 0xFF;
					HWND hTabControl = GetDlgItem(hwndDlg, IDC_TAB1);
					u8 tabs = (u8)TabCtrl_GetItemCount(hTabControl);

					if(multitap > 0)
					{
						if(tabs < 3)
						{
							TCITEM tci;
							tci.mask = TCIF_TEXT | TCIF_IMAGE;
							tci.iImage = -1;

							tci.pszText = tab_label[2];
							TabCtrl_InsertItem(hTabControl, 2, &tci);

							tci.pszText = tab_label[3];
							TabCtrl_InsertItem(hTabControl, 3, &tci);
						}
					}
					else
					{
						TabCtrl_SetCurSel(hTabControl, 0);

						TabCtrl_DeleteItem(hTabControl, 3);
						TabCtrl_DeleteItem(hTabControl, 2);
					}

					RedrawWindow(hChild, NULL, NULL, RDW_ERASE | RDW_INVALIDATE);
				}
				break;

			case IDRESET:
				{
					s32 port =  TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB1));
					settings[port].SetDefaults();
					SendMessage(hChild, WM_USER, 0xDEADBEEF, port);
				}
				break;

			case ID_OK:
					FileIO::INI_SaveSettings(); // SAVE SETTINGS
			case ID_CANCEL:
					EndDialog(hwndDlg, command); // .. and QUIT
					PostQuitMessage(0);
					break;
			}

		} break;

	case WM_NOTIFY:
			if ( ((LPNMHDR)lParam)->idFrom==IDC_TAB1 && ((LPNMHDR)lParam)->code == TCN_SELCHANGE  )
			{
				s32 port =  TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB1));
				SendMessage(hChild, WM_USER, 0xDEADBEEF, port);
			}
			break;

	default: return FALSE;
	}

	return TRUE;
}
示例#14
0
INT_PTR CALLBACK BtrfsDeviceResize::DeviceResizeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    try {
        switch (uMsg) {
            case WM_INITDIALOG:
            {
                win_handle h;
                WCHAR s[255];
                wstring t, u;

                EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);

                GetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, s, sizeof(s) / sizeof(WCHAR));
                wstring_sprintf(t, s, dev_id);
                SetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, t.c_str());

                h = CreateFileW(fn.c_str(), FILE_TRAVERSE | FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr,
                                OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, nullptr);

                if (h != INVALID_HANDLE_VALUE) {
                    NTSTATUS Status;
                    IO_STATUS_BLOCK iosb;
                    btrfs_device *devices, *bd;
                    ULONG devsize;
                    bool found = false;
                    HWND slider;

                    devsize = 1024;
                    devices = (btrfs_device*)malloc(devsize);

                    while (true) {
                        Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_DEVICES, nullptr, 0, devices, devsize);
                        if (Status == STATUS_BUFFER_OVERFLOW) {
                            devsize += 1024;

                            free(devices);
                            devices = (btrfs_device*)malloc(devsize);
                        } else
                            break;
                    }

                    if (!NT_SUCCESS(Status)) {
                        free(devices);
                        return false;
                    }

                    bd = devices;

                    while (true) {
                        if (bd->dev_id == dev_id) {
                            memcpy(&dev_info, bd, sizeof(btrfs_device));
                            found = true;
                            break;
                        }

                        if (bd->next_entry > 0)
                            bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
                        else
                            break;
                    }

                    if (!found) {
                        free(devices);
                        return false;
                    }

                    free(devices);

                    GetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, s, sizeof(s) / sizeof(WCHAR));
                    format_size(dev_info.size, u, true);
                    wstring_sprintf(t, s, u.c_str());
                    SetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, t.c_str());

                    new_size = dev_info.size;

                    GetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, new_size_text, sizeof(new_size_text) / sizeof(WCHAR));
                    wstring_sprintf(t, new_size_text, u.c_str());
                    SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());

                    slider = GetDlgItem(hwndDlg, IDC_RESIZE_SLIDER);
                    SendMessageW(slider, TBM_SETRANGEMIN, false, 0);
                    SendMessageW(slider, TBM_SETRANGEMAX, false, (LPARAM)(dev_info.max_size / 1048576));
                    SendMessageW(slider, TBM_SETPOS, true, (LPARAM)(new_size / 1048576));
                } else
                    return false;

                break;
            }

            case WM_COMMAND:
                switch (HIWORD(wParam)) {
                    case BN_CLICKED:
                        switch (LOWORD(wParam)) {
                            case IDOK:
                                do_resize(hwndDlg);
                                return true;

                            case IDCANCEL:
                                EndDialog(hwndDlg, 0);
                                return true;
                        }
                    break;
                }
            break;

            case WM_HSCROLL:
            {
                wstring t, u;

                new_size = UInt32x32To64(SendMessageW(GetDlgItem(hwndDlg, IDC_RESIZE_SLIDER), TBM_GETPOS, 0, 0), 1048576);

                format_size(new_size, u, true);
                wstring_sprintf(t, new_size_text, u.c_str());
                SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());

                EnableWindow(GetDlgItem(hwndDlg, IDOK), new_size > 0 ? true : false);

                break;
            }
        }
    } catch (const exception& e) {
        error_message(hwndDlg, e.what());
    }

    return false;
}
示例#15
0
BOOL xpt_EnableThemeDialogTexture(HWND hwnd, DWORD flags)
{
	mir_cslock lck(xptCS);
	return SUCCEEDED(EnableThemeDialogTexture(hwnd, flags));
}
INT_PTR CALLBACK DiskDriveOptionsDlgProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    PDV_DISK_OPTIONS_CONTEXT context = NULL;

    if (uMsg == WM_INITDIALOG)
    {
        context = (PDV_DISK_OPTIONS_CONTEXT)PhAllocate(sizeof(DV_DISK_OPTIONS_CONTEXT));
        memset(context, 0, sizeof(DV_DISK_OPTIONS_CONTEXT));

        SetProp(hwndDlg, L"Context", (HANDLE)context);
    }
    else
    {
        context = (PDV_DISK_OPTIONS_CONTEXT)GetProp(hwndDlg, L"Context");

        if (uMsg == WM_DESTROY)
        {
            if (context->OptionsChanged)
                DiskDrivesSaveList();

            FreeListViewDiskDriveEntries(context);

            RemoveProp(hwndDlg, L"Context");
            PhFree(context);
        }
    }

    if (context == NULL)
        return FALSE;

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            // Center the property sheet.
            PhCenterWindow(GetParent(hwndDlg), GetParent(GetParent(hwndDlg)));
            // Hide the OK button.
            ShowWindow(GetDlgItem(GetParent(hwndDlg), IDOK), SW_HIDE);
            // Set the Cancel button text.
            Button_SetText(GetDlgItem(GetParent(hwndDlg), IDCANCEL), L"Close");

            context->ListViewHandle = GetDlgItem(hwndDlg, IDC_DISKDRIVE_LISTVIEW);
            PhSetListViewStyle(context->ListViewHandle, FALSE, TRUE);
            ListView_SetExtendedListViewStyleEx(context->ListViewHandle, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
            PhSetControlTheme(context->ListViewHandle, L"explorer");
            PhAddListViewColumn(context->ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 350, L"Disk Drives");
            PhSetExtendedListView(context->ListViewHandle);
           
            if (WindowsVersion >= WINDOWS_VISTA)
            {
                ListView_EnableGroupView(context->ListViewHandle, TRUE);
                AddListViewGroup(context->ListViewHandle, 0, L"Connected");
                AddListViewGroup(context->ListViewHandle, 1, L"Disconnected");
            }

            FindDiskDrives(context);

            context->OptionsChanged = FALSE;

            EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
        }
        break;
    case WM_NOTIFY:
        {
            LPNMHDR header = (LPNMHDR)lParam;

            if (header->code == LVN_ITEMCHANGED)
            {
                LPNM_LISTVIEW listView = (LPNM_LISTVIEW)lParam;

                if (context->EnumeratingDisks)
                    break;

                if (listView->uChanged & LVIF_STATE)
                {
                    switch (listView->uNewState & LVIS_STATEIMAGEMASK)
                    {
                    case 0x2000: // checked
                        {
                            PDV_DISK_ID param = (PDV_DISK_ID)listView->lParam;

                            if (!FindDiskEntry(param, FALSE))
                            {
                                PDV_DISK_ENTRY entry;

                                entry = CreateDiskEntry(param);
                                entry->UserReference = TRUE;
                            }

                            context->OptionsChanged = TRUE;
                        }
                        break;
                    case 0x1000: // unchecked
                        {
                            PDV_DISK_ID param = (PDV_DISK_ID)listView->lParam;

                            FindDiskEntry(param, TRUE);

                            context->OptionsChanged = TRUE;
                        }
                        break;
                    }
                }
            }
            else if (header->code == NM_RCLICK)
            {
                PDV_DISK_ID param;
                PPH_STRING deviceInstance;

                if (param = PhGetSelectedListViewItemParam(context->ListViewHandle))
                {
                    if (deviceInstance = FindDiskDeviceInstance(param->DevicePath))
                    {
                        ShowDeviceMenu(hwndDlg, deviceInstance);
                        PhDereferenceObject(deviceInstance);
                    }
                }
            }
        }
        break;
    }

    return FALSE;
}
示例#17
0
static void ThemeDialogBackground(HWND hwnd)
{
	EnableThemeDialogTexture(hwnd, ETDT_ENABLETAB);
}
示例#18
0
static INT_PTR CALLBACK helpDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
	HELPDLGDATA *dat = (HELPDLGDATA *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch(msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			hwndHelpDialog = hwndDlg;
			dat = (HELPDLGDATA*)mir_calloc(sizeof(HELPDLGDATA));
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
			dat->vhs = (VARHELPINFO *)lParam;

			// set tabs
			int tabCount = 0;
			RECT rcTabs, rcParent;
			HWND hTab = GetDlgItem(hwndDlg, IDC_TABS);
			GetWindowRect(hTab, &rcTabs);
			GetWindowRect(hwndDlg, &rcParent);

			TCITEM tci = { 0 };
			HWND hPage, hShow = 0;
			if (dat->vhs->flags&VHF_TOKENS) {
				// token tab
				tci.mask = TCIF_TEXT | TCIF_PARAM;
				tci.pszText = TranslateT("Tokens");
				hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_TOKENS_DIALOG), hwndDlg, tokenHelpDlgProc, (LPARAM)GetParent(hwndDlg));
				EnableThemeDialogTexture(hPage, ETDT_ENABLETAB);

				tci.lParam = (LPARAM)hPage;
				MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE);
				ShowWindow(hPage, SW_HIDE);
				TabCtrl_InsertItem(hTab, tabCount++, &tci);
				hShow = hShow == 0 ? hPage : hShow;
			}
			if (dat->vhs->flags&VHF_INPUT) {
				// input tab
				tci.mask = TCIF_TEXT | TCIF_PARAM;
				tci.pszText = TranslateT("Input");
				dat->hwndInputDlg = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_INPUT_DIALOG), hwndDlg, inputDlgProc, (LPARAM)GetParent(hwndDlg));
				EnableThemeDialogTexture(hPage, ETDT_ENABLETAB);

				tci.lParam = (LPARAM)hPage;
				MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE);
				ShowWindow(hPage, SW_HIDE);
				TabCtrl_InsertItem(hTab, tabCount++, &tci);
				hShow = hShow == 0 ? hPage : hShow;
				if ((dat->vhs->fi != NULL) && (dat->vhs->fi->szFormat != NULL)) {
					if (dat->vhs->fi->flags & FIF_UNICODE)
						SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)dat->vhs->fi->tszFormat);
					else {

						WCHAR *wszFormatString = mir_a2t(dat->vhs->fi->szFormat);
						SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)wszFormatString);
						mir_free(wszFormatString);

					}
				}
				else if (dat->vhs->hwndCtrl != NULL) {
					TCHAR *tszText = Hlp_GetWindowText(dat->vhs->hwndCtrl);
					if (tszText != NULL) {
						SendMessage(hwndDlg, VARM_SETINPUTTEXT, 0, (LPARAM)tszText);
						mir_free(tszText);
					}
				}
				if (dat->vhs->fi != NULL || dat->vhs->hwndCtrl != NULL) {
					SetDlgItemText(hwndDlg, IDC_CANCEL, TranslateT("Cancel"));
					ShowWindow(GetDlgItem(hwndDlg, IDC_OK), SW_SHOW);
				}
			}
			if ((dat->vhs->flags&VHF_SUBJECT) ||
				((dat->vhs->flags&VHF_INPUT) && (((dat->vhs->fi != NULL) && (dat->vhs->fi->hContact != NULL)) || (dat->vhs->flags&VHF_SETLASTSUBJECT)))) {
				// subject window is created, but not necessarily shown
				dat->hwndSubjectDlg = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CLIST_DIALOG), hwndDlg, clistDlgProc, (LPARAM)GetParent(hwndDlg));
				EnableThemeDialogTexture(hPage, ETDT_ENABLETAB);

				MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE);
				ShowWindow(hPage, SW_HIDE);

				if ((dat->vhs->fi != NULL) && (dat->vhs->fi->hContact != NULL))
					SendMessage(hwndDlg, VARM_SETSUBJECT, (WPARAM)dat->vhs->fi->hContact, 0);
				else if (dat->vhs->flags&VHF_SETLASTSUBJECT)
					SendMessage(hwndDlg, VARM_SETSUBJECT, (WPARAM)INVALID_HANDLE_VALUE, 0);

				if (dat->vhs->flags&VHF_SUBJECT) {
					// create subject tab
					tci.lParam = (LPARAM)hPage;
					tci.mask = TCIF_TEXT | TCIF_PARAM;
					tci.pszText = TranslateT("%subject%");
					TabCtrl_InsertItem(hTab, tabCount++, &tci);
					hShow = hShow == 0 ? hPage : hShow;
				}
			}
			if ((dat->vhs->flags&VHF_EXTRATEXT) ||
				((dat->vhs->flags&VHF_INPUT) && (dat->vhs->fi != NULL) && (dat->vhs->fi->tszExtraText != NULL))) {
				// extratext window is created, but not necessarily shown
				dat->hwndExtraTextDlg = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EXTRATEXT_DIALOG), hwndDlg, extratextDlgProc, (LPARAM)GetParent(hwndDlg));
				EnableThemeDialogTexture(hPage, ETDT_ENABLETAB);

				MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE);
				ShowWindow(hPage, SW_HIDE);
				if ((dat->vhs->fi != NULL) && (dat->vhs->fi->tszExtraText != NULL)) {
					if (dat->vhs->fi->flags & FIF_UNICODE)
						SendMessage(hwndDlg, VARM_SETEXTRATEXT, 0, (LPARAM)dat->vhs->fi->tszExtraText);
					else {

						WCHAR *wszSource = mir_a2t(dat->vhs->fi->szExtraText);
						SendMessage(hwndDlg, VARM_SETEXTRATEXT, 0, (LPARAM)wszSource);
						mir_free(wszSource);

					}
				}
				if (dat->vhs->flags&VHF_EXTRATEXT) {
					// create extratext tab
					tci.mask = TCIF_TEXT | TCIF_PARAM;
					tci.pszText = TranslateT("%extratext%");
					tci.lParam = (LPARAM)hPage;
					TabCtrl_InsertItem(hTab, tabCount++, &tci);
					hShow = hShow == 0 ? hPage : hShow;
				}
			}
			if (dat->vhs->flags&VHF_HELP) {
				// helpinfo tab
				tci.mask = TCIF_TEXT | TCIF_PARAM;
				tci.pszText = TranslateT("Help");
				hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HELPINFO_DIALOG), hwndDlg, helpInfoDlgProc, (LPARAM)GetParent(hwndDlg));
				EnableThemeDialogTexture(hPage, ETDT_ENABLETAB);

				tci.lParam = (LPARAM)hPage;
				MoveWindow(hPage, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE);
				ShowWindow(hPage, SW_HIDE);
				TabCtrl_InsertItem(hTab, tabCount++, &tci);
				hShow = hShow == 0 ? hPage : hShow;
			}
			Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, MODULENAME, "help");
			SetWindowText(hwndDlg, TranslateT("Variables Help"));
			ShowWindow(hShow, SW_SHOW);
			break;
		}

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_OK:
			if ((dat->vhs->fi != NULL) && (!(dat->vhs->flags&VHF_DONTFILLSTRUCT))) {
				int len = SendMessage(hwndDlg, VARM_GETINPUTTEXTLENGTH, 0, 0);
				if (len > 0) {
					if ((dat->vhs->fi != NULL) && (!(dat->vhs->flags&VHF_DONTFILLSTRUCT))) {
						if (dat->vhs->fi->flags&FIF_UNICODE) {
							dat->vhs->fi->tszFormat = (TCHAR*)mir_calloc((len + 1)*sizeof(WCHAR));
							SendMessage(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->tszFormat);
						}
						else {
							dat->vhs->fi->szFormat = (char*)mir_calloc(len + 1);
							SendMessageA(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szFormat);
						}
					}
				}
			}

			if (dat->vhs->hwndCtrl != NULL) {
				int len = SendMessage(hwndDlg, VARM_GETINPUTTEXTLENGTH, 0, 0);
				if (len > 0) {
					TCHAR *tszText;

					tszText = (TCHAR*)mir_calloc((len + 1)*sizeof(TCHAR));
					if (tszText != NULL) {
						SendMessage(hwndDlg, VARM_GETINPUTTEXT, (WPARAM)len + 1, (LPARAM)tszText);
						SetWindowText(dat->vhs->hwndCtrl, tszText);
						mir_free(tszText);
					}
				}
				SendMessage(GetParent(dat->vhs->hwndCtrl),
					WM_COMMAND,
					MAKEWPARAM(GetDlgCtrlID(dat->vhs->hwndCtrl),
					EN_CHANGE),
					(LPARAM)dat->vhs->hwndCtrl);
			}

			if ((dat->vhs->flags&VHF_FULLFILLSTRUCT) && (dat->vhs->fi != NULL)) {
				int len = SendMessage(hwndDlg, VARM_GETEXTRATEXTLENGTH, 0, 0);
				if (len > 0) {
					if (dat->vhs->fi->flags&FIF_UNICODE) {
						dat->vhs->fi->tszExtraText = (TCHAR*)mir_calloc((len + 1)*sizeof(WCHAR));
						SendMessage(hwndDlg, VARM_GETEXTRATEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->tszExtraText);
					}
					else {
						dat->vhs->fi->szExtraText = (char*)mir_calloc(len + 1);
						SendMessageA(hwndDlg, VARM_GETEXTRATEXT, (WPARAM)len + 1, (LPARAM)dat->vhs->fi->szExtraText);
					}
				}
				dat->vhs->fi->hContact = (MCONTACT)SendMessage(hwndDlg, VARM_GETSUBJECT, 0, 0);
			}
			// fall through

		case IDC_CANCEL:
			if (GetParent(hwndDlg) == NULL)
				DestroyWindow(hwndDlg);
			else
				EndDialog(hwndDlg, 0);
			break;
		}
		break;

	case VARM_SETSUBJECT:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndSubjectDlg, VARM_SETSUBJECT, wParam, lParam));
		return TRUE;

	case VARM_GETSUBJECT:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndSubjectDlg, VARM_GETSUBJECT, wParam, lParam));
		return TRUE;

	case VARM_SETEXTRATEXT:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndExtraTextDlg, VARM_SETEXTRATEXT, wParam, lParam));
		return TRUE;

	case VARM_GETEXTRATEXTLENGTH:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndExtraTextDlg, VARM_GETEXTRATEXTLENGTH, wParam, lParam));
		return TRUE;

	case VARM_GETEXTRATEXT:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndExtraTextDlg, VARM_GETEXTRATEXT, wParam, lParam));
		return TRUE;

	case VARM_SETINPUTTEXT:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndInputDlg, VARM_SETINPUTTEXT, wParam, lParam));
		return TRUE;

	case VARM_GETINPUTTEXTLENGTH:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndInputDlg, VARM_GETINPUTTEXTLENGTH, wParam, lParam));
		return TRUE;

	case VARM_GETINPUTTEXT:
		SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT,
			SendMessage(dat->hwndInputDlg, VARM_GETINPUTTEXT, wParam, lParam));
		return TRUE;

	case VARM_GETDIALOG:
		switch (wParam) {
		case VHF_INPUT:
			SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)dat->hwndInputDlg);
			return TRUE;
		}
		break;

	case WM_GETMINMAXINFO:
		{
			int i, count;
			TCITEM tci;
			RECT rcParent;
			HWND hTab;
			MINMAXINFO pageMinMax;

			GetWindowRect(hwndDlg, &rcParent);
			// defaults
			((MINMAXINFO*)lParam)->ptMinTrackSize.x = 400;
			((MINMAXINFO*)lParam)->ptMinTrackSize.y = 400;
			hTab = GetDlgItem(hwndDlg, IDC_TABS);
			tci.mask = TCIF_PARAM;
			count = TabCtrl_GetItemCount(hTab);
			// return the largest of all pages
			for (i = 0; i < count; i++) {
				TabCtrl_GetItem(hTab, i, &tci);
				memset(&pageMinMax, 0, sizeof(pageMinMax));
				SendMessage((HWND)tci.lParam, WM_GETMINMAXINFO, wParam, (LPARAM)&pageMinMax);
				((MINMAXINFO*)lParam)->ptMinTrackSize.x = max(((MINMAXINFO*)lParam)->ptMinTrackSize.x, pageMinMax.ptMinTrackSize.x);
				((MINMAXINFO*)lParam)->ptMinTrackSize.y = max(((MINMAXINFO*)lParam)->ptMinTrackSize.y, pageMinMax.ptMinTrackSize.y);
			}
		}
		break;

	case WM_SIZE:
		if (!IsIconic(hwndDlg)) {
			UTILRESIZEDIALOG urd = { 0 };
			urd.cbSize = sizeof(urd);
			urd.hInstance = hInst;
			urd.hwndDlg = hwndDlg;
			urd.lParam = 0;
			// ! uses ANSI version !
			urd.lpTemplate = MAKEINTRESOURCEA(IDD_HELP_DIALOG);
			urd.pfnResizer = helpDialogResize;
			CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);

			SendMessage(hwndDlg, WM_MOVE, 0, 0);

			RECT rcTabs, rcParent;
			HWND hTab = GetDlgItem(hwndDlg, IDC_TABS);
			GetWindowRect(hTab, &rcTabs);
			GetWindowRect(hwndDlg, &rcParent);

			TCITEM tci;
			tci.mask = TCIF_PARAM;
			int count = TabCtrl_GetItemCount(hTab);
			for (int i = 0; i < count; i++) {
				TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TABS), i, &tci);
				MoveWindow((HWND)tci.lParam, (rcTabs.left - rcParent.left), (rcTabs.top - rcParent.top), (rcTabs.right - rcTabs.left) - 2 * iFrameX, (rcTabs.bottom - rcTabs.top) - 2 * iFrameY, TRUE);
			}
		}
		break;

	case WM_NOTIFY:
		if ((((NMHDR*)lParam)->idFrom == IDC_TABS)) {
			if (((NMHDR*)lParam)->code == TCN_SELCHANGING) {
				TCITEM tci;

				tci.mask = TCIF_PARAM;
				TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TABS), TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TABS)), &tci);
				ShowWindow((HWND)tci.lParam, SW_HIDE);
			}
			else if (((NMHDR*)lParam)->code == TCN_SELCHANGE) {
				TCITEM tci;

				tci.mask = TCIF_PARAM;
				TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TABS), TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TABS)), &tci);
				ShowWindow((HWND)tci.lParam, SW_SHOW);
			}
		}
		break;

	case WM_CLOSE:
		if (GetParent(hwndDlg) == NULL)
			DestroyWindow(hwndDlg);
		else
			EndDialog(hwndDlg, 0);
		break;

	case WM_DESTROY:
		Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "help");

		HWND hTab = GetDlgItem(hwndDlg, IDC_TABS);

		TCITEM tci;
		tci.mask = TCIF_PARAM;
		int count = TabCtrl_GetItemCount(hTab);
		for (int i = 0; i < count; i++) {
			TabCtrl_GetItem(hTab, i, &tci);
			if (((HWND)tci.lParam != dat->hwndSubjectDlg) && ((HWND)tci.lParam != dat->hwndExtraTextDlg))
				DestroyWindow((HWND)tci.lParam);
		}

		// these windows might have been created, but not inserted as tabs
		if (IsWindow(dat->hwndSubjectDlg))
			DestroyWindow(dat->hwndSubjectDlg);

		if (IsWindow(dat->hwndExtraTextDlg))
			DestroyWindow(dat->hwndExtraTextDlg);

		mir_free(dat);
		dat = NULL;
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
		break;
	}

	return FALSE;
}
示例#19
0
INT_PTR CALLBACK PvpPeResourcesDlgProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    LPPROPSHEETPAGE propSheetPage;
    PPV_PROPPAGECONTEXT propPageContext;

    if (!PvPropPageDlgProcHeader(hwndDlg, uMsg, lParam, &propSheetPage, &propPageContext))
        return FALSE;

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            HWND lvHandle;
            PH_MAPPED_IMAGE_RESOURCES resources;
            PH_IMAGE_RESOURCE_ENTRY entry;
            ULONG count = 0;
            ULONG i;
            INT lvItemIndex;

            lvHandle = GetDlgItem(hwndDlg, IDC_LIST);
            PhSetListViewStyle(lvHandle, TRUE, TRUE);
            PhSetControlTheme(lvHandle, L"explorer");
            PhAddListViewColumn(lvHandle, 0, 0, 0, LVCFMT_LEFT, 40, L"#");
            PhAddListViewColumn(lvHandle, 1, 1, 1, LVCFMT_LEFT, 150, L"Type");
            PhAddListViewColumn(lvHandle, 2, 2, 2, LVCFMT_LEFT, 80, L"Name");
            PhAddListViewColumn(lvHandle, 3, 3, 3, LVCFMT_LEFT, 100, L"Size");
            PhAddListViewColumn(lvHandle, 4, 4, 4, LVCFMT_LEFT, 100, L"Language");
            PhSetExtendedListView(lvHandle);
            PhLoadListViewColumnsFromSetting(L"ImageResourcesListViewColumns", lvHandle);

            if (NT_SUCCESS(PhGetMappedImageResources(&resources, &PvMappedImage)))
            {
                for (i = 0; i < resources.NumberOfEntries; i++)
                {
                    PVOID string;
                    WCHAR number[PH_INT32_STR_LEN_1];

                    entry = resources.ResourceEntries[i];

                    PhPrintUInt64(number, ++count);
                    lvItemIndex = PhAddListViewItem(lvHandle, MAXINT, number, NULL);

                    if (IS_INTRESOURCE(entry.Type))
                    {
                        PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_TYPE, PvpGetResourceTypeString(entry.Type));
                    }
                    else
                    {
                        PIMAGE_RESOURCE_DIR_STRING_U resourceString = (PIMAGE_RESOURCE_DIR_STRING_U)entry.Type;

                        string = PhAllocateCopy(resourceString->NameString, resourceString->Length * sizeof(WCHAR));

                        PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_TYPE, string);
                        PhFree(string);
                    }

                    if (IS_INTRESOURCE(entry.Name))
                    {
                        PhPrintUInt32(number, (ULONG)entry.Name);
                        PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_NAME, number);
                    }
                    else
                    {
                        PIMAGE_RESOURCE_DIR_STRING_U resourceString = (PIMAGE_RESOURCE_DIR_STRING_U)entry.Name;

                        string = PhAllocateCopy(resourceString->NameString, resourceString->Length * sizeof(WCHAR));

                        PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_NAME, string);
                        PhFree(string);
                    }

                    if (IS_INTRESOURCE(entry.Language))
                    {
                        WCHAR name[LOCALE_NAME_MAX_LENGTH];

                        PhPrintUInt32(number, (ULONG)entry.Language);

                        if (LCIDToLocaleName((ULONG)entry.Language, name, LOCALE_NAME_MAX_LENGTH, LOCALE_ALLOW_NEUTRAL_NAMES))
                            PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_LCID, PhaFormatString(L"%s (%s)", number, name)->Buffer);
                        else
                            PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_LCID, number);
                    }
                    else
                    {
                        PIMAGE_RESOURCE_DIR_STRING_U resourceString = (PIMAGE_RESOURCE_DIR_STRING_U)entry.Language;

                        string = PhAllocateCopy(resourceString->NameString, resourceString->Length * sizeof(WCHAR));

                        PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_LCID, string);
                        PhFree(string);
                    }

                    PhSetListViewSubItem(lvHandle, lvItemIndex, PVE_RESOURCES_COLUMN_INDEX_SIZE, PhaFormatSize(entry.Size, -1)->Buffer);
                }

                PhFree(resources.ResourceEntries);
            }

            ExtendedListView_SortItems(lvHandle);
            
            EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
        }
        break;
    case WM_DESTROY:
        {
            PhSaveListViewColumnsToSetting(L"ImageResourcesListViewColumns", GetDlgItem(hwndDlg, IDC_LIST));
        }
        break;
    case WM_SHOWWINDOW:
        {
            if (!propPageContext->LayoutInitialized)
            {
                PPH_LAYOUT_ITEM dialogItem;

                dialogItem = PvAddPropPageLayoutItem(hwndDlg, hwndDlg,
                    PH_PROP_PAGE_TAB_CONTROL_PARENT, PH_ANCHOR_ALL);
                PvAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_LIST),
                    dialogItem, PH_ANCHOR_ALL);

                PvDoPropPageLayout(hwndDlg);

                propPageContext->LayoutInitialized = TRUE;
            }
        }
        break;
    case WM_NOTIFY:
        {
            PvHandleListViewNotifyForCopy(lParam, GetDlgItem(hwndDlg, IDC_LIST));
        }
        break;
    }

    return FALSE;
}
示例#20
0
/*
** Constructor.
**
*/
CDialog::CTab::CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc) :
    m_Window(CreateDialog(instance, MAKEINTRESOURCE(tabId), owner, tabProc)),
    m_Initialized(false)
{
    EnableThemeDialogTexture(m_Window, ETDT_ENABLETAB);
}
INT_PTR CALLBACK SetupWebSetup_WndProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _Inout_ WPARAM wParam,
    _Inout_ LPARAM lParam
    )
{
    PPH_SETUP_CONTEXT context = NULL;

    if (uMsg == WM_INITDIALOG)
    {
        context = GetProp(GetParent(hwndDlg), L"SetupContext");
        SetProp(hwndDlg, L"Context", (HANDLE)context);
    }
    else
    {
        context = (PPH_SETUP_CONTEXT)GetProp(hwndDlg, L"Context");
    }

    if (context == NULL)
        return FALSE;

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            SetupLoadImage(GetDlgItem(hwndDlg, IDC_PROJECT_ICON), MAKEINTRESOURCE(IDB_PNG1));
            SetupInitializeFont(GetDlgItem(hwndDlg, IDC_MAINHEADER), -17, FW_SEMIBOLD);
            //SetupInitializeFont(GetDlgItem(hwndDlg, IDC_SUBHEADER), -12, FW_NORMAL);
            SetupInitializeFont(GetDlgItem(hwndDlg, IDC_INSTALL_STATUS), -12, FW_SEMIBOLD);
            SetupInitializeFont(GetDlgItem(hwndDlg, IDC_INSTALL_SUBSTATUS), -12, FW_NORMAL);

            EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
        }
        break;
    case WM_NOTIFY:
        {
            LPNMHDR header = (LPNMHDR)lParam;
            LPPSHNOTIFY pageNotify = (LPPSHNOTIFY)header;

            switch (pageNotify->hdr.code)
            {
            case PSN_SETACTIVE:
                {
                    context->MainHeaderHandle = GetDlgItem(hwndDlg, IDC_MAINHEADER);
                    context->StatusHandle = GetDlgItem(hwndDlg, IDC_INSTALL_STATUS);
                    context->SubStatusHandle = GetDlgItem(hwndDlg, IDC_INSTALL_SUBSTATUS);
                    context->ProgressHandle = GetDlgItem(hwndDlg, IDC_INSTALL_PROGRESS);

                    SetWindowText(context->MainHeaderHandle, L"Checking for newer websetup version...");
                    SetWindowText(context->StatusHandle, L"Requesting latest version...");
                    SetWindowText(context->SubStatusHandle, L"");

                    // Disable Next/Back buttons
                    PropSheet_SetWizButtons(context->DialogHandle, 0);

                    PhCreateThread2(SetupDownloadWebSetupThread, context);
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
示例#22
0
INT_PTR CALLBACK CDialogPackage::SelectFolderDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_INITDIALOG:
    {
        EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
        c_Dialog->SetDialogFont(hWnd);

        std::wstring* existingPath = (std::wstring*)lParam;
        SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);

        *existingPath += L'*';
        WIN32_FIND_DATA fd;
        HANDLE hFind = FindFirstFileEx(existingPath->c_str(), FindExInfoStandard, &fd, FindExSearchNameMatch, NULL, 0);
        existingPath->pop_back();

        if (hFind != INVALID_HANDLE_VALUE)
        {
            const WCHAR* folder = PathFindFileName(existingPath->c_str());

            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_RADIO);
            std::wstring text = L"Add folder from ";
            text.append(folder, wcslen(folder) - 1);
            text += L':';
            SetWindowText(item, text.c_str());
            Button_SetCheck(item, BST_CHECKED);

            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_COMBO);

            do
            {
                if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
                        !(fd.cFileName[0] == L'.' && (!fd.cFileName[1] || fd.cFileName[1] == L'.' && !fd.cFileName[2])) &&
                        wcscmp(fd.cFileName, L"Backup") != 0 &&
                        wcscmp(fd.cFileName, L"@Backup") != 0)
                {
                    ComboBox_InsertString(item, -1, fd.cFileName);
                }
            }
            while (FindNextFile(hFind, &fd));

            ComboBox_SetCurSel(item, 0);

            FindClose(hFind);
        }
    }
    break;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDC_PACKAGESELECTFOLDER_EXISTING_RADIO:
        {
            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_COMBO);
            EnableWindow(item, TRUE);
            int sel = ComboBox_GetCurSel(item);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
            EnableWindow(item, FALSE);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON);
            EnableWindow(item, FALSE);

            item = GetDlgItem(hWnd, IDOK);
            EnableWindow(item, sel != -1);
        }
        break;

        case IDC_PACKAGESELECTFOLDER_CUSTOM_RADIO:
        {
            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_COMBO);
            EnableWindow(item, FALSE);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
            EnableWindow(item, TRUE);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON);
            EnableWindow(item, TRUE);

            SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT, EN_CHANGE), 0);
        }
        break;

        case IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT:
            if (HIWORD(wParam) == EN_CHANGE)
            {
                WCHAR buffer[MAX_PATH];
                int len = Edit_GetText((HWND)lParam, buffer, MAX_PATH);

                // Disable Add button if invalid directory
                DWORD attributes = GetFileAttributes(buffer);
                BOOL state = (attributes != INVALID_FILE_ATTRIBUTES &&
                              attributes & FILE_ATTRIBUTE_DIRECTORY);
                EnableWindow(GetDlgItem(hWnd, IDOK), state);
            }
            break;

        case IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON:
        {
            WCHAR buffer[MAX_PATH];
            BROWSEINFO bi = {0};
            bi.hwndOwner = hWnd;
            bi.ulFlags = BIF_USENEWUI | BIF_NONEWFOLDERBUTTON | BIF_RETURNONLYFSDIRS;

            PIDLIST_ABSOLUTE pidl = SHBrowseForFolder(&bi);
            if (pidl && SHGetPathFromIDList(pidl, buffer))
            {
                HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
                SetWindowText(item, buffer);
                CoTaskMemFree(pidl);
            }
        }
        break;

        case IDOK:
        {
            WCHAR buffer[MAX_PATH];
            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_RADIO);
            bool existing = Button_GetCheck(item) == BST_CHECKED;

            item = GetDlgItem(hWnd, existing ? IDC_PACKAGESELECTFOLDER_EXISTING_COMBO : IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
            GetWindowText(item, buffer, _countof(buffer));

            std::wstring* result = (std::wstring*)GetWindowLongPtr(hWnd, GWLP_USERDATA);

            if (existing)
            {
                *result += buffer;
            }
            else
            {
                *result = buffer;
            }
            *result += L'\\';

            EndDialog(hWnd, 1);
        }
        }
        break;

    case WM_CLOSE:
        EndDialog(hWnd, 0);
        break;

    default:
        return FALSE;
    }

    return TRUE;
}
示例#23
0
INT_PTR CALLBACK CDialogPackage::SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_INITDIALOG:
    {
        EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
        c_Dialog->SetDialogFont(hWnd);

        auto plugins = (std::pair<std::wstring, std::wstring>*)lParam;
        SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)plugins);
    }
    break;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON:
        case IDC_PACKAGESELECTPLUGIN_64BITBROWSE_BUTTON:
        {
            WCHAR buffer[MAX_PATH];
            buffer[0] = L'\0';

            OPENFILENAME ofn = { sizeof(OPENFILENAME) };
            ofn.Flags = OFN_FILEMUSTEXIST;
            ofn.lpstrFilter = L"Plugins (.dll)\0*.dll";
            ofn.lpstrTitle = L"Select plugin file";
            ofn.lpstrDefExt = L"dll";
            ofn.nFilterIndex = 0;
            ofn.lpstrFile = buffer;
            ofn.nMaxFile = _countof(buffer);
            ofn.hwndOwner = c_Dialog->GetWindow();

            if (!GetOpenFileName(&ofn))
            {
                break;
            }

            bool x32 = LOWORD(wParam) == IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON;

            LOADED_IMAGE* loadedImage = ImageLoad(StringUtil::NarrowUTF8(buffer).c_str(), NULL);
            if (loadedImage)
            {
                WORD machine = loadedImage->FileHeader->FileHeader.Machine;
                ImageUnload(loadedImage);

                if ((x32 && machine == IMAGE_FILE_MACHINE_I386) || (!x32 && machine == IMAGE_FILE_MACHINE_AMD64))
                {
                    // Check if same name as other DLL
                    auto plugins = (std::pair<std::wstring, std::wstring>*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
                    const WCHAR* otherName = PathFindFileName(x32 ? plugins->second.c_str() : plugins->first.c_str());
                    if (*otherName && _wcsicmp(otherName, PathFindFileName(buffer)) != 0)
                    {
                        MessageBox(hWnd, L"Plugins must have same name.", L"Rainmeter Skin Packager", MB_OK | MB_TOPMOST);
                        break;
                    }

                    PathSetDlgItemPath(hWnd, x32 ? IDC_PACKAGESELECTPLUGIN_32BIT_EDIT : IDC_PACKAGESELECTPLUGIN_64BIT_EDIT, buffer);

                    (x32 ? plugins->first : plugins->second) = buffer;

                    if (!plugins->first.empty() && !plugins->second.empty())
                    {
                        // Enable Add button if both plugins have been selected
                        EnableWindow(GetDlgItem(hWnd, IDOK), TRUE);
                    }
                    break;
                }
            }

            MessageBox(hWnd, L"Invalid plugin.", L"Rainmeter Skin Packager", MB_OK | MB_TOPMOST);
        }
        break;

        case IDOK:
            EndDialog(hWnd, 1);
            break;
        }
        break;

    case WM_CLOSE:
        EndDialog(hWnd, 0);
        break;

    default:
        return FALSE;
    }

    return TRUE;
}
示例#24
0
INT_PTR CALLBACK DotNetAsmPageDlgProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    LPPROPSHEETPAGE propSheetPage;
    PPH_PROCESS_PROPPAGECONTEXT propPageContext;
    PPH_PROCESS_ITEM processItem;
    PASMPAGE_CONTEXT context;

    if (PhPropPageDlgProcHeader(hwndDlg, uMsg, lParam, &propSheetPage, &propPageContext, &processItem))
    {
        context = propPageContext->Context;
    }
    else
    {
        return FALSE;
    }

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            PPH_STRING settings;
            HWND tnHandle;

            context = PhAllocate(sizeof(ASMPAGE_CONTEXT));
            memset(context, 0, sizeof(ASMPAGE_CONTEXT));
            propPageContext->Context = context;
            context->WindowHandle = hwndDlg;
            context->ProcessItem = processItem;

            context->ClrVersions = 0;
            PhGetProcessIsDotNetEx(processItem->ProcessId, NULL, 0, NULL, &context->ClrVersions);

            tnHandle = GetDlgItem(hwndDlg, IDC_LIST);
            context->TnHandle = tnHandle;

            TreeNew_SetCallback(tnHandle, DotNetAsmTreeNewCallback, context);
            TreeNew_SetExtendedFlags(tnHandle, TN_FLAG_ITEM_DRAG_SELECT, TN_FLAG_ITEM_DRAG_SELECT);
            PhSetControlTheme(tnHandle, L"explorer");
            SendMessage(TreeNew_GetTooltips(tnHandle), TTM_SETMAXTIPWIDTH, 0, MAXSHORT);
            PhAddTreeNewColumn(tnHandle, DNATNC_STRUCTURE, TRUE, L"Structure", 240, PH_ALIGN_LEFT, -2, 0);
            PhAddTreeNewColumn(tnHandle, DNATNC_ID, TRUE, L"ID", 50, PH_ALIGN_RIGHT, 0, DT_RIGHT);
            PhAddTreeNewColumn(tnHandle, DNATNC_FLAGS, TRUE, L"Flags", 120, PH_ALIGN_LEFT, 1, 0);
            PhAddTreeNewColumn(tnHandle, DNATNC_PATH, TRUE, L"Path", 600, PH_ALIGN_LEFT, 2, 0); // don't use path ellipsis - the user already has the base file name
            PhAddTreeNewColumn(tnHandle, DNATNC_NATIVEPATH, TRUE, L"Native image path", 600, PH_ALIGN_LEFT, 3, 0);

            settings = PhGetStringSetting(SETTING_NAME_ASM_TREE_LIST_COLUMNS);
            PhCmLoadSettings(tnHandle, &settings->sr);
            PhDereferenceObject(settings);

            PhMoveReference(&context->TnErrorMessage, PhCreateString(L"Loading .NET assemblies..."));
            TreeNew_SetEmptyText(tnHandle, &context->TnErrorMessage->sr, 0);

            if (
                !IsProcessSuspended(processItem->ProcessId) ||
                PhShowMessage(hwndDlg, MB_ICONWARNING | MB_YESNO, L".NET assembly enumeration may not work properly because the process is currently suspended. Do you want to continue?") == IDYES
                )
            {
                CreateDotNetTraceQueryThread(
                    hwndDlg,
                    context->ClrVersions,
                    processItem->ProcessId
                    );
            }
            else
            {
                PhMoveReference(&context->TnErrorMessage,
                    PhCreateString(L"Unable to start the event tracing session because the process is suspended.")
                    );
                TreeNew_SetEmptyText(tnHandle, &context->TnErrorMessage->sr, 0);
                InvalidateRect(tnHandle, NULL, FALSE);
            }

            EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB);
        }
        break;
    case WM_DESTROY:
        {
            PPH_STRING settings;
            ULONG i;

            settings = PhCmSaveSettings(context->TnHandle);
            PhSetStringSetting2(SETTING_NAME_ASM_TREE_LIST_COLUMNS, &settings->sr);
            PhDereferenceObject(settings);

            if (context->NodeList)
            {
                for (i = 0; i < context->NodeList->Count; i++)
                    DestroyNode(context->NodeList->Items[i]);

                PhDereferenceObject(context->NodeList);
            }

            if (context->NodeRootList)
                PhDereferenceObject(context->NodeRootList);

            PhClearReference(&context->TnErrorMessage);
            PhFree(context);

            PhPropPageDlgProcDestroy(hwndDlg);
        }
        break;
    case WM_SHOWWINDOW:
        {
            PPH_LAYOUT_ITEM dialogItem;

            if (dialogItem = PhBeginPropPageLayout(hwndDlg, propPageContext))
            {
                PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_LIST), dialogItem, PH_ANCHOR_ALL);
                PhEndPropPageLayout(hwndDlg, propPageContext);
            }
        }
        break;
    case WM_COMMAND:
        {
            switch (GET_WM_COMMAND_ID(wParam, lParam))
            {
            case ID_COPY:
                {
                    PPH_STRING text;

                    text = PhGetTreeNewText(context->TnHandle, 0);
                    PhSetClipboardString(context->TnHandle, &text->sr);
                    PhDereferenceObject(text);
                }
                break;
            }
        }
        break;
    case UPDATE_MSG:
        {
            ULONG result = (ULONG)wParam;
            PASMPAGE_QUERY_CONTEXT queryContext = (PASMPAGE_QUERY_CONTEXT)lParam;

            if (result == 0)
            {
                PhSwapReference(&context->NodeList, queryContext->NodeList);
                PhSwapReference(&context->NodeRootList, queryContext->NodeRootList);

                DestroyDotNetTraceQuery(queryContext);

                TreeNew_NodesStructured(context->TnHandle);
            }
            else
            {
                PhMoveReference(&context->TnErrorMessage,
                    PhConcatStrings2(L"Unable to start the event tracing session: ", PhGetStringOrDefault(PhGetWin32Message(result), L"Unknown error"))
                    );
                TreeNew_SetEmptyText(context->TnHandle, &context->TnErrorMessage->sr, 0);
                InvalidateRect(context->TnHandle, NULL, FALSE);
            }
        }
        break;
    }

    return FALSE;
}