2008-05-28 19:52:46 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Picture and Fax Viewer
|
|
|
|
* FILE: dll/win32/shimgvw/shimgvw.c
|
|
|
|
* PURPOSE: shimgvw.dll
|
2018-01-30 19:36:59 +00:00
|
|
|
* PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
|
|
|
|
* Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
2008-05-28 19:52:46 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#define _INC_WINDOWS
|
|
|
|
#define COM_NO_WINDOWS_H
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winnls.h>
|
|
|
|
#include <winreg.h>
|
|
|
|
#include <wingdi.h>
|
2018-01-30 19:36:59 +00:00
|
|
|
#include <windowsx.h>
|
2013-01-24 23:00:42 +00:00
|
|
|
#include <objbase.h>
|
2008-05-28 19:52:46 +00:00
|
|
|
#include <commctrl.h>
|
2013-12-19 20:29:17 +00:00
|
|
|
#include <commdlg.h>
|
2008-05-28 19:52:46 +00:00
|
|
|
#include <gdiplus.h>
|
|
|
|
#include <tchar.h>
|
2013-12-19 20:29:17 +00:00
|
|
|
#include <strsafe.h>
|
2014-12-11 19:52:47 +00:00
|
|
|
#include <shlwapi.h>
|
2009-01-29 12:30:02 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
2008-05-29 14:30:26 +00:00
|
|
|
#include <debug.h>
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
#include "shimgvw.h"
|
|
|
|
|
|
|
|
|
|
|
|
HINSTANCE hInstance;
|
|
|
|
SHIMGVW_SETTINGS shiSettings;
|
2014-12-11 19:52:47 +00:00
|
|
|
SHIMGVW_FILENODE *currentFile;
|
2009-01-27 17:14:00 +00:00
|
|
|
GpImage *image;
|
|
|
|
WNDPROC PrevProc = NULL;
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
HWND hDispWnd, hToolBar;
|
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
/* zooming */
|
|
|
|
#define MIN_ZOOM 10
|
|
|
|
#define MAX_ZOOM 1600
|
|
|
|
UINT ZoomPercents = 100;
|
|
|
|
static const UINT ZoomSteps[] =
|
|
|
|
{
|
|
|
|
10, 25, 50, 100, 200, 400, 800, 1600
|
|
|
|
};
|
|
|
|
|
|
|
|
static void ZoomInOrOut(BOOL bZoomIn)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
if (bZoomIn) /* zoom in */
|
|
|
|
{
|
|
|
|
/* find next step */
|
|
|
|
for (i = 0; i < ARRAYSIZE(ZoomSteps); ++i)
|
|
|
|
{
|
|
|
|
if (ZoomPercents < ZoomSteps[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == ARRAYSIZE(ZoomSteps))
|
|
|
|
ZoomPercents = MAX_ZOOM;
|
|
|
|
else
|
|
|
|
ZoomPercents = ZoomSteps[i];
|
|
|
|
|
|
|
|
/* update tool bar buttons */
|
|
|
|
SendMessage(hToolBar, TB_ENABLEBUTTON, IDC_ZOOMM, TRUE);
|
|
|
|
if (ZoomPercents >= MAX_ZOOM)
|
|
|
|
SendMessage(hToolBar, TB_ENABLEBUTTON, IDC_ZOOMP, FALSE);
|
|
|
|
else
|
|
|
|
SendMessage(hToolBar, TB_ENABLEBUTTON, IDC_ZOOMP, TRUE);
|
|
|
|
}
|
|
|
|
else /* zoom out */
|
|
|
|
{
|
|
|
|
/* find previous step */
|
|
|
|
for (i = ARRAYSIZE(ZoomSteps); i > 0; )
|
|
|
|
{
|
|
|
|
--i;
|
|
|
|
if (ZoomSteps[i] < ZoomPercents)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < 0)
|
|
|
|
ZoomPercents = MIN_ZOOM;
|
|
|
|
else
|
|
|
|
ZoomPercents = ZoomSteps[i];
|
|
|
|
|
|
|
|
/* update tool bar buttons */
|
|
|
|
SendMessage(hToolBar, TB_ENABLEBUTTON, IDC_ZOOMP, TRUE);
|
|
|
|
if (ZoomPercents <= MIN_ZOOM)
|
|
|
|
SendMessage(hToolBar, TB_ENABLEBUTTON, IDC_ZOOMM, FALSE);
|
|
|
|
else
|
|
|
|
SendMessage(hToolBar, TB_ENABLEBUTTON, IDC_ZOOMM, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* redraw */
|
|
|
|
InvalidateRect(hDispWnd, NULL, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ResetZoom(void)
|
|
|
|
{
|
|
|
|
RECT Rect;
|
|
|
|
UINT ImageWidth, ImageHeight;
|
|
|
|
|
|
|
|
/* get disp window size and image size */
|
|
|
|
GetClientRect(hDispWnd, &Rect);
|
|
|
|
GdipGetImageWidth(image, &ImageWidth);
|
|
|
|
GdipGetImageHeight(image, &ImageHeight);
|
|
|
|
|
|
|
|
/* compare two aspect rates. same as
|
|
|
|
(ImageHeight / ImageWidth < Rect.bottom / Rect.right) in real */
|
|
|
|
if (ImageHeight * Rect.right < Rect.bottom * ImageWidth)
|
|
|
|
{
|
|
|
|
if (Rect.right < ImageWidth)
|
|
|
|
{
|
|
|
|
/* it's large, shrink it */
|
|
|
|
ZoomPercents = (Rect.right * 100) / ImageWidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* it's small. show as original size */
|
|
|
|
ZoomPercents = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Rect.bottom < ImageHeight)
|
|
|
|
{
|
|
|
|
/* it's large, shrink it */
|
|
|
|
ZoomPercents = (Rect.bottom * 100) / ImageHeight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* it's small. show as original size */
|
|
|
|
ZoomPercents = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
/* ToolBar Buttons */
|
|
|
|
static const TBBUTTON Buttons [] =
|
|
|
|
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
|
|
|
{TBICON_PREV, IDC_PREV, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{TBICON_NEXT, IDC_NEXT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
|
|
|
{TBICON_ZOOMP, IDC_ZOOMP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{TBICON_ZOOMM, IDC_ZOOMM, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
|
|
|
{TBICON_ROT1, IDC_ROT1, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{TBICON_ROT2, IDC_ROT2, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
|
|
|
{TBICON_SAVE, IDC_SAVE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
{TBICON_PRINT, IDC_PRINT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
|
|
|
};
|
|
|
|
|
2009-01-27 17:14:00 +00:00
|
|
|
static void pLoadImage(LPWSTR szOpenFileName)
|
|
|
|
{
|
2018-01-30 19:36:59 +00:00
|
|
|
/* check file presence */
|
2009-01-27 17:14:00 +00:00
|
|
|
if (GetFileAttributesW(szOpenFileName) == 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
DPRINT1("File %s not found!\n", szOpenFileName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
/* load now */
|
2009-01-27 17:14:00 +00:00
|
|
|
GdipLoadImageFromFile(szOpenFileName, &image);
|
|
|
|
if (!image)
|
|
|
|
{
|
|
|
|
DPRINT1("GdipLoadImageFromFile() failed\n");
|
2018-01-30 19:36:59 +00:00
|
|
|
return;
|
2009-01-27 17:14:00 +00:00
|
|
|
}
|
2018-01-30 19:36:59 +00:00
|
|
|
|
|
|
|
/* reset zoom */
|
|
|
|
ResetZoom();
|
|
|
|
|
|
|
|
/* redraw */
|
|
|
|
InvalidateRect(hDispWnd, NULL, TRUE);
|
2009-01-27 17:14:00 +00:00
|
|
|
}
|
|
|
|
|
2013-12-19 20:29:17 +00:00
|
|
|
static void pSaveImageAs(HWND hwnd)
|
|
|
|
{
|
|
|
|
OPENFILENAMEW sfn;
|
|
|
|
ImageCodecInfo *codecInfo;
|
|
|
|
WCHAR szSaveFileName[MAX_PATH];
|
2014-12-10 21:27:18 +00:00
|
|
|
WCHAR *szFilterMask;
|
2013-12-19 20:29:17 +00:00
|
|
|
GUID rawFormat;
|
|
|
|
UINT num;
|
|
|
|
UINT size;
|
2018-04-23 09:42:32 +00:00
|
|
|
size_t sizeRemain;
|
2013-12-19 20:29:17 +00:00
|
|
|
UINT j;
|
|
|
|
WCHAR *c;
|
|
|
|
|
|
|
|
GdipGetImageEncodersSize(&num, &size);
|
|
|
|
codecInfo = malloc(size);
|
|
|
|
if (!codecInfo)
|
|
|
|
{
|
|
|
|
DPRINT1("malloc() failed in pSaveImageAs()\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipGetImageEncoders(num, size, codecInfo);
|
|
|
|
GdipGetImageRawFormat(image, &rawFormat);
|
|
|
|
|
2014-12-10 21:27:18 +00:00
|
|
|
sizeRemain = 0;
|
|
|
|
|
|
|
|
for (j = 0; j < num; ++j)
|
|
|
|
{
|
|
|
|
// Every pair needs space for the Description, twice the Extensions, 1 char for the space, 2 for the braces and 2 for the NULL terminators.
|
|
|
|
sizeRemain = sizeRemain + (((wcslen(codecInfo[j].FormatDescription) + (wcslen(codecInfo[j].FilenameExtension) * 2) + 5) * sizeof(WCHAR)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add two more chars for the last terminator */
|
|
|
|
sizeRemain = sizeRemain + (sizeof(WCHAR) * 2);
|
|
|
|
|
|
|
|
szFilterMask = malloc(sizeRemain);
|
|
|
|
if (!szFilterMask)
|
|
|
|
{
|
|
|
|
DPRINT1("cannot allocate memory for filter mask in pSaveImageAs()");
|
|
|
|
free(codecInfo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
|
|
|
|
ZeroMemory(szFilterMask, sizeRemain);
|
|
|
|
ZeroMemory(&sfn, sizeof(sfn));
|
|
|
|
sfn.lStructSize = sizeof(sfn);
|
|
|
|
sfn.hwndOwner = hwnd;
|
|
|
|
sfn.hInstance = hInstance;
|
|
|
|
sfn.lpstrFile = szSaveFileName;
|
|
|
|
sfn.lpstrFilter = szFilterMask;
|
|
|
|
sfn.nMaxFile = MAX_PATH;
|
|
|
|
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
|
|
|
|
2013-12-19 20:29:17 +00:00
|
|
|
c = szFilterMask;
|
|
|
|
|
|
|
|
for (j = 0; j < num; ++j)
|
|
|
|
{
|
|
|
|
StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", codecInfo[j].FormatDescription, codecInfo[j].FilenameExtension);
|
|
|
|
|
|
|
|
/* Skip the NULL character */
|
|
|
|
c++;
|
|
|
|
sizeRemain -= sizeof(*c);
|
|
|
|
|
|
|
|
StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", codecInfo[j].FilenameExtension);
|
|
|
|
|
|
|
|
/* Skip the NULL character */
|
|
|
|
c++;
|
|
|
|
sizeRemain -= sizeof(*c);
|
|
|
|
|
2017-10-01 14:42:04 +00:00
|
|
|
if (IsEqualGUID(&rawFormat, &codecInfo[j].FormatID) != FALSE)
|
2013-12-19 20:29:17 +00:00
|
|
|
{
|
|
|
|
sfn.nFilterIndex = j + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetSaveFileNameW(&sfn))
|
|
|
|
{
|
|
|
|
if (GdipSaveImageToFile(image, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
|
|
|
|
{
|
|
|
|
DPRINT1("GdipSaveImageToFile() failed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-10 21:27:18 +00:00
|
|
|
free(szFilterMask);
|
2013-12-19 20:29:17 +00:00
|
|
|
free(codecInfo);
|
|
|
|
}
|
|
|
|
|
2014-12-11 19:52:47 +00:00
|
|
|
static VOID
|
|
|
|
pLoadImageFromNode(SHIMGVW_FILENODE *node, HWND hwnd)
|
|
|
|
{
|
|
|
|
WCHAR szTitleBuf[800];
|
|
|
|
WCHAR szResStr[512];
|
|
|
|
WCHAR *c;
|
|
|
|
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
c = wcsrchr(node->FileName, '\\');
|
|
|
|
if (c)
|
|
|
|
{
|
|
|
|
c++;
|
|
|
|
}
|
2015-03-06 20:32:38 +00:00
|
|
|
|
|
|
|
LoadStringW(hInstance, IDS_APPTITLE, szResStr, ARRAYSIZE(szResStr));
|
|
|
|
StringCbPrintfW(szTitleBuf, sizeof(szTitleBuf), L"%ls%ls%ls", szResStr, L" - ", c);
|
2014-12-11 19:52:47 +00:00
|
|
|
SetWindowTextW(hwnd, szTitleBuf);
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
{
|
|
|
|
GdipDisposeImage(image);
|
|
|
|
}
|
|
|
|
|
|
|
|
pLoadImage(node->FileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static SHIMGVW_FILENODE*
|
|
|
|
pBuildFileList(LPWSTR szFirstFile)
|
|
|
|
{
|
|
|
|
HANDLE hFindHandle;
|
|
|
|
WCHAR *extension;
|
|
|
|
WCHAR szSearchPath[MAX_PATH];
|
|
|
|
WCHAR szSearchMask[MAX_PATH];
|
|
|
|
WCHAR szFileTypes[MAX_PATH];
|
|
|
|
WIN32_FIND_DATAW findData;
|
2015-03-06 20:32:38 +00:00
|
|
|
SHIMGVW_FILENODE *currentNode = NULL;
|
|
|
|
SHIMGVW_FILENODE *root = NULL;
|
|
|
|
SHIMGVW_FILENODE *conductor = NULL;
|
2014-12-11 19:52:47 +00:00
|
|
|
ImageCodecInfo *codecInfo;
|
|
|
|
UINT num;
|
|
|
|
UINT size;
|
|
|
|
UINT j;
|
|
|
|
|
2015-03-06 20:32:38 +00:00
|
|
|
StringCbCopyW(szSearchPath, sizeof(szSearchPath), szFirstFile);
|
2014-12-11 19:52:47 +00:00
|
|
|
PathRemoveFileSpecW(szSearchPath);
|
|
|
|
|
|
|
|
GdipGetImageDecodersSize(&num, &size);
|
|
|
|
codecInfo = malloc(size);
|
|
|
|
if (!codecInfo)
|
|
|
|
{
|
|
|
|
DPRINT1("malloc() failed in pLoadFileList()\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipGetImageDecoders(num, size, codecInfo);
|
|
|
|
|
|
|
|
root = malloc(sizeof(SHIMGVW_FILENODE));
|
|
|
|
if (!root)
|
|
|
|
{
|
|
|
|
DPRINT1("malloc() failed in pLoadFileList()\n");
|
|
|
|
free(codecInfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
conductor = root;
|
|
|
|
|
|
|
|
for (j = 0; j < num; ++j)
|
|
|
|
{
|
2015-03-06 20:32:38 +00:00
|
|
|
StringCbCopyW(szFileTypes, sizeof(szFileTypes), codecInfo[j].FilenameExtension);
|
|
|
|
|
2014-12-11 19:52:47 +00:00
|
|
|
extension = wcstok(szFileTypes, L";");
|
|
|
|
while (extension != NULL)
|
|
|
|
{
|
2015-03-06 20:32:38 +00:00
|
|
|
PathCombineW(szSearchMask, szSearchPath, extension);
|
2014-12-11 19:52:47 +00:00
|
|
|
|
|
|
|
hFindHandle = FindFirstFileW(szSearchMask, &findData);
|
|
|
|
if (hFindHandle != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2015-03-06 20:32:38 +00:00
|
|
|
PathCombineW(conductor->FileName, szSearchPath, findData.cFileName);
|
2014-12-11 19:52:47 +00:00
|
|
|
|
|
|
|
// compare the name of the requested file with the one currently found.
|
|
|
|
// if the name matches, the current node is returned by the function.
|
|
|
|
if (wcscmp(szFirstFile, conductor->FileName) == 0)
|
|
|
|
{
|
|
|
|
currentNode = conductor;
|
|
|
|
}
|
|
|
|
|
|
|
|
conductor->Next = malloc(sizeof(SHIMGVW_FILENODE));
|
|
|
|
|
|
|
|
// if malloc fails, make circular what we have and return it
|
|
|
|
if (!conductor->Next)
|
|
|
|
{
|
|
|
|
DPRINT1("malloc() failed in pLoadFileList()\n");
|
2015-03-06 20:32:38 +00:00
|
|
|
|
2014-12-11 19:52:47 +00:00
|
|
|
conductor->Next = root;
|
|
|
|
root->Prev = conductor;
|
|
|
|
|
|
|
|
FindClose(hFindHandle);
|
|
|
|
free(codecInfo);
|
|
|
|
return conductor;
|
|
|
|
}
|
|
|
|
|
|
|
|
conductor->Next->Prev = conductor;
|
|
|
|
conductor = conductor->Next;
|
|
|
|
}
|
|
|
|
while (FindNextFileW(hFindHandle, &findData) != 0);
|
|
|
|
|
|
|
|
FindClose(hFindHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
extension = wcstok(NULL, L";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// we now have a node too much in the list. In case the requested file was not found,
|
|
|
|
// we use this node to store the name of it, otherwise we free it.
|
|
|
|
if (currentNode == NULL)
|
|
|
|
{
|
2015-03-06 20:32:38 +00:00
|
|
|
StringCchCopyW(conductor->FileName, MAX_PATH, szFirstFile);
|
2014-12-11 19:52:47 +00:00
|
|
|
currentNode = conductor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
conductor = conductor->Prev;
|
|
|
|
free(conductor->Next);
|
|
|
|
}
|
|
|
|
|
|
|
|
// link the last node with the first one to make the list circular
|
|
|
|
conductor->Next = root;
|
|
|
|
root->Prev = conductor;
|
|
|
|
conductor = currentNode;
|
|
|
|
|
|
|
|
free(codecInfo);
|
|
|
|
|
|
|
|
return conductor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
pFreeFileList(SHIMGVW_FILENODE *root)
|
|
|
|
{
|
|
|
|
SHIMGVW_FILENODE *conductor;
|
|
|
|
|
|
|
|
root->Prev->Next = NULL;
|
|
|
|
root->Prev = NULL;
|
|
|
|
|
|
|
|
while (root)
|
|
|
|
{
|
|
|
|
conductor = root;
|
|
|
|
root = conductor->Next;
|
|
|
|
free(conductor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 20:01:52 +00:00
|
|
|
static VOID
|
|
|
|
ImageView_UpdateWindow(HWND hwnd)
|
|
|
|
{
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
UpdateWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
static VOID
|
|
|
|
ImageView_DrawImage(HWND hwnd)
|
|
|
|
{
|
|
|
|
GpGraphics *graphics;
|
2018-01-30 19:36:59 +00:00
|
|
|
UINT ImageWidth, ImageHeight;
|
|
|
|
INT ZoomedWidth, ZoomedHeight, x, y;
|
2008-05-28 19:52:46 +00:00
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT rect;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
hdc = BeginPaint(hwnd, &ps);
|
2008-05-29 14:30:26 +00:00
|
|
|
if (!hdc)
|
|
|
|
{
|
|
|
|
DPRINT1("BeginPaint() failed\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
GdipCreateFromHDC(hdc, &graphics);
|
2008-05-29 14:30:26 +00:00
|
|
|
if (!graphics)
|
|
|
|
{
|
|
|
|
DPRINT1("GdipCreateFromHDC() failed\n");
|
|
|
|
return;
|
|
|
|
}
|
2013-12-19 20:29:17 +00:00
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
GdipGetImageWidth(image, &ImageWidth);
|
|
|
|
GdipGetImageHeight(image, &ImageHeight);
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
if (GetClientRect(hwnd, &rect))
|
|
|
|
{
|
2009-01-27 17:14:00 +00:00
|
|
|
FillRect(hdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
2008-05-28 19:52:46 +00:00
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
ZoomedWidth = (ImageWidth * ZoomPercents) / 100;
|
|
|
|
ZoomedHeight = (ImageHeight * ZoomPercents) / 100;
|
|
|
|
|
|
|
|
x = (rect.right - ZoomedWidth) / 2;
|
|
|
|
y = (rect.bottom - ZoomedHeight) / 2;
|
|
|
|
|
|
|
|
DPRINT("x = %d, y = %d, ImageWidth = %u, ImageHeight = %u\n");
|
|
|
|
DPRINT("rect.right = %ld, rect.bottom = %ld\n", rect.right, rect.bottom);
|
|
|
|
DPRINT("ZoomPercents = %d, ZoomedWidth = %d, ZoomedHeight = %d\n",
|
|
|
|
ZoomPercents, ZoomedWidth, ZoomedWidth);
|
|
|
|
|
|
|
|
if (ZoomPercents % 100 == 0)
|
2008-05-28 19:52:46 +00:00
|
|
|
{
|
2018-01-30 19:36:59 +00:00
|
|
|
GdipSetInterpolationMode(graphics, InterpolationModeNearestNeighbor);
|
|
|
|
GdipSetSmoothingMode(graphics, SmoothingModeNone);
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
2014-12-11 19:57:03 +00:00
|
|
|
else
|
2008-05-28 19:52:46 +00:00
|
|
|
{
|
2018-01-30 19:36:59 +00:00
|
|
|
GdipSetInterpolationMode(graphics, InterpolationModeHighQualityBilinear);
|
|
|
|
GdipSetSmoothingMode(graphics, SmoothingModeHighQuality);
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
Rectangle(hdc, x - 1, y - 1, x + ZoomedWidth + 1, y + ZoomedHeight + 1);
|
|
|
|
GdipDrawImageRectI(graphics, image, x, y, ZoomedWidth, ZoomedHeight);
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
2009-01-27 17:14:00 +00:00
|
|
|
GdipDeleteGraphics(graphics);
|
2008-05-28 19:52:46 +00:00
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
ImageView_LoadSettings()
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD dwSize;
|
|
|
|
|
|
|
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
dwSize = sizeof(SHIMGVW_SETTINGS);
|
|
|
|
if (RegQueryValueEx(hKey, _T("Settings"), NULL, NULL, (LPBYTE)&shiSettings, &dwSize) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
ImageView_SaveSettings(HWND hwnd)
|
|
|
|
{
|
|
|
|
WINDOWPLACEMENT wp;
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
wp.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
GetWindowPlacement(hwnd, &wp);
|
|
|
|
|
|
|
|
shiSettings.Left = wp.rcNormalPosition.left;
|
|
|
|
shiSettings.Top = wp.rcNormalPosition.top;
|
|
|
|
shiSettings.Right = wp.rcNormalPosition.right;
|
|
|
|
shiSettings.Bottom = wp.rcNormalPosition.bottom;
|
|
|
|
shiSettings.Maximized = (IsZoomed(hwnd) || (wp.flags & WPF_RESTORETOMAXIMIZED));
|
|
|
|
|
|
|
|
if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegSetValueEx(hKey, _T("Settings"), 0, REG_BINARY, (LPBYTE)&shiSettings, sizeof(SHIMGVW_SETTINGS));
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
ImageView_CreateToolBar(HWND hwnd)
|
|
|
|
{
|
|
|
|
INT numButtons = sizeof(Buttons) / sizeof(Buttons[0]);
|
|
|
|
|
|
|
|
hToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
|
|
|
|
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | CCS_BOTTOM | TBSTYLE_TOOLTIPS,
|
|
|
|
0, 0, 0, 0, hwnd,
|
|
|
|
0, hInstance, NULL);
|
|
|
|
if(hToolBar != NULL)
|
|
|
|
{
|
|
|
|
HIMAGELIST hImageList;
|
|
|
|
|
|
|
|
SendMessage(hToolBar, TB_SETEXTENDEDSTYLE,
|
|
|
|
0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
|
|
|
|
|
|
|
|
SendMessage(hToolBar, TB_BUTTONSTRUCTSIZE,
|
|
|
|
sizeof(Buttons[0]), 0);
|
|
|
|
|
|
|
|
hImageList = ImageList_Create(TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, ILC_MASK | ILC_COLOR24, 1, 1);
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_PREVICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_NEXTICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ZOOMPICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ZOOMMICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_SAVEICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_PRINTICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ROT1ICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ROT2ICON), IMAGE_BITMAP,
|
|
|
|
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
|
|
|
|
|
|
|
|
if (hImageList == NULL) return FALSE;
|
|
|
|
|
|
|
|
ImageList_Destroy((HIMAGELIST)SendMessage(hToolBar, TB_SETIMAGELIST,
|
|
|
|
0, (LPARAM)hImageList));
|
|
|
|
|
|
|
|
SendMessage(hToolBar, TB_ADDBUTTONS,
|
|
|
|
numButtons, (LPARAM)Buttons);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-27 17:14:00 +00:00
|
|
|
LRESULT CALLBACK
|
|
|
|
ImageView_DispWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (Message)
|
|
|
|
{
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
ImageView_DrawImage(hwnd);
|
|
|
|
return 0L;
|
|
|
|
}
|
2015-03-06 20:32:38 +00:00
|
|
|
}
|
2009-01-27 17:14:00 +00:00
|
|
|
return CallWindowProc(PrevProc, hwnd, Message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
static VOID
|
|
|
|
ImageView_InitControls(HWND hwnd)
|
|
|
|
{
|
|
|
|
MoveWindow(hwnd, shiSettings.Left, shiSettings.Top,
|
|
|
|
shiSettings.Right - shiSettings.Left,
|
|
|
|
shiSettings.Bottom - shiSettings.Top, TRUE);
|
|
|
|
|
|
|
|
if (shiSettings.Maximized) ShowWindow(hwnd, SW_MAXIMIZE);
|
|
|
|
|
2015-08-10 10:23:55 +00:00
|
|
|
hDispWnd = CreateWindowEx(0, WC_STATIC, _T(""),
|
2008-05-28 19:52:46 +00:00
|
|
|
WS_CHILD | WS_VISIBLE,
|
|
|
|
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
|
|
|
|
|
2009-05-09 10:11:04 +00:00
|
|
|
SetClassLongPtr(hDispWnd, GCL_STYLE, CS_HREDRAW | CS_VREDRAW);
|
2018-02-05 01:42:14 +00:00
|
|
|
PrevProc = (WNDPROC) SetWindowLongPtr(hDispWnd, GWLP_WNDPROC, (LPARAM) ImageView_DispWndProc);
|
2009-01-27 17:14:00 +00:00
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
ImageView_CreateToolBar(hwnd);
|
|
|
|
}
|
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
static VOID
|
|
|
|
ImageView_OnMouseWheel(HWND hwnd, INT x, INT y, INT zDelta, UINT fwKeys)
|
|
|
|
{
|
|
|
|
if (zDelta != 0)
|
|
|
|
{
|
|
|
|
ZoomInOrOut(zDelta > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
LRESULT CALLBACK
|
|
|
|
ImageView_WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (Message)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
ImageView_InitControls(hwnd);
|
2009-01-27 17:14:00 +00:00
|
|
|
return 0L;
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
2015-08-10 10:23:55 +00:00
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case VK_LEFT:
|
|
|
|
PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_PREV, BN_CLICKED), (LPARAM)NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_RIGHT:
|
|
|
|
PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_NEXT, BN_CLICKED), (LPARAM)NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case IDC_PREV:
|
2014-12-11 19:52:47 +00:00
|
|
|
{
|
|
|
|
currentFile = currentFile->Prev;
|
|
|
|
pLoadImageFromNode(currentFile, hwnd);
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case IDC_NEXT:
|
2014-12-11 19:52:47 +00:00
|
|
|
{
|
|
|
|
currentFile = currentFile->Next;
|
|
|
|
pLoadImageFromNode(currentFile, hwnd);
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case IDC_ZOOMP:
|
2018-01-30 19:36:59 +00:00
|
|
|
{
|
|
|
|
ZoomInOrOut(TRUE);
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
break;
|
|
|
|
case IDC_ZOOMM:
|
2018-01-30 19:36:59 +00:00
|
|
|
{
|
|
|
|
ZoomInOrOut(FALSE);
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
break;
|
|
|
|
case IDC_SAVE:
|
2013-12-19 20:29:17 +00:00
|
|
|
pSaveImageAs(hwnd);
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case IDC_PRINT:
|
|
|
|
|
|
|
|
break;
|
|
|
|
case IDC_ROT1:
|
2014-12-11 20:01:52 +00:00
|
|
|
{
|
|
|
|
GdipImageRotateFlip(image, Rotate270FlipNone);
|
|
|
|
ImageView_UpdateWindow(hwnd);
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case IDC_ROT2:
|
2014-12-11 20:01:52 +00:00
|
|
|
{
|
|
|
|
GdipImageRotateFlip(image, Rotate90FlipNone);
|
|
|
|
ImageView_UpdateWindow(hwnd);
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-01-30 19:36:59 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
ImageView_OnMouseWheel(hwnd,
|
|
|
|
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
|
|
|
|
(SHORT)HIWORD(wParam), (UINT)LOWORD(wParam));
|
|
|
|
break;
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR pnmhdr = (LPNMHDR)lParam;
|
|
|
|
|
|
|
|
switch (pnmhdr->code)
|
|
|
|
{
|
|
|
|
case TTN_GETDISPINFO:
|
|
|
|
{
|
|
|
|
LPTOOLTIPTEXT lpttt;
|
|
|
|
UINT idButton;
|
|
|
|
|
|
|
|
lpttt = (LPTOOLTIPTEXT)lParam;
|
|
|
|
idButton = (UINT)lpttt->hdr.idFrom;
|
2014-12-11 18:11:08 +00:00
|
|
|
lpttt->hinst = hInstance;
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
switch (idButton)
|
|
|
|
{
|
|
|
|
case IDC_PREV:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PREV_PIC);
|
|
|
|
break;
|
|
|
|
case IDC_NEXT:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEXT_PIC);
|
|
|
|
break;
|
|
|
|
case IDC_ZOOMP:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ZOOM_IN);
|
|
|
|
break;
|
|
|
|
case IDC_ZOOMM:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ZOOM_OUT);
|
|
|
|
break;
|
|
|
|
case IDC_SAVE:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SAVEAS);
|
|
|
|
break;
|
|
|
|
case IDC_PRINT:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINT);
|
|
|
|
break;
|
|
|
|
case IDC_ROT1:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ROT_COUNCW);
|
|
|
|
break;
|
|
|
|
case IDC_ROT2:
|
|
|
|
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ROT_CLOCKW);
|
|
|
|
break;
|
|
|
|
}
|
2009-01-28 12:28:11 +00:00
|
|
|
return TRUE;
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-28 12:28:11 +00:00
|
|
|
break;
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
case WM_SIZING:
|
|
|
|
{
|
|
|
|
LPRECT pRect = (LPRECT)lParam;
|
|
|
|
if (pRect->right-pRect->left < 350)
|
|
|
|
pRect->right = pRect->left + 350;
|
|
|
|
|
|
|
|
if (pRect->bottom-pRect->top < 290)
|
|
|
|
pRect->bottom = pRect->top + 290;
|
2009-01-27 17:14:00 +00:00
|
|
|
return TRUE;
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
case WM_SIZE:
|
|
|
|
{
|
2009-01-28 12:28:11 +00:00
|
|
|
RECT rc;
|
2008-05-28 19:52:46 +00:00
|
|
|
SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
|
2014-12-12 21:15:17 +00:00
|
|
|
GetWindowRect(hToolBar, &rc);
|
|
|
|
MoveWindow(hDispWnd, 1, 1, LOWORD(lParam) - 1, HIWORD(lParam) - (rc.bottom - rc.top) - 1, TRUE);
|
2018-01-30 19:36:59 +00:00
|
|
|
/* is it maximized or restored? */
|
|
|
|
if (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED)
|
|
|
|
{
|
|
|
|
/* reset zoom */
|
|
|
|
ResetZoom();
|
|
|
|
}
|
2009-01-27 17:14:00 +00:00
|
|
|
return 0L;
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
case WM_DESTROY:
|
|
|
|
{
|
|
|
|
ImageView_SaveSettings(hwnd);
|
2018-02-05 01:42:14 +00:00
|
|
|
SetWindowLongPtr(hDispWnd, GWLP_WNDPROC, (LPARAM) PrevProc);
|
2008-05-28 19:52:46 +00:00
|
|
|
PostQuitMessage(0);
|
2009-01-27 17:14:00 +00:00
|
|
|
break;
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hwnd, Message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
LONG WINAPI
|
2008-05-28 19:52:46 +00:00
|
|
|
ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
|
|
|
|
{
|
|
|
|
struct GdiplusStartupInput gdiplusStartupInput;
|
|
|
|
ULONG_PTR gdiplusToken;
|
|
|
|
WNDCLASS WndClass = {0};
|
|
|
|
TCHAR szBuf[512];
|
2014-12-11 19:52:47 +00:00
|
|
|
WCHAR szInitialFile[MAX_PATH];
|
2008-05-28 19:52:46 +00:00
|
|
|
HWND hMainWnd;
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
if (!ImageView_LoadSettings())
|
|
|
|
{
|
|
|
|
shiSettings.Maximized = FALSE;
|
|
|
|
shiSettings.Left = 0;
|
|
|
|
shiSettings.Top = 0;
|
|
|
|
shiSettings.Right = 520;
|
|
|
|
shiSettings.Bottom = 400;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize GDI+
|
|
|
|
gdiplusStartupInput.GdiplusVersion = 1;
|
|
|
|
gdiplusStartupInput.DebugEventCallback = NULL;
|
2009-01-28 09:09:30 +00:00
|
|
|
gdiplusStartupInput.SuppressBackgroundThread = FALSE;
|
|
|
|
gdiplusStartupInput.SuppressExternalCodecs = FALSE;
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
|
2009-01-27 17:14:00 +00:00
|
|
|
pLoadImage(szFileName);
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
// Create the window
|
|
|
|
WndClass.lpszClassName = _T("shimgvw_window");
|
2013-12-19 20:29:17 +00:00
|
|
|
WndClass.lpfnWndProc = ImageView_WndProc;
|
2008-05-28 19:52:46 +00:00
|
|
|
WndClass.hInstance = hInstance;
|
|
|
|
WndClass.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
|
|
|
|
WndClass.hCursor = LoadCursor(hInstance, IDC_ARROW);
|
2018-01-30 19:36:59 +00:00
|
|
|
WndClass.hbrBackground = NULL; /* less flicker */
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
if (!RegisterClass(&WndClass)) return -1;
|
|
|
|
|
|
|
|
LoadString(hInstance, IDS_APPTITLE, szBuf, sizeof(szBuf) / sizeof(TCHAR));
|
|
|
|
hMainWnd = CreateWindow(_T("shimgvw_window"), szBuf,
|
2009-01-27 17:14:00 +00:00
|
|
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CAPTION,
|
2008-05-28 19:52:46 +00:00
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
2013-12-19 20:29:17 +00:00
|
|
|
0, 0, NULL, NULL, hInstance, NULL);
|
2008-05-28 19:52:46 +00:00
|
|
|
|
2014-12-11 19:52:47 +00:00
|
|
|
// make sure the path has no quotes on it
|
|
|
|
wcscpy(szInitialFile, szFileName);
|
|
|
|
PathUnquoteSpacesW(szInitialFile);
|
|
|
|
|
|
|
|
currentFile = pBuildFileList(szInitialFile);
|
|
|
|
if (currentFile)
|
|
|
|
{
|
|
|
|
pLoadImageFromNode(currentFile, hMainWnd);
|
|
|
|
}
|
|
|
|
|
2008-05-28 19:52:46 +00:00
|
|
|
// Show it
|
|
|
|
ShowWindow(hMainWnd, SW_SHOW);
|
|
|
|
UpdateWindow(hMainWnd);
|
|
|
|
|
|
|
|
// Message Loop
|
|
|
|
while(GetMessage(&msg,NULL,0,0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
|
2014-12-11 19:52:47 +00:00
|
|
|
pFreeFileList(currentFile);
|
|
|
|
|
2009-01-27 17:14:00 +00:00
|
|
|
if (image)
|
|
|
|
GdipDisposeImage(image);
|
2008-05-28 19:52:46 +00:00
|
|
|
GdiplusShutdown(gdiplusToken);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
VOID WINAPI
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_FullscreenW(HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
|
2008-05-28 19:52:46 +00:00
|
|
|
{
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_CreateWindow(hwnd, (LPWSTR)path);
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
VOID WINAPI
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_Fullscreen(HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
|
|
|
|
{
|
|
|
|
ImageView_CreateWindow(hwnd, (LPWSTR)path);
|
|
|
|
}
|
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
VOID WINAPI
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_FullscreenA(HWND hwnd, HINSTANCE hInst, LPCSTR path, int nShow)
|
2008-05-28 19:52:46 +00:00
|
|
|
{
|
|
|
|
WCHAR szFile[MAX_PATH];
|
|
|
|
|
2008-05-29 14:30:26 +00:00
|
|
|
if (MultiByteToWideChar(CP_ACP, 0, (char*)path, strlen((char*)path)+1, szFile, MAX_PATH))
|
2008-05-28 19:52:46 +00:00
|
|
|
{
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_CreateWindow(hwnd, (LPWSTR)szFile);
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
2008-05-29 14:30:26 +00:00
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
VOID WINAPI
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_PrintTo(HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
|
|
|
|
{
|
|
|
|
DPRINT("ImageView_PrintTo() not implemented\n");
|
2008-05-28 19:52:46 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
VOID WINAPI
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_PrintToA(HWND hwnd, HINSTANCE hInst, LPCSTR path, int nShow)
|
2008-05-28 19:52:46 +00:00
|
|
|
{
|
2008-05-29 14:30:26 +00:00
|
|
|
DPRINT("ImageView_PrintToA() not implemented\n");
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
2008-08-09 08:20:58 +00:00
|
|
|
VOID WINAPI
|
2008-05-29 14:30:26 +00:00
|
|
|
ImageView_PrintToW(HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
|
|
|
|
{
|
|
|
|
DPRINT("ImageView_PrintToW() not implemented\n");
|
|
|
|
}
|
2008-05-28 19:52:46 +00:00
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
DllMain(IN HINSTANCE hinstDLL,
|
|
|
|
IN DWORD dwReason,
|
|
|
|
IN LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
switch (dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
hInstance = hinstDLL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|