Ejemplo n.º 1
0
INT_PTR CALLBACK
AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	INT iListIndex;
	GLOBALS* g;

	g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);

	switch (uMsg)
	{
		case WM_INITDIALOG:
			g = (GLOBALS*)lParam;
			SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
			AdvAppearanceDlg_Init(hwndDlg, g);
			break;

		case WM_DESTROY:
			AdvAppearanceDlg_CleanUp(hwndDlg, g);
			break;

		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDOK:
					SaveCurrentValues(hwndDlg, g);
					EndDialog(hwndDlg, IDOK);
					break;

				case IDCANCEL:
					g->ThemeAdv = g->Theme;
					EndDialog(hwndDlg, IDCANCEL);
					break;

				case IDC_APPEARANCE_PREVIEW:
					SaveCurrentValues(hwndDlg, g);
					SelectComboByElement(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, lParam);
					g->CurrentElement = (INT)lParam;
					UpdateControls(hwndDlg, g);
					break;

				case IDC_ADVAPPEARANCE_ELEMENT:
					if (HIWORD(wParam) == CBN_SELCHANGE)
					{
						SaveCurrentValues(hwndDlg, g);
						iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0, 0);
						g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, (WPARAM)iListIndex, 0);
						UpdateControls(hwndDlg, g);
					}
					break;

				case IDC_ADVAPPEARANCE_SIZE_E:
					if (g && HIWORD(wParam) == EN_CHANGE)
					{
						INT i = (INT)LOWORD(SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD, UDM_GETPOS,0,0L));

						switch (g->CurrentElement)
						{
							case IDX_INACTIVE_CAPTION:
							case IDX_ACTIVE_CAPTION:
							case IDX_CAPTION_BUTTON:
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYCAPTION, 0, i);
								break;

							case IDX_MENU:
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYMENU, 0, i);
								break;

							case IDX_SCROLLBAR:
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCXSCROLLBAR, 0, i);
								break;

							case IDX_INACTIVE_BORDER:
							case IDX_ACTIVE_BORDER:
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETCYSIZEFRAME, 0, i);
								break;
						}
					}
					break;

				case IDC_ADVAPPEARANCE_FONT_C:
					if (g && HIWORD(wParam) == CBN_SELCHANGE)
					{
						switch (g->CurrentElement)
						{
							case IDX_INACTIVE_CAPTION:
							case IDX_ACTIVE_CAPTION:
								GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
									g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_MENU:
								GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
									g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_DIALOG:
								GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
									g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;
						}
					}
					break;

				case IDC_ADVAPPEARANCE_FONTSIZE_E:
					if (g && HIWORD(wParam) == CBN_SELCHANGE)
					{
						HDC hdcDlg = GetDC(hwndDlg);
						INT i;

						switch (g->CurrentElement)
						{
							case IDX_INACTIVE_CAPTION:
							case IDX_ACTIVE_CAPTION:
								i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
									-MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_MENU:
								i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
									-MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_DIALOG:
								i = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
									-MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;
						}

						ReleaseDC(hwndDlg, hdcDlg);
					}
					else if (g && HIWORD(wParam) == CBN_EDITCHANGE)
					{
						HDC hdcDlg = GetDC(hwndDlg);
						INT i;

						switch (g->CurrentElement)
						{
							case IDX_INACTIVE_CAPTION:
							case IDX_ACTIVE_CAPTION:
								i = GetEditedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
									-MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_MENU:
								i = GetEditedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
									-MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_DIALOG:
								i = GetEditedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
									-MulDiv(i , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;
						}

						ReleaseDC(hwndDlg, hdcDlg);
					}
					break;

				case IDC_ADVAPPEARANCE_FONTBOLD:
					if (g && HIWORD(wParam) == BN_CLICKED)
					{
						INT i;

						switch (g->CurrentElement)
						{
							case IDX_INACTIVE_CAPTION:
							case IDX_ACTIVE_CAPTION:
								i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight =
									(i == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_MENU:
								i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);

								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight =
									(i == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_DIALOG:
								i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfWeight =
									(i == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;
						}
					}
					break;

				case IDC_ADVAPPEARANCE_FONTITALIC:
					if (g && HIWORD(wParam) == BN_CLICKED)
					{
						INT i;

						switch (g->CurrentElement)
						{
							case IDX_INACTIVE_CAPTION:
							case IDX_ACTIVE_CAPTION:
								i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
									(i == BST_CHECKED) ? TRUE : FALSE;
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_MENU:
								i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
									(i == BST_CHECKED) ? TRUE : FALSE;
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;

							case IDX_DIALOG:
								i = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
								g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
									(i == BST_CHECKED) ? TRUE : FALSE;
								SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->ThemeAdv);
								break;
						}
					}
					break;

				case IDC_ADVAPPEARANCE_COLOR1_B:
					GetColor(hwndDlg, g, 0);
					break;

				case IDC_ADVAPPEARANCE_COLOR2_B:
					GetColor(hwndDlg, g, 1);
					break;

				case IDC_ADVAPPEARANCE_FONTCOLOR_B:
					GetColor(hwndDlg, g, 2);
					break;

				default:
					return FALSE;
			}
			break;

		default:
			return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 2
0
INT_PTR CALLBACK
AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    INT iSelection, iProperty;
    GLOBALS* g;
    PLOGFONTW plfFont;

    g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);

    switch (uMsg)
    {
        case WM_INITDIALOG:
            g = (GLOBALS*)lParam;
            SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
            AdvAppearanceDlg_Init(hwndDlg, g);
            break;

        case WM_DESTROY:
            AdvAppearanceDlg_CleanUp(hwndDlg, g);
            break;

        case WM_COMMAND:
            if(g == NULL)
                return TRUE;

            switch(LOWORD(wParam))
            {
                case IDOK:
                    SaveCurrentValues(hwndDlg, g);
                    EndDialog(hwndDlg, IDOK);
                    break;

                case IDCANCEL:
                    g->SchemeAdv = g->Scheme;
                    EndDialog(hwndDlg, IDCANCEL);
                    break;

                case IDC_APPEARANCE_PREVIEW:
                    SaveCurrentValues(hwndDlg, g);
                    SelectComboByElement(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, lParam);
                    g->CurrentElement = (INT)lParam;
                    UpdateControls(hwndDlg, g);
                    break;

                case IDC_ADVAPPEARANCE_ELEMENT:
                    if (HIWORD(wParam) == CBN_SELCHANGE)
                    {
                        SaveCurrentValues(hwndDlg, g);
                        iSelection = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0, 0);
                        g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA, iSelection, 0);
                        UpdateControls(hwndDlg, g);
                    }
                    break;

                case IDC_ADVAPPEARANCE_SIZE_E:
                    if (HIWORD(wParam) == EN_CHANGE)
                    {
                        iProperty = g_Assignment[g->CurrentElement].Size;
                        if(iProperty == -1)
                            return TRUE;

                        iSelection = LOWORD(SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD, UDM_GETPOS,0,0L));
                        SchemeSetMetric(&g->SchemeAdv, iProperty, iSelection);
                        SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETSIZE, iProperty, iSelection);

                        iProperty = g_Assignment[g->CurrentElement].Size2;
                        if(iProperty != -1)
                            SchemeSetMetric(&g->SchemeAdv, iProperty, iSelection);
                    }
                    break;

                case IDC_ADVAPPEARANCE_FONT_C:
                    if (HIWORD(wParam) == CBN_SELCHANGE)
                    {
                        iProperty = g_Assignment[g->CurrentElement].Font;
                        if(iProperty == -1)
                            return TRUE;

                        plfFont = SchemeGetFont(&g->SchemeAdv, iProperty);
                        GetSelectedComboText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, plfFont->lfFaceName);
                        SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETFONT, iProperty, (LPARAM)plfFont);
                    }
                    break;

                case IDC_ADVAPPEARANCE_FONTSIZE_E:
                    if ((HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE))
                    {
                        HDC hdcDlg;

                        iProperty =  g_Assignment[g->CurrentElement].Font;
                        if(iProperty == -1)
                            return TRUE;

                        hdcDlg = GetDC(hwndDlg);

                        plfFont = SchemeGetFont(&g->SchemeAdv, iProperty);
                        iSelection = GetSelectedComboInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E);
                        plfFont->lfHeight = -MulDiv(iSelection , GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
                        SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_UPDATETHEME, 0, (LPARAM)&g->SchemeAdv);

                        ReleaseDC(hwndDlg, hdcDlg);
                    }
                    break;

                case IDC_ADVAPPEARANCE_FONTBOLD:
                    if (HIWORD(wParam) == BN_CLICKED)
                    {
                        iProperty = g_Assignment[g->CurrentElement].Font;
                        if(iProperty == -1)
                            return TRUE;

                        plfFont = SchemeGetFont(&g->SchemeAdv, iProperty);
                        iSelection = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_GETCHECK, 0, 0);
                        plfFont->lfWeight = (iSelection == BST_CHECKED) ? FW_BOLD : FW_NORMAL;
                        SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETFONT, iProperty, (LPARAM)plfFont);
                    }
                    break;

                case IDC_ADVAPPEARANCE_FONTITALIC:
                    if (HIWORD(wParam) == BN_CLICKED)
                    {
                        iProperty = g_Assignment[g->CurrentElement].Font;
                        if(iProperty == -1)
                            return TRUE;

                        plfFont = SchemeGetFont(&g->SchemeAdv, iProperty);
                        iSelection = (INT)SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
                        plfFont->lfItalic = (iSelection == BST_CHECKED) ? TRUE : FALSE;
                        SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_PREVIEW, PVM_SETFONT, iProperty, (LPARAM)plfFont);
                    }
                    break;

                case IDC_ADVAPPEARANCE_COLOR1_B:
                    GetColor(hwndDlg, g, 0);
                    break;

                case IDC_ADVAPPEARANCE_COLOR2_B:
                    GetColor(hwndDlg, g, 1);
                    break;

                case IDC_ADVAPPEARANCE_FONTCOLOR_B:
                    GetColor(hwndDlg, g, 2);
                    break;

                default:
                    return FALSE;
            }
            break;

        default:
            return FALSE;
    }

    return TRUE;
}