mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
- Add a bit of a hack to paint over the NULL text values in the caption bar. At least they look pretty now until a better fix is found
- load resource strings onto heap to avoid overfows from translations svn path=/trunk/; revision=25309
This commit is contained in:
parent
3f8e525b58
commit
66e877331a
19 changed files with 175 additions and 29 deletions
|
@ -131,4 +131,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -125,4 +125,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -129,4 +129,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -151,4 +151,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -133,4 +133,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -123,4 +123,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -127,4 +127,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -33,6 +33,10 @@ extern HINSTANCE hApplet;
|
|||
PDIBITMAP DibLoadImage(LPTSTR lpFilename);
|
||||
VOID DibFreeImage(PDIBITMAP lpBitmap);
|
||||
|
||||
INT AllocAndLoadString(LPTSTR *lpTarget,
|
||||
HINSTANCE hInst,
|
||||
UINT uID);
|
||||
|
||||
DWORD DbgPrint(PCH Format,...);
|
||||
|
||||
#endif /* __CPL_DESK_H__ */
|
||||
|
|
|
@ -8,7 +8,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
#define REACTOS_STR_INTERNAL_NAME "desk\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "desk.cpl\0"
|
||||
|
||||
#include <reactos/version.rc>
|
||||
//#include <reactos/version.rc>
|
||||
|
||||
IDC_DESK_ICON ICON "resources/applet.ico"
|
||||
IDC_DESK_ICON2 ICON "resources/applet.ico"
|
||||
|
|
|
@ -125,4 +125,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -130,4 +130,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -129,4 +129,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -117,4 +117,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
63
reactos/dll/cpl/desk/misc.c
Normal file
63
reactos/dll/cpl/desk/misc.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include "desk.h"
|
||||
|
||||
static INT
|
||||
LengthOfStrResource(IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
{
|
||||
HRSRC hrSrc;
|
||||
HGLOBAL hRes;
|
||||
LPWSTR lpName, lpStr;
|
||||
|
||||
if (hInst == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* There are always blocks of 16 strings */
|
||||
lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
|
||||
|
||||
/* Find the string table block */
|
||||
if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
|
||||
(hRes = LoadResource(hInst, hrSrc)) &&
|
||||
(lpStr = LockResource(hRes)))
|
||||
{
|
||||
UINT x;
|
||||
|
||||
/* Find the string we're looking for */
|
||||
uID &= 0xF; /* position in the block, same as % 16 */
|
||||
for (x = 0; x < uID; x++)
|
||||
{
|
||||
lpStr += (*lpStr) + 1;
|
||||
}
|
||||
|
||||
/* Found the string */
|
||||
return (int)(*lpStr);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
INT
|
||||
AllocAndLoadString(OUT LPTSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
{
|
||||
INT ln;
|
||||
|
||||
ln = LengthOfStrResource(hInst,
|
||||
uID);
|
||||
if (ln++ > 0)
|
||||
{
|
||||
(*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
|
||||
ln * sizeof(TCHAR));
|
||||
if ((*lpTarget) != NULL)
|
||||
{
|
||||
INT Ret;
|
||||
if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
|
||||
{
|
||||
LocalFree((HLOCAL)(*lpTarget));
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -123,4 +123,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -124,4 +124,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
|
@ -39,6 +39,16 @@ typedef struct _PREVIEW_DATA
|
|||
|
||||
RECT rcDialogButton;
|
||||
|
||||
LPTSTR lpInAct;
|
||||
LPTSTR lpAct;
|
||||
LPTSTR lpWinTxt;
|
||||
LPTSTR lpMessBox;
|
||||
LPTSTR lpMessText;
|
||||
LPTSTR lpButText;
|
||||
LPTSTR lpMenNorm;
|
||||
LPTSTR lpMenDis;
|
||||
LPTSTR lpMenSel;
|
||||
|
||||
LOGFONT CaptionFont;
|
||||
LOGFONT DialogFont;
|
||||
LOGFONT MenuFont;
|
||||
|
@ -46,6 +56,22 @@ typedef struct _PREVIEW_DATA
|
|||
} PREVIEW_DATA, *PPREVIEW_DATA;
|
||||
|
||||
|
||||
/* HACK: fill the caption bar squares due to NULL text */
|
||||
static VOID
|
||||
FillSquare(HDC hdc, PRECT rect)
|
||||
{
|
||||
INT x, y, i;
|
||||
|
||||
x = rect->left + 2;
|
||||
y = rect->top + 2;
|
||||
|
||||
for (i = 3; i < 12; i++)
|
||||
{
|
||||
BitBlt(hdc, x, y + i, 10, 1, hdc, x, y, SRCCOPY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DrawCaptionButtons(HDC hdc, LPRECT lpRect, BOOL bMinMax)
|
||||
{
|
||||
|
@ -176,13 +202,6 @@ PreviewWndProc(HWND hwnd,
|
|||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT rc;
|
||||
static NONCLIENTMETRICS NonClientMetrics;
|
||||
static TCHAR szInAct[32];
|
||||
static TCHAR szAct[32];
|
||||
static TCHAR szWinTxt[32];
|
||||
static TCHAR szMessBox[32];
|
||||
static TCHAR szMessText[32];
|
||||
static TCHAR szButText[4];
|
||||
|
||||
pPreviewData = (PPREVIEW_DATA)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
|
||||
|
@ -190,6 +209,8 @@ PreviewWndProc(HWND hwnd,
|
|||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
NONCLIENTMETRICS NonClientMetrics;
|
||||
|
||||
pPreviewData = (PPREVIEW_DATA)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(PREVIEW_DATA));
|
||||
|
@ -214,12 +235,15 @@ PreviewWndProc(HWND hwnd,
|
|||
pPreviewData->MenuFont = NonClientMetrics.lfMenuFont;
|
||||
pPreviewData->DialogFont = NonClientMetrics.lfMessageFont;
|
||||
|
||||
LoadString(hApplet, IDS_INACTWIN, szInAct, sizeof(szInAct));
|
||||
LoadString(hApplet, IDS_ACTWIN, szAct, sizeof(szAct));
|
||||
LoadString(hApplet, IDS_WINTEXT, szWinTxt, sizeof(szWinTxt));
|
||||
LoadString(hApplet, IDS_MESSBOX, szMessBox, sizeof(szMessBox));
|
||||
LoadString(hApplet, IDS_MESSTEXT, szMessText, sizeof(szMessText));
|
||||
LoadString(hApplet, IDS_BUTTEXT, szButText, sizeof(szButText));
|
||||
AllocAndLoadString(&pPreviewData->lpInAct, hApplet, IDS_INACTWIN);
|
||||
AllocAndLoadString(&pPreviewData->lpAct, hApplet, IDS_ACTWIN);
|
||||
AllocAndLoadString(&pPreviewData->lpWinTxt, hApplet, IDS_WINTEXT);
|
||||
AllocAndLoadString(&pPreviewData->lpMessBox, hApplet, IDS_MESSBOX);
|
||||
AllocAndLoadString(&pPreviewData->lpMessText, hApplet, IDS_MESSTEXT);
|
||||
AllocAndLoadString(&pPreviewData->lpButText, hApplet, IDS_BUTTEXT);
|
||||
AllocAndLoadString(&pPreviewData->lpMenNorm, hApplet, IDS_NORMAL);
|
||||
AllocAndLoadString(&pPreviewData->lpMenDis, hApplet, IDS_DISABLED);
|
||||
AllocAndLoadString(&pPreviewData->lpMenSel, hApplet, IDS_SELECTED);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -241,25 +265,26 @@ PreviewWndProc(HWND hwnd,
|
|||
DrawEdge(hdc, &pPreviewData->rcInactiveFrame, EDGE_RAISED, BF_RECT | BF_MIDDLE);
|
||||
DrawCaption(hwnd, hdc, &pPreviewData->rcInactiveCaption, DC_GRADIENT | DC_TEXT);
|
||||
DrawCaptionButtons(hdc, &pPreviewData->rcInactiveCaption, TRUE);
|
||||
CopyMemory(&tmpRc, &pPreviewData->rcInactiveCaption, sizeof(RECT));
|
||||
FillSquare(hdc, &pPreviewData->rcInactiveCaption);
|
||||
CopyRect(&tmpRc, &pPreviewData->rcInactiveCaption);
|
||||
tmpRc.left += 4;
|
||||
tmpRc.top += 2;
|
||||
SelectObject(hdc, CreateFontIndirect(&pPreviewData->CaptionFont));
|
||||
SetTextColor(hdc, RGB(212,208,200));
|
||||
DrawText(hdc, szInAct, lstrlen(szInAct), &tmpRc, DT_LEFT);
|
||||
DrawText(hdc, pPreviewData->lpInAct, lstrlen(pPreviewData->lpInAct), &tmpRc, DT_LEFT);
|
||||
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
|
||||
|
||||
|
||||
/* Active Window */
|
||||
DrawEdge(hdc, &pPreviewData->rcActiveFrame, EDGE_RAISED, BF_RECT | BF_MIDDLE);
|
||||
DrawCaption(hwnd, hdc, &pPreviewData->rcActiveCaption, DC_ACTIVE | DC_GRADIENT | DC_TEXT);
|
||||
DrawCaptionButtons(hdc, &pPreviewData->rcActiveCaption, TRUE);
|
||||
CopyMemory(&tmpRc, &pPreviewData->rcActiveCaption, sizeof(RECT));
|
||||
FillSquare(hdc, &pPreviewData->rcActiveCaption);
|
||||
CopyRect(&tmpRc, &pPreviewData->rcActiveCaption);
|
||||
tmpRc.left += 4;
|
||||
tmpRc.top += 2;
|
||||
SetTextColor(hdc, RGB(255,255,255)); // FIXME: don't hardcode colors
|
||||
SelectObject(hdc, CreateFontIndirect(&pPreviewData->CaptionFont));
|
||||
DrawText(hdc, szAct, lstrlen(szAct), &tmpRc, DT_LEFT);
|
||||
DrawText(hdc, pPreviewData->lpAct, lstrlen(pPreviewData->lpAct), &tmpRc, DT_LEFT);
|
||||
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
|
||||
|
||||
/* FIXME: Draw the menu bar */
|
||||
|
@ -268,48 +293,47 @@ PreviewWndProc(HWND hwnd,
|
|||
FillRect(hdc, &rc, pPreviewData->hbrWindow);
|
||||
|
||||
/* Draw the client text */
|
||||
CopyMemory(&tmpRc, &pPreviewData->rcActiveClient, sizeof(RECT));
|
||||
CopyRect(&tmpRc, &pPreviewData->rcActiveClient);
|
||||
tmpRc.left += 4;
|
||||
tmpRc.top += 2;
|
||||
SetTextColor(hdc, RGB(0,0,0));
|
||||
SelectObject(hdc, CreateFontIndirect(&pPreviewData->DialogFont));
|
||||
DrawText(hdc, szWinTxt, lstrlen(szWinTxt), &tmpRc, DT_LEFT);
|
||||
DrawText(hdc, pPreviewData->lpWinTxt, lstrlen(pPreviewData->lpWinTxt), &tmpRc, DT_LEFT);
|
||||
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
|
||||
|
||||
/* Draw the scroll bar */
|
||||
DrawScrollbar(hdc, &pPreviewData->rcActiveScroll);
|
||||
|
||||
|
||||
/* Dialog Window */
|
||||
DrawEdge(hdc, &pPreviewData->rcDialogFrame, EDGE_RAISED, BF_RECT | BF_MIDDLE);
|
||||
DrawCaption(hwnd, hdc, &pPreviewData->rcDialogCaption, DC_ACTIVE | DC_GRADIENT | DC_TEXT);
|
||||
DrawCaptionButtons(hdc, &pPreviewData->rcDialogCaption, FALSE);
|
||||
CopyMemory(&tmpRc, &pPreviewData->rcDialogCaption, sizeof(RECT));
|
||||
FillSquare(hdc, &pPreviewData->rcDialogCaption);
|
||||
CopyRect(&tmpRc, &pPreviewData->rcDialogCaption);
|
||||
tmpRc.left += 4;
|
||||
tmpRc.top += 2;
|
||||
SetTextColor(hdc, RGB(255,255,255));
|
||||
SelectObject(hdc, CreateFontIndirect(&pPreviewData->CaptionFont));
|
||||
DrawText(hdc, szMessBox, lstrlen(szMessBox), &tmpRc, DT_LEFT);
|
||||
DrawText(hdc, pPreviewData->lpMessBox, lstrlen(pPreviewData->lpMessBox), &tmpRc, DT_LEFT);
|
||||
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
|
||||
|
||||
/* draw the dialog text */
|
||||
CopyMemory(&tmpRc, &pPreviewData->rcDialogClient, sizeof(RECT));
|
||||
CopyRect(&tmpRc, &pPreviewData->rcDialogClient);
|
||||
tmpRc.left += 4;
|
||||
tmpRc.top += 2;
|
||||
SetTextColor(hdc, RGB(0,0,0));
|
||||
SelectObject(hdc, CreateFontIndirect(&pPreviewData->DialogFont));
|
||||
DrawText(hdc, szMessText, lstrlen(szMessText), &tmpRc, DT_LEFT);
|
||||
DrawText(hdc, pPreviewData->lpMessText, lstrlen(pPreviewData->lpMessText), &tmpRc, DT_LEFT);
|
||||
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
|
||||
|
||||
/* Draw Button */
|
||||
DrawFrameControl(hdc, &pPreviewData->rcDialogButton, DFC_BUTTON, DFCS_BUTTONPUSH);
|
||||
CopyMemory(&tmpRc, &pPreviewData->rcDialogButton, sizeof(RECT));
|
||||
CopyRect(&tmpRc, &pPreviewData->rcDialogButton);
|
||||
tmpRc.top += 6;
|
||||
SelectObject(hdc, CreateFontIndirect(&pPreviewData->DialogFont));
|
||||
DrawText(hdc, szButText, lstrlen(szButText), &tmpRc, DT_CENTER);
|
||||
DrawText(hdc, pPreviewData->lpButText, lstrlen(pPreviewData->lpButText), &tmpRc, DT_CENTER);
|
||||
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
|
||||
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
break;
|
||||
}
|
||||
|
@ -318,6 +342,16 @@ PreviewWndProc(HWND hwnd,
|
|||
DeleteObject(pPreviewData->hbrDesktop);
|
||||
DeleteObject(pPreviewData->hbrWindow);
|
||||
|
||||
LocalFree((HLOCAL)pPreviewData->lpInAct);
|
||||
LocalFree((HLOCAL)pPreviewData->lpAct);
|
||||
LocalFree((HLOCAL)pPreviewData->lpWinTxt);
|
||||
LocalFree((HLOCAL)pPreviewData->lpMessBox);
|
||||
LocalFree((HLOCAL)pPreviewData->lpMessText);
|
||||
LocalFree((HLOCAL)pPreviewData->lpButText);
|
||||
LocalFree((HLOCAL)pPreviewData->lpMenNorm);
|
||||
LocalFree((HLOCAL)pPreviewData->lpMenDis);
|
||||
LocalFree((HLOCAL)pPreviewData->lpMenSel);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pPreviewData);
|
||||
break;
|
||||
|
||||
|
|
|
@ -88,6 +88,9 @@
|
|||
#define IDS_MESSBOX 1513
|
||||
#define IDS_MESSTEXT 1514
|
||||
#define IDS_BUTTEXT 1515
|
||||
#define IDS_NORMAL 1516
|
||||
#define IDS_DISABLED 1517
|
||||
#define IDS_SELECTED 1518
|
||||
|
||||
|
||||
#endif /* __CPL_DESK_RESOURCE_H__ */
|
||||
|
|
|
@ -126,4 +126,7 @@ BEGIN
|
|||
IDS_MESSBOX "Message Box"
|
||||
IDS_MESSTEXT "Message Text"
|
||||
IDS_BUTTEXT "OK"
|
||||
IDS_NORMAL "Normal"
|
||||
IDS_DISABLED "Disabled"
|
||||
IDS_SELECTED "Selected"
|
||||
END
|
||||
|
|
Loading…
Reference in a new issue