[CONSOLE.CPL]: Fix the console window preview:

- turn it into a custom control;
- supports dynamic preview area depending on the actual current monitor screen resolution;
  (note that on ReactOS, the WM_DISPLAYCHANGE is not correctly sent, see CORE-13212, therefore this functionality won't show up yet)
- supports correct rescaling of the console preview drawn in the preview area;
- supports dependence of the console preview with respect to the chosen font character dimensions.
The code is there, it may be a little bit improved in the future.
CORE-13196 #resolve

Other additions:
- Add a few space between the console preview text window border and the text sample;
- PaintText and PaintStaticControls do not need to return anything.

svn path=/trunk/; revision=74504
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-08 17:33:33 +00:00
parent 9e97728d4f
commit a3842a814c
26 changed files with 529 additions and 145 deletions

View file

@ -14,11 +14,10 @@
static DWORD ActiveStaticControl = 0;
static BOOL
static VOID
PaintStaticControls(
IN HWND hDlg,
IN PCONSOLE_STATE_INFO pConInfo,
IN LPDRAWITEMSTRUCT drawItem)
IN LPDRAWITEMSTRUCT drawItem,
IN PCONSOLE_STATE_INFO pConInfo)
{
HBRUSH hBrush;
DWORD index;
@ -27,15 +26,13 @@ PaintStaticControls(
ARRAYSIZE(pConInfo->ColorTable) - 1);
hBrush = CreateSolidBrush(pConInfo->ColorTable[index]);
if (!hBrush) return FALSE;
if (!hBrush) return;
FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
DeleteObject(hBrush);
if (ActiveStaticControl == index)
DrawFocusRect(drawItem->hDC, &drawItem->rcItem);
return TRUE;
}
INT_PTR CALLBACK
@ -67,14 +64,14 @@ ColorsProc(HWND hDlg,
{
LPDRAWITEMSTRUCT drawItem = (LPDRAWITEMSTRUCT)lParam;
if (drawItem->CtlID >= IDC_STATIC_COLOR1 && drawItem->CtlID <= IDC_STATIC_COLOR16)
return PaintStaticControls(hDlg, ConInfo, drawItem);
if (IDC_STATIC_COLOR1 <= drawItem->CtlID && drawItem->CtlID <= IDC_STATIC_COLOR16)
PaintStaticControls(drawItem, ConInfo);
else if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR)
return PaintText(drawItem, ConInfo, Screen);
PaintText(drawItem, ConInfo, Screen);
else if (drawItem->CtlID == IDC_STATIC_POPUP_COLOR)
return PaintText(drawItem, ConInfo, Popup);
PaintText(drawItem, ConInfo, Popup);
break;
return TRUE;
}
case WM_NOTIFY:

View file

@ -256,7 +256,9 @@ InitApplet(HANDLE hSectionOrWnd)
InitPropSheetPage(&psp[i++], IDD_PROPPAGECOLORS , ColorsProc );
/* Display the property sheet */
RegisterWinPrevClass(hApplet);
Result = PropertySheetW(&psh);
UnRegisterWinPrevClass(hApplet);
/* First cleanup */
if (hCurrentFont) DeleteObject(hCurrentFont);

View file

@ -42,12 +42,17 @@ extern HFONT hCurrentFont;
VOID ApplyConsoleInfo(HWND hwndDlg);
VOID
PaintConsole(
IN LPDRAWITEMSTRUCT drawItem,
IN PCONSOLE_STATE_INFO pConInfo);
/* Preview Windows */
BOOL
RegisterWinPrevClass(
IN HINSTANCE hInstance);
BOOL
UnRegisterWinPrevClass(
IN HINSTANCE hInstance);
VOID
PaintText(
IN LPDRAWITEMSTRUCT drawItem,
IN PCONSOLE_STATE_INFO pConInfo,

View file

@ -716,14 +716,20 @@ FontProc(HWND hDlg,
{
LPDRAWITEMSTRUCT drawItem = (LPDRAWITEMSTRUCT)lParam;
if (drawItem->CtlID == IDC_STATIC_FONT_WINDOW_PREVIEW)
PaintConsole(drawItem, ConInfo);
else if (drawItem->CtlID == IDC_STATIC_SELECT_FONT_PREVIEW)
if (drawItem->CtlID == IDC_STATIC_SELECT_FONT_PREVIEW)
PaintText(drawItem, ConInfo, Screen);
return TRUE;
}
case WM_DISPLAYCHANGE:
{
/* Retransmit to the preview window */
SendDlgItemMessageW(hDlg, IDC_STATIC_FONT_WINDOW_PREVIEW,
WM_DISPLAYCHANGE, wParam, lParam);
break;
}
case WM_NOTIFY:
{
switch (((LPNMHDR)lParam)->code)

View file

@ -35,7 +35,7 @@ CAPTION "Шрифт"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Прозоречен преглед:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Размер:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -58,7 +58,7 @@ CAPTION "Подредба"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Прозоречен преглед:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Размер на екранния буфер", IDC_STATIC, 130, 12, 135, 50
LTEXT "&Ширина:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Височина:", IDC_STATIC, 140, 46, 39, 10

View file

@ -41,7 +41,7 @@ CAPTION "Písmo"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Náhled okna:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Velikost:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -64,7 +64,7 @@ CAPTION "Vzhled"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Náhled okna:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Velikost paměti zobrazení", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Šířka:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Výška:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "Schrift"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Fenstervorschau:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Größe:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Fenstervorschau:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Fensterpuffergröße", IDC_STATIC, 130, 15, 115, 40
LTEXT "&Breite:", IDC_STATIC, 135, 30, 25, 10
LTEXT "&Höhe:", IDC_STATIC, 135, 40, 25, 10

View file

@ -35,7 +35,7 @@ CAPTION "Font"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Window Preview:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Size:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -58,7 +58,7 @@ CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Window Preview:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Screen Buffer Size", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Width:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Height:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "Fuente"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Ventana de Previsualización:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Tamaño:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Disposición"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Ventana de Previsualización:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Tamaño del Búfer de Pantalla", IDC_STATIC, 130, 15, 115, 40
LTEXT "&Anchura:", IDC_STATIC, 135, 30, 25, 10
LTEXT "A&ltura:", IDC_STATIC, 135, 40, 25, 10

View file

@ -37,7 +37,7 @@ CAPTION "Police"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Fenêtre de Prévisualisation :", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Taille :", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Disposition"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Fenêtre de Prévisualisation :", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Taille du buffer de l'écran", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Largeur :", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Hauteur :", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "גופן"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "תצוגה מקדימה:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "גודל:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "תצורה"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "תצוגה מקדימה:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "גודל מתווך המסך", IDC_STATIC, 130, 12, 115, 50
LTEXT "רוחב:", IDC_STATIC, 140, 28, 40, 10
LTEXT "גובה:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "Font"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Tinjauan Jendela:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Ukuran:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Tata Letak"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Tinjauan Jendela:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Ukuran Bufer Layar", IDC_STATIC, 130, 15, 115, 40
LTEXT "&Panjang:", IDC_STATIC, 135, 30, 25, 10
LTEXT "&Tinggi:", IDC_STATIC, 135, 40, 25, 10

View file

@ -37,7 +37,7 @@ CAPTION "Font"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Anteprima:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Dimansione:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Anteprima:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Dimensione del buffer dello schermo", IDC_STATIC, 130, 15, 115, 40
LTEXT "&Larghezza:", IDC_STATIC, 135, 30, 25, 10
LTEXT "&Altezza:", IDC_STATIC, 135, 40, 25, 10

View file

@ -35,7 +35,7 @@ CAPTION "フォント"
FONT 9, "MS UI Gothic"
BEGIN
LTEXT "ウィンドウのプレビュー:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "サイズ:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -58,7 +58,7 @@ CAPTION "レイアウト"
FONT 9, "MS UI Gothic"
BEGIN
LTEXT "ウィンドウのプレビュー:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "スクリーンバッファーのサイズ", IDC_STATIC, 130, 12, 115, 50
LTEXT "幅(&W):", IDC_STATIC, 140, 28, 40, 10
LTEXT "高さ(&H):", IDC_STATIC, 140, 46, 39, 10

View file

@ -35,7 +35,7 @@ CAPTION "Skrift"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Vindu forhåndsvisning:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Størrelse:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -58,7 +58,7 @@ CAPTION "Oppsett"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Vindu forhåndsvisning:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Størrelse på skjermbuffer", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Bredde:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Høyde:", IDC_STATIC, 140, 46, 39, 10

View file

@ -42,7 +42,7 @@ CAPTION "Czcionka"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Okno podglądu:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Rozmiar:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -65,7 +65,7 @@ CAPTION "Układ"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Okno podglądu:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Rozmiar bufora ekranu", IDC_STATIC, 130, 15, 115, 40
LTEXT "&Szerokość:", IDC_STATIC, 135, 30, 25, 10
LTEXT "&Wysokość:", IDC_STATIC, 135, 40, 25, 10

View file

@ -35,7 +35,7 @@ CAPTION "Fonte"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Visualização da janela:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "&Tamanho:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -58,7 +58,7 @@ CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Visualização da janela:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Tamanho do buffer de tela", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Largura:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Altura:", IDC_STATIC, 140, 46, 39, 10

View file

@ -44,7 +44,7 @@ CAPTION "Font"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Previzionare:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Mărime:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -67,7 +67,7 @@ CAPTION "Aspect"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Previzionare:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Dimensiunea textului", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Coloane:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Rânduri:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "Шрифт"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Окно предпросмотра:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Размер:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Раскладка"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Окно предпросмотра:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Размер буфера экрана", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Ширина:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Высота:", IDC_STATIC, 140, 46, 39, 10

View file

@ -39,7 +39,7 @@ CAPTION "Písmo"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Ukážka okna:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Veľkosť:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -62,7 +62,7 @@ CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Ukážka okna:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Screen Buffer Size", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Width:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Height:", IDC_STATIC, 140, 46, 39, 10

View file

@ -39,7 +39,7 @@ CAPTION "Font"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Dritare Preview:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Masë:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -62,7 +62,7 @@ CAPTION "Pamja"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Dritare Preview:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Masa e Ekranit Buffer", IDC_STATIC, 130, 12, 115, 50
LTEXT "Gjerë:", IDC_STATIC, 140, 28, 40, 10
LTEXT "Gjatë:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "Yazı Tipi"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Pencere Ön İzlemesi:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "&Boyutlar:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Yerleşim"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Pencere Ön İzlemesi:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Görüntülük Arabelleği Boyutları", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Genişlik:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Yükseklik:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "Шрифт"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Зразок вікна:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "Size:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "Розкладка"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Зразок вікна:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "Розмір буфера екрана", IDC_STATIC, 130, 12, 115, 50
LTEXT "&Ширина:", IDC_STATIC, 140, 28, 40, 10
LTEXT "&Висота:", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "字体"
FONT 9, "MS Shell Dlg"
BEGIN
LTEXT "窗口预览:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "大小:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "布局"
FONT 9, "MS Shell Dlg"
BEGIN
LTEXT "窗口预览:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "屏幕缓冲区大小", IDC_STATIC, 130, 12, 115, 50
LTEXT "宽(&W)", IDC_STATIC, 140, 28, 40, 10
LTEXT "高(&H)", IDC_STATIC, 140, 46, 39, 10

View file

@ -37,7 +37,7 @@ CAPTION "字型"
FONT 9, "MS Shell Dlg"
BEGIN
LTEXT "視窗預覽:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
LTEXT "大小:", IDC_STATIC, 130, 7, 45, 10
LISTBOX IDC_LBOX_FONTSIZE, 130, 20, 50, 86, LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_CBOX_FONTSIZE, 130, 20, 30, 86, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP
@ -60,7 +60,7 @@ CAPTION "佈局"
FONT 9, "MS Shell Dlg"
BEGIN
LTEXT "視窗預覽:", IDC_STATIC, 7, 7, 115, 10
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN, 7, 20, 115, 70, WS_EX_CLIENTEDGE
CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "WinPreview", WS_BORDER | WS_CHILD | WS_VISIBLE, 7, 20, 115, 70
GROUPBOX "螢幕緩衝區大小", IDC_STATIC, 130, 12, 115, 50
LTEXT "寬(&W)", IDC_STATIC, 140, 28, 40, 10
LTEXT "高(&H)", IDC_STATIC, 140, 46, 39, 10

View file

@ -12,6 +12,448 @@
#define NDEBUG
#include <debug.h>
/* CONSOLE WINDOW PREVIEW Control *********************************************/
#define WIN_PREVIEW_CLASS L"WinPreview"
typedef struct _WINPREV_DATA
{
HWND hWnd; // The window which this structure refers to
RECT rcMaxArea; // Maximum rectangle in which the preview window can be sized
SIZE siPreview; // Actual size of the preview window
SIZE siVirtScr; // Width and Height of the virtual screen
PVOID pData; // Private data
} WINPREV_DATA, *PWINPREV_DATA;
static LRESULT CALLBACK
WinPrevProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL
RegisterWinPrevClass(
IN HINSTANCE hInstance)
{
WNDCLASSW WndClass;
WndClass.lpszClassName = WIN_PREVIEW_CLASS;
WndClass.lpfnWndProc = WinPrevProc;
WndClass.style = 0;
WndClass.hInstance = hInstance;
WndClass.hIcon = NULL;
WndClass.hCursor = LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_ARROW));
WndClass.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
WndClass.lpszMenuName = NULL;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0; // sizeof(PWINPREV_DATA);
return (RegisterClassW(&WndClass) != 0);
}
BOOL
UnRegisterWinPrevClass(
IN HINSTANCE hInstance)
{
return UnregisterClassW(WIN_PREVIEW_CLASS, hInstance);
}
static VOID
WinPrev_OnDisplayChange(
IN PWINPREV_DATA pData)
{
// RECT rcNew;
pData->siVirtScr.cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
pData->siVirtScr.cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
/*
* The rescaling factor "siPreview / siVirtScr" should be the minimum of the ratios
* pData->rcMaxArea.right / pData->siVirtScr.cx , and
* pData->rcMaxArea.bottom / pData->siVirtScr.cy ,
* or equivalently, the maximum of the inverse of these ratios.
* This condition is equivalent to the following inequality being tested.
*/
// if (pData->siVirtScr.cx / pData->rcMaxArea.right >= pData->siVirtScr.cy / pData->rcMaxArea.bottom)
if (pData->siVirtScr.cx * pData->rcMaxArea.bottom >= pData->siVirtScr.cy * pData->rcMaxArea.right)
{
pData->siPreview.cx = MulDiv(pData->siVirtScr.cx, pData->rcMaxArea.right, pData->siVirtScr.cx);
pData->siPreview.cy = MulDiv(pData->siVirtScr.cy, pData->rcMaxArea.right, pData->siVirtScr.cx);
}
else
{
pData->siPreview.cx = MulDiv(pData->siVirtScr.cx, pData->rcMaxArea.bottom, pData->siVirtScr.cy);
pData->siPreview.cy = MulDiv(pData->siVirtScr.cy, pData->rcMaxArea.bottom, pData->siVirtScr.cy);
}
/*
* Now, the lengths in screen-units can be rescaled into preview-units with:
* MulDiv(cx, pData->siPreview.cx, pData->siVirtScr.cx);
* and:
* MulDiv(cy, pData->siPreview.cy, pData->siVirtScr.cy);
*/
#if 0 // TODO: Investigate!
/*
* Since both rcMaxArea and siPreview are client window area sizes,
* transform them into window sizes.
*/
SetRect(&rcNew, 0, 0, pData->siPreview.cx, pData->siPreview.cy);
AdjustWindowRect(&rcNew,
WS_BORDER,
// GetWindowLongPtrW(pData->hWnd, GWL_STYLE) & ~WS_OVERLAPPED,
FALSE);
OffsetRect(&rcNew, -rcNew.left, -rcNew.top);
rcNew.right += 2;
rcNew.bottom += 2;
#endif
SetWindowPos(pData->hWnd,
0 /* HWND_TOP */,
0, 0,
pData->siPreview.cx, pData->siPreview.cy,
// rcNew.right, rcNew.bottom,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
#define RescaleCX(pData, len) \
MulDiv((len), (pData)->siPreview.cx, (pData)->siVirtScr.cx)
#define RescaleCY(pData, len) \
MulDiv((len), (pData)->siPreview.cy, (pData)->siVirtScr.cy)
#define RescaleRect(pData, rect) \
do { \
(rect).left = RescaleCX((pData), (rect).left); \
(rect).right = RescaleCX((pData), (rect).right); \
(rect).top = RescaleCY((pData), (rect).top); \
(rect).bottom = RescaleCY((pData), (rect).bottom); \
} while (0)
#if 0
static VOID
WinPrev_OnSize(VOID)
{
}
#endif
static VOID
WinPrev_OnDraw(
IN HDC hDC,
IN PWINPREV_DATA pData)
{
PCONSOLE_STATE_INFO pConInfo = (PCONSOLE_STATE_INFO)pData->pData;
HBRUSH hBrush;
RECT rcWin, fRect;
SIZE /*siBorder,*/ siFrame, siButton, siScroll;
SIZE resize;
RECT rcItem;
GetClientRect(pData->hWnd, &rcItem);
/*
* Retrieve some system metrics and rescale them.
* They will be added separately, so that to always round the sizes up.
*/
/* Don't care about border as it is almost always 1 and <= frame size */
/* Example: Frame = 4, or 13 ... while Border = 1 */
// siBorder.cx = GetSystemMetrics(SM_CXBORDER);
// siBorder.cy = GetSystemMetrics(SM_CYBORDER);
/* Window frame size */
siFrame.cx = GetSystemMetrics(SM_CXFRAME);
if (siFrame.cx > 0)
{
siFrame.cx = RescaleCX(pData, siFrame.cx);
siFrame.cx = max(1, siFrame.cx);
}
siFrame.cy = GetSystemMetrics(SM_CYFRAME);
if (siFrame.cy > 0)
{
siFrame.cy = RescaleCY(pData, siFrame.cy);
siFrame.cy = max(1, siFrame.cy);
}
/* Window caption buttons */
siButton.cx = GetSystemMetrics(SM_CXSIZE);
siButton.cx = RescaleCX(pData, siButton.cx);
siButton.cx = max(1, siButton.cx);
siButton.cy = GetSystemMetrics(SM_CYSIZE);
siButton.cy = RescaleCY(pData, siButton.cy);
siButton.cy = max(1, siButton.cy);
/* Enlarge them for improving their appearance */
// siButton.cx *= 2;
siButton.cy *= 2;
/* Dimensions of the scrollbars */
siScroll.cx = GetSystemMetrics(SM_CXVSCROLL);
siScroll.cx = RescaleCX(pData, siScroll.cx);
siScroll.cx = max(1, siScroll.cx);
siScroll.cy = GetSystemMetrics(SM_CYHSCROLL);
siScroll.cy = RescaleCY(pData, siScroll.cy);
siScroll.cy = max(1, siScroll.cy);
// FIXME: Use SM_CXMIN, SM_CYMIN ??
/*
* Compute the console window layout
*/
/* We start with the console client area, rescaled for the preview */
SetRect(&rcWin, 0, 0,
pConInfo->WindowSize.X * pConInfo->FontSize.X,
pConInfo->WindowSize.Y * pConInfo->FontSize.Y);
RescaleRect(pData, rcWin);
/* Add the scrollbars if needed (does not account for any frame) */
if (pConInfo->WindowSize.X < pConInfo->ScreenBufferSize.X)
{
/* Horizontal scrollbar */
rcWin.bottom += siScroll.cy;
// NOTE: If an additional exterior frame is needed, add +1
}
else
{
/* No scrollbar */
siScroll.cy = 0;
}
if (pConInfo->WindowSize.Y < pConInfo->ScreenBufferSize.Y)
{
/* Vertical scrollbar */
rcWin.right += siScroll.cx;
// NOTE: If an additional exterior frame is needed, add +1
}
else
{
/* No scrollbar */
siScroll.cx = 0;
}
/* Add the title bar, taking into account the frames */
rcWin.top -= siButton.cy - 1;
/* If we have a non-zero window frame size, add an interior border and the frame */
resize.cx = (siFrame.cx > 0 ? 1 + siFrame.cx : 0);
resize.cy = (siFrame.cy > 0 ? 1 + siFrame.cy : 0);
/* Add the outer border */
++resize.cx, ++resize.cy;
InflateRect(&rcWin, resize.cx, resize.cy);
/* Finally, move the window rectangle back to its correct origin */
OffsetRect(&rcWin, -rcWin.left, -rcWin.top);
if ( pConInfo->WindowPosition.x == MAXDWORD &&
pConInfo->WindowPosition.y == MAXDWORD )
{
// OffsetRect(&rcWin, (rcItem.right - rcItem.left) / 3, (rcItem.bottom - rcItem.top) / 3);
OffsetRect(&rcWin, 0, 0);
}
else
{
OffsetRect(&rcWin,
RescaleCX(pData, pConInfo->WindowPosition.x),
RescaleCY(pData, pConInfo->WindowPosition.y));
}
/*
* Paint the preview window
*/
/* Fill the background with desktop colour */
FillRect(hDC, &rcItem, GetSysColorBrush(COLOR_BACKGROUND));
/*
* Draw the exterior frame. Use 'FillRect' instead of 'FrameRect'
* so that, when we want to draw frames around other elements,
* we can just instead separate them with space instead of redrawing
* a frame with 'FrameRect'.
*/
FillRect(hDC, &rcWin, GetSysColorBrush(COLOR_WINDOWFRAME));
InflateRect(&rcWin, -1, -1);
/* Draw the border */
hBrush = GetSysColorBrush(COLOR_ACTIVEBORDER);
if (siFrame.cx > 0)
{
SetRect(&fRect, rcWin.left, rcWin.top, rcWin.left + siFrame.cx, rcWin.bottom);
FillRect(hDC, &fRect, hBrush);
SetRect(&fRect, rcWin.right - siFrame.cx, rcWin.top, rcWin.right, rcWin.bottom);
FillRect(hDC, &fRect, hBrush);
InflateRect(&rcWin, -siFrame.cx, 0);
}
if (siFrame.cy > 0)
{
SetRect(&fRect, rcWin.left, rcWin.top, rcWin.right, rcWin.top + siFrame.cy);
FillRect(hDC, &fRect, hBrush);
SetRect(&fRect, rcWin.left, rcWin.bottom - siFrame.cy, rcWin.right, rcWin.bottom);
FillRect(hDC, &fRect, hBrush);
InflateRect(&rcWin, 0, -siFrame.cy);
}
/* Draw the interior frame if we had a border */
if (siFrame.cx > 0 || siFrame.cy > 0)
{
#if 0 // See the remark above
SetRect(&fRect, rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
FrameRect(hDC, &fRect, GetSysColorBrush(COLOR_WINDOWFRAME));
#endif
InflateRect(&rcWin, (siFrame.cx > 0 ? -1 : 0), (siFrame.cy > 0 ? -1 : 0));
}
/* Draw the console window title bar */
hBrush = GetSysColorBrush(COLOR_BTNFACE);
/* Draw the system menu (left button) */
SetRect(&fRect, rcWin.left, rcWin.top, rcWin.left + siButton.cx, rcWin.top + siButton.cy - 2);
// DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
FillRect(hDC, &fRect, hBrush);
fRect.right++; // Separation
/* Draw the caption bar */
SetRect(&fRect, fRect.right, fRect.top, rcWin.right - 2 * (siButton.cx + 1), fRect.bottom);
FillRect(hDC, &fRect, GetSysColorBrush(COLOR_ACTIVECAPTION));
fRect.right++; // Separation
/* Draw the minimize menu (first right button) */
SetRect(&fRect, fRect.right, fRect.top, fRect.right + siButton.cx, fRect.bottom);
// DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONMIN);
FillRect(hDC, &fRect, hBrush);
fRect.right++; // Separation
/* Draw the maximize menu (second right button) */
SetRect(&fRect, fRect.right, fRect.top, fRect.right + siButton.cx, fRect.bottom);
// DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONMAX);
FillRect(hDC, &fRect, hBrush);
rcWin.top += siButton.cy - 1;
/* Add the scrollbars if needed */
if (siScroll.cy > 0 || siScroll.cx > 0)
{
LONG right, bottom;
right = rcWin.right;
bottom = rcWin.bottom;
/*
* If both the horizontal and vertical scrollbars are present,
* reserve some space for the "dead square" at the bottom right.
*/
if (siScroll.cy > 0 && siScroll.cx > 0)
{
right -= (1 + siScroll.cx);
bottom -= (1 + siScroll.cy);
}
hBrush = GetSysColorBrush(COLOR_SCROLLBAR);
/* Horizontal scrollbar */
if (siScroll.cy > 0)
{
SetRect(&fRect, rcWin.left, rcWin.bottom - siScroll.cy, right, rcWin.bottom);
FillRect(hDC, &fRect, hBrush);
}
/* Vertical scrollbar */
if (siScroll.cx > 0)
{
SetRect(&fRect, rcWin.right - siScroll.cx, rcWin.top, rcWin.right, bottom);
FillRect(hDC, &fRect, hBrush);
}
/*
* If both the horizontal and vertical scrollbars are present,
* draw the "dead square" at the bottom right.
*/
if (siScroll.cy > 0 && siScroll.cx > 0)
{
SetRect(&fRect, rcWin.right - siScroll.cx, rcWin.bottom - siScroll.cy, rcWin.right, rcWin.bottom);
FillRect(hDC, &fRect, hBrush);
}
// NOTE: If an additional exterior frame is needed, remove +1 for each direction
rcWin.right -= siScroll.cx;
rcWin.bottom -= siScroll.cy;
}
/* Draw the console background */
hBrush = CreateSolidBrush(pConInfo->ColorTable[BkgdAttribFromAttrib(pConInfo->ScreenAttributes)]);
FillRect(hDC, &rcWin, hBrush);
DeleteObject(hBrush);
}
static LRESULT CALLBACK
WinPrevProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PWINPREV_DATA pData;
pData = (PWINPREV_DATA)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
switch (msg)
{
case WM_CREATE:
{
pData = (PWINPREV_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pData));
if (!pData)
{
/* We failed to allocate our private data, halt the window creation */
return (LRESULT)-1;
}
pData->hWnd = hWnd;
pData->pData = ConInfo;
GetClientRect(pData->hWnd, &pData->rcMaxArea);
// LPCREATESTRUCT::cx and cy give window (not client) size
WinPrev_OnDisplayChange(pData);
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pData);
break;
}
case WM_DESTROY:
{
if (pData)
HeapFree(GetProcessHeap(), 0, pData);
break;
}
case WM_DISPLAYCHANGE:
{
WinPrev_OnDisplayChange(pData);
UpdateWindow(hWnd);
// InvalidateRect(hWnd, NULL, FALSE);
break;
}
case WM_SIZE:
break;
case WM_ERASEBKGND:
return 1;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
WinPrev_OnDraw(ps.hdc, pData);
EndPaint(hWnd, &ps);
return 0;
}
}
return DefWindowProcW(hWnd, msg, wParam, lParam);
}
/* CONSOLE TEXT PREVIEW *******************************************************/
const WCHAR szPreviewText[] =
L"C:\\ReactOS> dir \n" \
L"SYSTEM <DIR> 13-04-15 5:00a\n" \
@ -22,80 +464,7 @@ const WCHAR szPreviewText[] =
L"setuplog txt 313 13-04-15 5:00a\n" \
L"win ini 7005 13-04-15 5:00a\n" ;
VOID
PaintConsole(
IN LPDRAWITEMSTRUCT drawItem,
IN PCONSOLE_STATE_INFO pConInfo)
{
HBRUSH hBrush;
RECT cRect, fRect;
DWORD startx, starty;
DWORD endx, endy;
DWORD sizex, sizey;
FillRect(drawItem->hDC, &drawItem->rcItem, GetSysColorBrush(COLOR_BACKGROUND));
// FIXME: Use: SM_CXSIZE, SM_CYSIZE, SM_CXVSCROLL, SM_CYHSCROLL, SM_CXMIN, SM_CYMIN, SM_CXFRAME, SM_CYFRAME
/* Use it for scaling */
sizex = drawItem->rcItem.right - drawItem->rcItem.left;
sizey = drawItem->rcItem.bottom - drawItem->rcItem.top ;
if ( pConInfo->WindowPosition.x == MAXDWORD &&
pConInfo->WindowPosition.y == MAXDWORD )
{
startx = sizex / 3;
starty = sizey / 3;
}
else
{
// TODO:
// Calculate pos correctly when console centered
startx = pConInfo->WindowPosition.x;
starty = pConInfo->WindowPosition.y;
}
// TODO:
// Stretch console when bold fonts are selected
endx = startx + pConInfo->WindowSize.X; // drawItem->rcItem.right - startx + 15;
endy = starty + pConInfo->WindowSize.Y; // starty + sizey / 3;
/* Draw console size */
SetRect(&cRect, startx, starty, endx, endy);
FillRect(drawItem->hDC, &cRect, GetSysColorBrush(COLOR_WINDOWFRAME));
/* Draw console border */
SetRect(&fRect, startx + 1, starty + 1, cRect.right - 1, cRect.bottom - 1);
FrameRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER));
/* Draw left box */
SetRect(&fRect, startx + 3, starty + 3, startx + 5, starty + 5);
FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER));
/* Draw window title */
SetRect(&fRect, startx + 7, starty + 3, cRect.right - 9, starty + 5);
FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVECAPTION));
/* Draw first right box */
SetRect(&fRect, fRect.right + 1, starty + 3, fRect.right + 3, starty + 5);
FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER));
/* Draw second right box */
SetRect(&fRect, fRect.right + 1, starty + 3, fRect.right + 3, starty + 5);
FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER));
/* Draw scrollbar */
SetRect(&fRect, cRect.right - 5, fRect.bottom + 1, cRect.right - 3, cRect.bottom - 3);
FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_SCROLLBAR));
/* Draw console background */
hBrush = CreateSolidBrush(pConInfo->ColorTable[BkgdAttribFromAttrib(pConInfo->ScreenAttributes)]);
SetRect(&fRect, startx + 3, starty + 6, cRect.right - 6, cRect.bottom - 3);
FillRect(drawItem->hDC, &fRect, hBrush);
DeleteObject(hBrush);
}
BOOL
PaintText(
IN LPDRAWITEMSTRUCT drawItem,
IN PCONSOLE_STATE_INFO pConInfo,
@ -112,36 +481,39 @@ PaintText(
else if (TextMode == Popup)
CurrentAttrib = pConInfo->PopupAttributes;
else
return FALSE;
return;
nbkColor = pConInfo->ColorTable[BkgdAttribFromAttrib(CurrentAttrib)];
ntColor = pConInfo->ColorTable[TextAttribFromAttrib(CurrentAttrib)];
hBrush = CreateSolidBrush(nbkColor);
if (!hBrush) return FALSE;
if (!hBrush) return;
hOldFont = SelectObject(drawItem->hDC, hCurrentFont);
//if (hOldFont == NULL)
//{
// DeleteObject(hBrush);
// return FALSE;
// return;
//}
FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
ptColor = SetTextColor(drawItem->hDC, ntColor);
/* Add a few space between the preview window border and the text sample */
InflateRect(&drawItem->rcItem, -2, -2);
ptColor = SetTextColor(drawItem->hDC, ntColor);
pbkColor = SetBkColor(drawItem->hDC, nbkColor);
DrawTextW(drawItem->hDC, szPreviewText, wcslen(szPreviewText), &drawItem->rcItem, 0);
DrawTextW(drawItem->hDC, szPreviewText, (INT)wcslen(szPreviewText), &drawItem->rcItem, 0);
SetTextColor(drawItem->hDC, ptColor);
SetBkColor(drawItem->hDC, pbkColor);
SelectObject(drawItem->hDC, hOldFont);
DeleteObject(hBrush);
return TRUE;
}
/* LAYOUT DIALOG **************************************************************/
INT_PTR
CALLBACK
LayoutProc(HWND hDlg,
@ -196,10 +568,12 @@ LayoutProc(HWND hDlg,
return TRUE;
}
case WM_DRAWITEM:
case WM_DISPLAYCHANGE:
{
PaintConsole((LPDRAWITEMSTRUCT)lParam, ConInfo);
return TRUE;
/* Retransmit to the preview window */
SendDlgItemMessageW(hDlg, IDC_STATIC_LAYOUT_WINDOW_PREVIEW,
WM_DISPLAYCHANGE, wParam, lParam);
break;
}
case WM_NOTIFY: