[IMAGESOFT] Use ARRAYSIZE / un-hardcode some sizeof(TYPE) where applicable.

This commit is contained in:
Hermès Bélusca-Maïto 2021-09-26 02:38:37 +02:00
parent 67fd29cae0
commit 516c8829ea
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
11 changed files with 27 additions and 28 deletions

View file

@ -32,7 +32,7 @@ AboutDialogProc(HWND hDlg,
LoadString(hInstance,
IDS_LICENSE,
strLicense,
sizeof(strLicense) / sizeof(TCHAR));
ARRAYSIZE(strLicense));
SetWindowText(hLicenseEditWnd,
strLicense);

View file

@ -15,7 +15,7 @@ DisplayBlackAndWhite(HWND hwnd,
RECT rc;
GetObject(hBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
/* Bitmap header */
@ -112,7 +112,7 @@ DisplayInvertedColors(HWND hwnd,
RECT rc;
GetObject(hBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
/* Bitmap header */
@ -206,7 +206,7 @@ DisplayBlur(HWND hwnd,
RECT rc;
GetObject(hBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
/* Bitmap header */
@ -367,7 +367,7 @@ DisplaySharpness(HWND hwnd,
RECT rc;
GetObject(hBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
/* Bitmap header */

View file

@ -21,7 +21,7 @@ AdjustBrightness(HBITMAP hOrigBitmap,
RECT rc;
GetObject(hNewBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
/* Bitmap header */

View file

@ -21,7 +21,7 @@ AdjustContrast(HBITMAP hOrigBitmap,
RECT rc;
GetObject(hNewBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
/* Bitmap header */

View file

@ -58,8 +58,7 @@ FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info)
HIMAGELIST hImageList;
UINT NumButtons;
NumButtons = sizeof(ToolsButtons) / sizeof(ToolsButtons[0]);
NumButtons = ARRAYSIZE(ToolsButtons);
hTb = CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL,
@ -293,7 +292,7 @@ FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info)
if (hList == NULL)
return FALSE;
NumButtons = sizeof(HistoryButtons) / sizeof(HistoryButtons[0]);
NumButtons = ARRAYSIZE(HistoryButtons);
hButtons = CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL,
@ -603,7 +602,7 @@ InitFloatWndClass(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = FloatToolbarWndProc;
wc.hInstance = hInstance;

View file

@ -16,7 +16,7 @@ EnumFontSizes(ENUMLOGFONTEX *lpelfe,
if (fTrueType)
{
for (i = 0; i < (sizeof(ttsizes) / sizeof(ttsizes[0])); i++)
for (i = 0; i < ARRAYSIZE(ttsizes); i++)
{
wsprintf(ach, _T("%d"), ttsizes[i]);

View file

@ -20,7 +20,7 @@ _tWinMain(HINSTANCE hThisInstance,
hInstance = hThisInstance;
ProcessHeap = GetProcessHeap();
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
InitCommonControlsEx(&icex);

View file

@ -65,14 +65,14 @@ LoadDIBImage(PEDIT_WND_INFO Info)
bSuccess = ReadFile(hFile,
&bmfh,
sizeof(BITMAPFILEHEADER),
sizeof(bmfh),
&BytesRead,
NULL);
if (bSuccess && (BytesRead == sizeof(BITMAPFILEHEADER))
if (bSuccess && (BytesRead == sizeof(bmfh))
&& (bmfh.bfType == *(WORD *)"BM"))
{
DWORD InfoSize = bmfh.bfOffBits - sizeof(BITMAPFILEHEADER);
DWORD InfoSize = bmfh.bfOffBits - sizeof(bmfh);
Info->pbmi = HeapAlloc(ProcessHeap,
0,
@ -102,7 +102,7 @@ LoadDIBImage(PEDIT_WND_INFO Info)
NULL);
GetObject(Info->hBitmap,
sizeof(BITMAP),
sizeof(bitmap),
&bitmap);
Info->Width = bitmap.bmWidth;
@ -514,7 +514,7 @@ InitImageEditWindowImpl(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = ImageEditWndProc;
wc.hInstance = hInstance;

View file

@ -129,7 +129,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
case ID_TOOLBAR_STANDARD:
{
Buttons = StdButtons;
NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]);
NumButtons = ARRAYSIZE(StdButtons);
StartImageRes = IDB_MAINNEWICON;
NumImages = 10;
break;
@ -138,7 +138,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
case ID_TOOLBAR_TEXT:
{
Buttons = TextButtons;
NumButtons = sizeof(TextButtons) / sizeof(TextButtons[0]);
NumButtons = ARRAYSIZE(TextButtons);
StartImageRes = IDB_TEXTBOLD;
NumImages = 6;
break;
@ -493,7 +493,7 @@ MainWndMoveFloatingWindows(PMAIN_WND_INFO Info,
CopyMemory(wndOldPos,
&wndNewPos,
sizeof(RECT));
sizeof(wndOldPos));
}
}
@ -665,7 +665,7 @@ CreateToolbars(PMAIN_WND_INFO Info)
{
UINT i;
for (i = 0; i < sizeof(MainDockBars) / sizeof(MainDockBars[0]); i++)
for (i = 0; i < ARRAYSIZE(MainDockBars); i++)
{
/* FIXME - lookup whether to display the toolbar */
TbdAddToolbar(&Info->ToolDocks,
@ -774,7 +774,7 @@ InitMainWnd(PMAIN_WND_INFO Info)
if (Info->hStatus != NULL)
SendMessage(Info->hStatus,
SB_SETPARTS,
sizeof(statwidths)/sizeof(int),
ARRAYSIZE(statwidths),
(LPARAM)statwidths);
/* create the MDI client window */
@ -1170,13 +1170,13 @@ MainWndProc(HWND hwnd,
if (!MainWndMenuHint(Info,
LOWORD(wParam),
MainMenuHintTable,
sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]),
ARRAYSIZE(MainMenuHintTable),
IDS_HINT_BLANK))
{
MainWndMenuHint(Info,
LOWORD(wParam),
SystemMenuHintTable,
sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]),
ARRAYSIZE(SystemMenuHintTable),
IDS_HINT_BLANK);
}
}
@ -1428,7 +1428,7 @@ InitMainWindowImpl(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbSize = sizeof(wc);
wc.lpfnWndProc = MainWndProc;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance,

View file

@ -8,7 +8,7 @@ static OPENFILENAME ofn;
VOID FileInitialize(HWND hwnd)
{
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.nMaxFile = MAX_PATH;
ofn.nMaxFileTitle = MAX_PATH;

View file

@ -1117,7 +1117,7 @@ TbdInitImpl(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = ToolDockWndProc;
wc.cbWndExtra = TD_EXTRA_BYTES;