ReactOS  0.4.15-dev-506-ga3ec01c
shimgvw.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <winreg.h>
#include <wingdi.h>
#include <wincon.h>
#include <windowsx.h>
#include <objbase.h>
#include <commctrl.h>
#include <commdlg.h>
#include <gdiplus.h>
#include <tchar.h>
#include <shlobj.h>
#include <strsafe.h>
#include <shlwapi.h>
#include <debug.h>
#include "shimgvw.h"
Include dependency graph for shimgvw.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define INITGUID
 
#define NDEBUG
 
#define MIN_ZOOM   10
 
#define MAX_ZOOM   1600
 
#define ANIME_TIMER_ID   9999
 

Functions

static void Anime_FreeInfo (void)
 
static BOOL Anime_LoadInfo (void)
 
static void Anime_SetFrameIndex (UINT nFrameIndex)
 
DWORD Anime_GetFrameDelay (UINT nFrameIndex)
 
BOOL Anime_Step (DWORD *pdwDelay)
 
static void ZoomInOrOut (BOOL bZoomIn)
 
static void ResetZoom (void)
 
static void pLoadImage (LPWSTR szOpenFileName)
 
static void pSaveImageAs (HWND hwnd)
 
static VOID pPrintImage (HWND hwnd)
 
static VOID EnableToolBarButtons (BOOL bEnable)
 
static VOID pLoadImageFromNode (SHIMGVW_FILENODE *node, HWND hwnd)
 
static SHIMGVW_FILENODEpBuildFileList (LPWSTR szFirstFile)
 
static VOID pFreeFileList (SHIMGVW_FILENODE *root)
 
static VOID ImageView_UpdateWindow (HWND hwnd)
 
static HBRUSH CreateCheckerBoardBrush (HDC hdc)
 
static VOID ImageView_DrawImage (HWND hwnd)
 
static BOOL ImageView_LoadSettings ()
 
static VOID ImageView_SaveSettings (HWND hwnd)
 
static BOOL ImageView_CreateToolBar (HWND hwnd)
 
static void ImageView_OnTimer (HWND hwnd)
 
LRESULT CALLBACK ImageView_DispWndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
static VOID ImageView_InitControls (HWND hwnd)
 
static VOID ImageView_OnMouseWheel (HWND hwnd, INT x, INT y, INT zDelta, UINT fwKeys)
 
static VOID ImageView_OnSize (HWND hwnd, UINT state, INT cx, INT cy)
 
LRESULT CALLBACK ImageView_WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
LONG WINAPI ImageView_CreateWindow (HWND hwnd, LPWSTR szFileName)
 
VOID WINAPI ImageView_FullscreenW (HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
 
VOID WINAPI ImageView_Fullscreen (HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
 
VOID WINAPI ImageView_FullscreenA (HWND hwnd, HINSTANCE hInst, LPCSTR path, int nShow)
 
VOID WINAPI ImageView_PrintTo (HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
 
VOID WINAPI ImageView_PrintToA (HWND hwnd, HINSTANCE hInst, LPCSTR path, int nShow)
 
VOID WINAPI ImageView_PrintToW (HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
 
BOOL WINAPI DllMain (IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
 

Variables

HINSTANCE hInstance
 
SHIMGVW_SETTINGS shiSettings
 
SHIMGVW_FILENODEcurrentFile
 
GpImageimage = NULL
 
WNDPROC PrevProc = NULL
 
HWND hDispWnd
 
HWND hToolBar
 
UINT ZoomPercents = 100
 
static const UINT ZoomSteps []
 
UINT m_nFrameIndex = 0
 
UINT m_nFrameCount = 0
 
UINT m_nLoopIndex = 0
 
UINT m_nLoopCount = (UINT)-1
 
PropertyItemm_pDelayItem = NULL
 
static const TBBUTTON Buttons []
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 10 of file shimgvw.c.

◆ ANIME_TIMER_ID

#define ANIME_TIMER_ID   9999

Definition at line 61 of file shimgvw.c.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 11 of file shimgvw.c.

◆ INITGUID

#define INITGUID

Definition at line 12 of file shimgvw.c.

◆ MAX_ZOOM

#define MAX_ZOOM   1600

Definition at line 47 of file shimgvw.c.

◆ MIN_ZOOM

#define MIN_ZOOM   10

Definition at line 46 of file shimgvw.c.

◆ NDEBUG

#define NDEBUG

Definition at line 32 of file shimgvw.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file shimgvw.c.

Function Documentation

◆ Anime_FreeInfo()

static void Anime_FreeInfo ( void  )
static

Definition at line 63 of file shimgvw.c.

64 {
65  if (m_pDelayItem)
66  {
69  }
70  m_nFrameIndex = 0;
71  m_nFrameCount = 0;
72  m_nLoopIndex = 0;
73  m_nLoopCount = (UINT)-1;
74 }
#define free
Definition: debug_ros.c:5
UINT m_nLoopIndex
Definition: shimgvw.c:57
smooth NULL
Definition: ftsmooth.c:416
PropertyItem * m_pDelayItem
Definition: shimgvw.c:59
UINT m_nLoopCount
Definition: shimgvw.c:58
unsigned int UINT
Definition: ndis.h:50
UINT m_nFrameIndex
Definition: shimgvw.c:55
UINT m_nFrameCount
Definition: shimgvw.c:56

Referenced by Anime_LoadInfo(), and ImageView_CreateWindow().

◆ Anime_GetFrameDelay()

DWORD Anime_GetFrameDelay ( UINT  nFrameIndex)

Definition at line 150 of file shimgvw.c.

151 {
152  if (nFrameIndex < m_nFrameCount && m_pDelayItem)
153  {
154  return ((DWORD *)m_pDelayItem->value)[m_nFrameIndex] * 10;
155  }
156  return 0;
157 }
unsigned long DWORD
Definition: ntddk_ex.h:95
PropertyItem * m_pDelayItem
Definition: shimgvw.c:59
UINT m_nFrameIndex
Definition: shimgvw.c:55
UINT m_nFrameCount
Definition: shimgvw.c:56

Referenced by Anime_Step().

◆ Anime_LoadInfo()

static BOOL Anime_LoadInfo ( void  )
static

Definition at line 76 of file shimgvw.c.

77 {
78  GUID *dims;
79  UINT nDimCount = 0;
80  UINT cbItem;
81  UINT result;
82  PropertyItem *pItem;
83 
86 
87  if (!image)
88  return FALSE;
89 
91  if (nDimCount)
92  {
93  dims = (GUID *)calloc(nDimCount, sizeof(GUID));
94  if (dims)
95  {
96  GdipImageGetFrameDimensionsList(image, dims, nDimCount);
99  free(dims);
100  }
101  }
102 
103  result = 0;
105  cbItem = result;
106  if (cbItem)
107  {
108  m_pDelayItem = (PropertyItem *)malloc(cbItem);
110  }
111 
112  result = 0;
114  cbItem = result;
115  if (cbItem)
116  {
117  pItem = (PropertyItem *)malloc(cbItem);
118  if (pItem)
119  {
120  if (GdipGetPropertyItem(image, PropertyTagLoopCount, cbItem, pItem) == Ok)
121  {
122  m_nLoopCount = *(WORD *)pItem->value;
123  }
124  free(pItem);
125  }
126  }
127 
128  if (m_pDelayItem)
129  {
131  }
132 
133  return m_pDelayItem != NULL;
134 }
#define PropertyTagLoopCount
GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GDIPCONST GUID *dimensionID, UINT *count)
Definition: image.c:2865
#define free
Definition: debug_ros.c:5
GpStatus WINGDIPAPI GdipGetPropertyItemSize(GpImage *image, PROPID propid, UINT *size)
Definition: image.c:2488
#define ANIME_TIMER_ID
Definition: shimgvw.c:61
#define PropertyTagFrameDelay
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static void Anime_FreeInfo(void)
Definition: shimgvw.c:63
unsigned short WORD
Definition: ntddk_ex.h:93
GpStatus WINGDIPAPI GdipGetPropertyItem(GpImage *image, PROPID propid, UINT size, PropertyItem *buffer)
Definition: image.c:2634
HWND hDispWnd
Definition: shimgvw.c:43
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
PropertyItem * m_pDelayItem
Definition: shimgvw.c:59
UINT m_nLoopCount
Definition: shimgvw.c:58
unsigned int UINT
Definition: ndis.h:50
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsCount(GpImage *image, UINT *count)
Definition: image.c:2885
#define calloc
Definition: rosglue.h:14
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsList(GpImage *image, GUID *dimensionIDs, UINT count)
Definition: image.c:2900
#define malloc
Definition: debug_ros.c:4
UINT m_nFrameCount
Definition: shimgvw.c:56
GLuint64EXT * result
Definition: glext.h:11304

Referenced by pLoadImage().

◆ Anime_SetFrameIndex()

static void Anime_SetFrameIndex ( UINT  nFrameIndex)
static

Definition at line 136 of file shimgvw.c.

137 {
138  if (nFrameIndex < m_nFrameCount)
139  {
140  GUID guid = FrameDimensionTime;
141  if (Ok != GdipImageSelectActiveFrame(image, &guid, nFrameIndex))
142  {
143  guid = FrameDimensionPage;
144  GdipImageSelectActiveFrame(image, &guid, nFrameIndex);
145  }
146  }
147  m_nFrameIndex = nFrameIndex;
148 }
const GUID * guid
GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *dimensionID, UINT frame)
Definition: image.c:4302
UINT m_nFrameIndex
Definition: shimgvw.c:55
UINT m_nFrameCount
Definition: shimgvw.c:56

Referenced by Anime_Step().

◆ Anime_Step()

BOOL Anime_Step ( DWORD pdwDelay)

Definition at line 159 of file shimgvw.c.

160 {
161  *pdwDelay = INFINITE;
162  if (m_nLoopCount == (UINT)-1)
163  return FALSE;
164 
165  if (m_nFrameIndex + 1 < m_nFrameCount)
166  {
167  *pdwDelay = Anime_GetFrameDelay(m_nFrameIndex);
169  ++m_nFrameIndex;
170  return TRUE;
171  }
172 
173  if (m_nLoopCount == 0 || m_nLoopIndex < m_nLoopCount)
174  {
175  *pdwDelay = Anime_GetFrameDelay(m_nFrameIndex);
177  m_nFrameIndex = 0;
178  ++m_nLoopIndex;
179  return TRUE;
180  }
181 
182  return FALSE;
183 }
#define TRUE
Definition: types.h:120
UINT m_nLoopIndex
Definition: shimgvw.c:57
DWORD Anime_GetFrameDelay(UINT nFrameIndex)
Definition: shimgvw.c:150
static void Anime_SetFrameIndex(UINT nFrameIndex)
Definition: shimgvw.c:136
UINT m_nLoopCount
Definition: shimgvw.c:58
unsigned int UINT
Definition: ndis.h:50
UINT m_nFrameIndex
Definition: shimgvw.c:55
UINT m_nFrameCount
Definition: shimgvw.c:56
#define INFINITE
Definition: serial.h:102

Referenced by ImageView_OnTimer().

◆ CreateCheckerBoardBrush()

static HBRUSH CreateCheckerBoardBrush ( HDC  hdc)
static

Definition at line 619 of file shimgvw.c.

620 {
621  static const CHAR pattern[] =
622  "\x28\x00\x00\x00\x10\x00\x00\x00\x10\x00\x00\x00\x01\x00\x04\x00\x00\x00"
623  "\x00\x00\x80\x00\x00\x00\x23\x2E\x00\x00\x23\x2E\x00\x00\x10\x00\x00\x00"
624  "\x00\x00\x00\x00\x99\x99\x99\x00\xCC\xCC\xCC\x00\x00\x00\x00\x00\x00\x00"
625  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
626  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
627  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11\x11\x11"
628  "\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00"
629  "\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00"
630  "\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11"
631  "\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00"
632  "\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11"
633  "\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11"
634  "\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11";
635 
637 }
char CHAR
Definition: xmlstorage.h:175
#define DIB_RGB_COLORS
Definition: wingdi.h:366
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
GLubyte * pattern
Definition: glext.h:7787

Referenced by ImageView_DrawImage().

◆ DllMain()

BOOL WINAPI DllMain ( IN HINSTANCE  hinstDLL,
IN DWORD  dwReason,
IN LPVOID  lpvReserved 
)

@DllMain

Core routine of the Utility Manager's library.

Parameters
[in]hDllInstanceThe entry point instance of the library.
[in]fdwReasonThe reason argument to indicate the motive DllMain is being called.
[in]lpvReservedReserved.
Returns
Returns TRUE when main call initialization has succeeded, FALSE otherwise.

Definition at line 1225 of file shimgvw.c.

1228 {
1229  switch (dwReason)
1230  {
1231  case DLL_PROCESS_ATTACH:
1232  case DLL_THREAD_ATTACH:
1233  hInstance = hinstDLL;
1234  break;
1235  }
1236 
1237  return TRUE;
1238 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:121
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: shimgvw.c:37

◆ EnableToolBarButtons()

static VOID EnableToolBarButtons ( BOOL  bEnable)
static

Definition at line 440 of file shimgvw.c.

441 {
444 }
#define IDC_SAVE
Definition: resource.h:16
#define TB_ENABLEBUTTON
Definition: commctrl.h:1038
_In_ BOOL bEnable
Definition: winddi.h:3426
#define SendMessage
Definition: winuser.h:5818
HWND hToolBar
Definition: shimgvw.c:43
#define IDC_PRINT
Definition: fontview.h:14

Referenced by pLoadImageFromNode().

◆ ImageView_CreateToolBar()

static BOOL ImageView_CreateToolBar ( HWND  hwnd)
static

Definition at line 800 of file shimgvw.c.

801 {
802  INT numButtons = sizeof(Buttons) / sizeof(Buttons[0]);
803 
806  0, 0, 0, 0, hwnd,
807  0, hInstance, NULL);
808  if(hToolBar != NULL)
809  {
810  HIMAGELIST hImageList;
811 
814 
816  sizeof(Buttons[0]), 0);
817 
819 
822 
825 
828 
831 
834 
837 
840 
843 
844  if (hImageList == NULL) return FALSE;
845 
847  0, (LPARAM)hImageList));
848 
850  numButtons, (LPARAM)Buttons);
851 
852  return TRUE;
853  }
854 
855  return FALSE;
856 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1130
#define TRUE
Definition: types.h:120
#define IDB_PRINTICON
Definition: resource.h:15
#define TBSTYLE_EX_HIDECLIPPEDBUTTONS
Definition: commctrl.h:1009
#define RGB(r, g, b)
Definition: precomp.h:62
#define IDB_NEXTICON
Definition: resource.h:11
#define WS_CHILD
Definition: pedump.c:617
int32_t INT
Definition: typedefs.h:57
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define TB_IMAGE_HEIGHT
Definition: shimgvw.h:4
#define IDB_PREVICON
Definition: resource.h:10
#define CreateWindowEx
Definition: winuser.h:5730
#define TOOLBARCLASSNAME
Definition: commctrl.h:942
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define CCS_BOTTOM
Definition: commctrl.h:2240
#define TB_SETIMAGELIST
Definition: commctrl.h:1146
#define ILC_COLOR24
Definition: commctrl.h:353
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:985
#define TB_ADDBUTTONS
Definition: commctrl.h:1267
#define ILC_MASK
Definition: commctrl.h:347
#define IDB_ROT1ICON
Definition: resource.h:16
#define IDB_ROT2ICON
Definition: resource.h:17
#define IDB_ZOOMMICON
Definition: resource.h:13
#define IMAGE_BITMAP
Definition: winuser.h:211
HINSTANCE hInstance
Definition: shimgvw.c:37
#define IDB_SAVEICON
Definition: resource.h:14
#define SendMessage
Definition: winuser.h:5818
#define TB_IMAGE_WIDTH
Definition: shimgvw.h:3
HWND hToolBar
Definition: shimgvw.c:43
#define LoadImage
Definition: winuser.h:5790
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
static const TBBUTTON Buttons[]
Definition: shimgvw.c:282
#define IDB_ZOOMPICON
Definition: resource.h:12
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
#define WS_VISIBLE
Definition: pedump.c:620
#define TBSTYLE_FLAT
Definition: commctrl.h:988
#define TB_SETEXTENDEDSTYLE
Definition: commctrl.h:1186

Referenced by ImageView_InitControls().

◆ ImageView_CreateWindow()

LONG WINAPI ImageView_CreateWindow ( HWND  hwnd,
LPWSTR  szFileName 
)

Definition at line 1103 of file shimgvw.c.

1104 {
1105  struct GdiplusStartupInput gdiplusStartupInput;
1107  WNDCLASS WndClass = {0};
1108  TCHAR szBuf[512];
1109  WCHAR szInitialFile[MAX_PATH];
1110  HWND hMainWnd;
1111  MSG msg;
1112 
1113  if (!ImageView_LoadSettings())
1114  {
1116  shiSettings.Left = 0;
1117  shiSettings.Top = 0;
1118  shiSettings.Right = 520;
1119  shiSettings.Bottom = 400;
1120  }
1121 
1122  // Initialize GDI+
1123  gdiplusStartupInput.GdiplusVersion = 1;
1124  gdiplusStartupInput.DebugEventCallback = NULL;
1125  gdiplusStartupInput.SuppressBackgroundThread = FALSE;
1126  gdiplusStartupInput.SuppressExternalCodecs = FALSE;
1127 
1128  GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1129  pLoadImage(szFileName);
1130 
1131  // Create the window
1132  WndClass.lpszClassName = _T("shimgvw_window");
1133  WndClass.lpfnWndProc = ImageView_WndProc;
1134  WndClass.hInstance = hInstance;
1135  WndClass.style = CS_HREDRAW | CS_VREDRAW;
1137  WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
1138  WndClass.hbrBackground = NULL; /* less flicker */
1139 
1140  if (!RegisterClass(&WndClass)) return -1;
1141 
1142  LoadString(hInstance, IDS_APPTITLE, szBuf, sizeof(szBuf) / sizeof(TCHAR));
1143  hMainWnd = CreateWindow(_T("shimgvw_window"), szBuf,
1146  0, 0, NULL, NULL, hInstance, NULL);
1147 
1148  // make sure the path has no quotes on it
1149  wcscpy(szInitialFile, szFileName);
1150  PathUnquoteSpacesW(szInitialFile);
1151 
1152  currentFile = pBuildFileList(szInitialFile);
1153  if (currentFile)
1154  {
1156  }
1157 
1158  // Show it
1161 
1162  // Message Loop
1163  while(GetMessage(&msg,NULL,0,0))
1164  {
1167  }
1168 
1170 
1171  if (image)
1172  {
1174  image = NULL;
1175  }
1176 
1177  Anime_FreeInfo();
1178 
1180  return -1;
1181 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
BOOL WINAPI TranslateMessage(_In_ const MSG *)
static BOOL ImageView_LoadSettings()
Definition: shimgvw.c:755
#define CreateWindow
Definition: winuser.h:5729
#define IDS_APPTITLE
Definition: resource.h:3
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CS_HREDRAW
Definition: winuser.h:648
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
uint32_t ULONG_PTR
Definition: typedefs.h:64
BOOL Maximized
Definition: shimgvw.h:10
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
LRESULT CALLBACK ImageView_WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:942
#define CW_USEDEFAULT
Definition: winuser.h:225
static SHIMGVW_FILENODE * pBuildFileList(LPWSTR szFirstFile)
Definition: shimgvw.c:484
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
SHIMGVW_FILENODE * currentFile
Definition: shimgvw.c:39
#define WS_CAPTION
Definition: pedump.c:624
static void Anime_FreeInfo(void)
Definition: shimgvw.c:63
#define CS_VREDRAW
Definition: winuser.h:653
char TCHAR
Definition: xmlstorage.h:189
static VOID pLoadImageFromNode(SHIMGVW_FILENODE *node, HWND hwnd)
Definition: shimgvw.c:447
#define _T(x)
Definition: vfdio.h:22
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
void WINAPI GdiplusShutdown(ULONG_PTR)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
static ULONG_PTR gdiplusToken
Definition: CImage.cpp:79
HWND hMainWnd
Definition: magnifier.c:32
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static VOID pFreeFileList(SHIMGVW_FILENODE *root)
Definition: shimgvw.c:597
#define IDI_APPICON
Definition: resource.h:166
#define LoadCursor
Definition: winuser.h:5787
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1029
static void pLoadImage(LPWSTR szOpenFileName)
Definition: shimgvw.c:297
#define GetMessage
Definition: winuser.h:5765
HINSTANCE hInstance
Definition: shimgvw.c:37
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define RegisterClass
Definition: winuser.h:5811
#define LoadIcon
Definition: winuser.h:5788
#define WS_VISIBLE
Definition: pedump.c:620
#define LoadString
Definition: winuser.h:5794
WCHAR WndClass[]
Definition: capicon.c:23

Referenced by ImageView_Fullscreen(), ImageView_FullscreenA(), and ImageView_FullscreenW().

◆ ImageView_DispWndProc()

LRESULT CALLBACK ImageView_DispWndProc ( HWND  hwnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 872 of file shimgvw.c.

873 {
874  switch (Message)
875  {
876  case WM_PAINT:
877  {
879  return 0L;
880  }
881  case WM_TIMER:
882  {
883  if (wParam == ANIME_TIMER_ID)
884  {
886  return 0;
887  }
888  break;
889  }
890  }
892 }
#define CallWindowProc
Definition: winuser.h:5710
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WNDPROC PrevProc
Definition: shimgvw.c:41
#define ANIME_TIMER_ID
Definition: shimgvw.c:61
WPARAM wParam
Definition: combotst.c:138
#define WM_TIMER
Definition: winuser.h:1724
#define WM_PAINT
Definition: winuser.h:1602
CHAR Message[80]
Definition: alive.c:5
static const WCHAR L[]
Definition: oid.c:1250
static VOID ImageView_DrawImage(HWND hwnd)
Definition: shimgvw.c:640
static void ImageView_OnTimer(HWND hwnd)
Definition: shimgvw.c:858
LPARAM lParam
Definition: combotst.c:139

Referenced by ImageView_InitControls().

◆ ImageView_DrawImage()

static VOID ImageView_DrawImage ( HWND  hwnd)
static

Definition at line 640 of file shimgvw.c.

641 {
642  GpGraphics *graphics;
643  UINT ImageWidth, ImageHeight;
644  INT ZoomedWidth, ZoomedHeight, x, y;
645  PAINTSTRUCT ps;
646  RECT rect, margin;
647  HDC hdc;
648  HBRUSH white;
649  HGDIOBJ hbrOld;
650  UINT uFlags;
651  WCHAR szText[128];
652  HGDIOBJ hFontOld;
653 
654  hdc = BeginPaint(hwnd, &ps);
655  if (!hdc)
656  {
657  DPRINT1("BeginPaint() failed\n");
658  return;
659  }
660 
661  GdipCreateFromHDC(hdc, &graphics);
662  if (!graphics)
663  {
664  DPRINT1("GdipCreateFromHDC() failed\n");
665  return;
666  }
667 
669  white = GetStockObject(WHITE_BRUSH);
670 
671  if (image == NULL)
672  {
673  FillRect(hdc, &rect, white);
674 
676 
677  SetTextColor(hdc, RGB(0, 0, 0));
679 
682  DT_NOPREFIX);
683  SelectObject(hdc, hFontOld);
684  }
685  else
686  {
687  GdipGetImageWidth(image, &ImageWidth);
688  GdipGetImageHeight(image, &ImageHeight);
689 
690  ZoomedWidth = (ImageWidth * ZoomPercents) / 100;
691  ZoomedHeight = (ImageHeight * ZoomPercents) / 100;
692 
693  x = (rect.right - ZoomedWidth) / 2;
694  y = (rect.bottom - ZoomedHeight) / 2;
695 
696  // Fill top part
697  margin = rect;
698  margin.bottom = y - 1;
699  FillRect(hdc, &margin, white);
700  // Fill bottom part
701  margin.top = y + ZoomedHeight + 1;
702  margin.bottom = rect.bottom;
703  FillRect(hdc, &margin, white);
704  // Fill left part
705  margin.top = y - 1;
706  margin.bottom = y + ZoomedHeight + 1;
707  margin.right = x - 1;
708  FillRect(hdc, &margin, white);
709  // Fill right part
710  margin.left = x + ZoomedWidth + 1;
711  margin.right = rect.right;
712  FillRect(hdc, &margin, white);
713 
714  DPRINT("x = %d, y = %d, ImageWidth = %u, ImageHeight = %u\n");
715  DPRINT("rect.right = %ld, rect.bottom = %ld\n", rect.right, rect.bottom);
716  DPRINT("ZoomPercents = %d, ZoomedWidth = %d, ZoomedHeight = %d\n",
717  ZoomPercents, ZoomedWidth, ZoomedWidth);
718 
719  if (ZoomPercents % 100 == 0)
720  {
723  }
724  else
725  {
728  }
729 
730  uFlags = 0;
732 
734  {
735  HBRUSH hbr = CreateCheckerBoardBrush(hdc);
736  hbrOld = SelectObject(hdc, hbr);
737  Rectangle(hdc, x - 1, y - 1, x + ZoomedWidth + 1, y + ZoomedHeight + 1);
738  SelectObject(hdc, hbrOld);
739  DeleteObject(hbr);
740  }
741  else
742  {
744  Rectangle(hdc, x - 1, y - 1, x + ZoomedWidth + 1, y + ZoomedHeight + 1);
745  SelectObject(hdc, hbrOld);
746  }
747 
748  GdipDrawImageRectI(graphics, image, x, y, ZoomedWidth, ZoomedHeight);
749  }
750  GdipDeleteGraphics(graphics);
751  EndPaint(hwnd, &ps);
752 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define RGB(r, g, b)
Definition: precomp.h:62
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2342
#define NULL_BRUSH
Definition: wingdi.h:900
UINT ZoomPercents
Definition: shimgvw.c:48
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WHITE_BRUSH
Definition: wingdi.h:901
GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags)
Definition: image.c:5266
LONG left
Definition: windef.h:306
UINT uFlags
Definition: api.c:59
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
#define DT_NOPREFIX
Definition: winuser.h:537
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
& rect
Definition: startmenu.cpp:1413
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2239
static const WCHAR szText[]
Definition: dialog.c:139
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
Definition: graphics.c:6289
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define TRANSPARENT
Definition: wingdi.h:949
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define DT_VCENTER
Definition: winuser.h:543
GpStatus WINGDIPAPI GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y, INT width, INT height)
Definition: graphics.c:3561
__wchar_t WCHAR
Definition: xmlstorage.h:180
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, InterpolationMode mode)
Definition: graphics.c:6143
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
HDC hdc
Definition: main.c:9
static HBRUSH CreateCheckerBoardBrush(HDC hdc)
Definition: shimgvw.c:619
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
unsigned int UINT
Definition: ndis.h:50
HINSTANCE hInstance
Definition: shimgvw.c:37
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define DPRINT1
Definition: precomp.h:8
LONG bottom
Definition: windef.h:309
#define DT_CENTER
Definition: winuser.h:527
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define IDS_NOPREVIEW
Definition: resource.h:41
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17

Referenced by ImageView_DispWndProc().

◆ ImageView_Fullscreen()

VOID WINAPI ImageView_Fullscreen ( HWND  hwnd,
HINSTANCE  hInst,
LPCWSTR  path,
int  nShow 
)

Definition at line 1190 of file shimgvw.c.

1191 {
1193 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG WINAPI ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
Definition: shimgvw.c:1103
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ ImageView_FullscreenA()

VOID WINAPI ImageView_FullscreenA ( HWND  hwnd,
HINSTANCE  hInst,
LPCSTR  path,
int  nShow 
)

Definition at line 1196 of file shimgvw.c.

1197 {
1198  WCHAR szFile[MAX_PATH];
1199 
1200  if (MultiByteToWideChar(CP_ACP, 0, (char*)path, strlen((char*)path)+1, szFile, MAX_PATH))
1201  {
1203  }
1204 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
LONG WINAPI ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
Definition: shimgvw.c:1103
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ ImageView_FullscreenW()

VOID WINAPI ImageView_FullscreenW ( HWND  hwnd,
HINSTANCE  hInst,
LPCWSTR  path,
int  nShow 
)

Definition at line 1184 of file shimgvw.c.

1185 {
1187 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG WINAPI ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
Definition: shimgvw.c:1103
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ ImageView_InitControls()

static VOID ImageView_InitControls ( HWND  hwnd)
static

Definition at line 895 of file shimgvw.c.

896 {
900 
902 
905  0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
906 
909 
911 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
#define TRUE
Definition: types.h:120
WNDPROC PrevProc
Definition: shimgvw.c:41
#define CS_HREDRAW
Definition: winuser.h:648
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT CALLBACK ImageView_DispWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:872
#define SetWindowLongPtr
Definition: treelist.c:70
static BOOL ImageView_CreateToolBar(HWND hwnd)
Definition: shimgvw.c:800
#define GCL_STYLE
Definition: winuser.h:665
BOOL Maximized
Definition: shimgvw.h:10
#define WC_STATIC
Definition: commctrl.h:4678
#define CreateWindowEx
Definition: winuser.h:5730
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define SetClassLongPtr
Definition: winuser.h:5823
#define CS_VREDRAW
Definition: winuser.h:653
#define _T(x)
Definition: vfdio.h:22
HWND hDispWnd
Definition: shimgvw.c:43
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
HINSTANCE hInstance
Definition: shimgvw.c:37
#define WS_VISIBLE
Definition: pedump.c:620
#define SW_MAXIMIZE
Definition: winuser.h:766

Referenced by ImageView_WndProc().

◆ ImageView_LoadSettings()

static BOOL ImageView_LoadSettings ( )
static

Definition at line 755 of file shimgvw.c.

756 {
757  HKEY hKey;
758  DWORD dwSize;
759 
760  if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
761  {
762  dwSize = sizeof(SHIMGVW_SETTINGS);
763  if (RegQueryValueEx(hKey, _T("Settings"), NULL, NULL, (LPBYTE)&shiSettings, &dwSize) == ERROR_SUCCESS)
764  {
765  RegCloseKey(hKey);
766  return TRUE;
767  }
768 
769  RegCloseKey(hKey);
770  }
771 
772  return FALSE;
773 }
#define RegQueryValueEx
Definition: winreg.h:524
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by ImageView_CreateWindow().

◆ ImageView_OnMouseWheel()

static VOID ImageView_OnMouseWheel ( HWND  hwnd,
INT  x,
INT  y,
INT  zDelta,
UINT  fwKeys 
)
static

Definition at line 914 of file shimgvw.c.

915 {
916  if (zDelta != 0)
917  {
918  ZoomInOrOut(zDelta > 0);
919  }
920 }
static void ZoomInOrOut(BOOL bZoomIn)
Definition: shimgvw.c:185

Referenced by ImageView_WndProc().

◆ ImageView_OnSize()

static VOID ImageView_OnSize ( HWND  hwnd,
UINT  state,
INT  cx,
INT  cy 
)
static

Definition at line 923 of file shimgvw.c.

924 {
925  RECT rc;
926 
928 
929  GetWindowRect(hToolBar, &rc);
930 
931  MoveWindow(hDispWnd, 0, 0, cx, cy - (rc.bottom - rc.top), TRUE);
932 
933  /* is it maximized or restored? */
935  {
936  /* reset zoom */
937  ResetZoom();
938  }
939 }
#define TRUE
Definition: types.h:120
static void ResetZoom(void)
Definition: shimgvw.c:238
#define SIZE_MAXIMIZED
Definition: winuser.h:2482
#define SIZE_RESTORED
Definition: winuser.h:2480
LONG top
Definition: windef.h:307
#define TB_AUTOSIZE
Definition: commctrl.h:1133
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
HWND hDispWnd
Definition: shimgvw.c:43
static int state
Definition: maze.c:121
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
_Out_opt_ int * cx
Definition: commctrl.h:581
#define SendMessage
Definition: winuser.h:5818
HWND hToolBar
Definition: shimgvw.c:43
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by ImageView_WndProc().

◆ ImageView_OnTimer()

static void ImageView_OnTimer ( HWND  hwnd)
static

Definition at line 858 of file shimgvw.c.

859 {
860  DWORD dwDelay;
861 
864 
865  if (Anime_Step(&dwDelay))
866  {
867  SetTimer(hwnd, ANIME_TIMER_ID, dwDelay, NULL);
868  }
869 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL Anime_Step(DWORD *pdwDelay)
Definition: shimgvw.c:159
#define ANIME_TIMER_ID
Definition: shimgvw.c:61
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by ImageView_DispWndProc().

◆ ImageView_PrintTo()

VOID WINAPI ImageView_PrintTo ( HWND  hwnd,
HINSTANCE  hInst,
LPCWSTR  path,
int  nShow 
)

Definition at line 1207 of file shimgvw.c.

1208 {
1209  DPRINT("ImageView_PrintTo() not implemented\n");
1210 }
void DPRINT(...)
Definition: polytest.cpp:61

◆ ImageView_PrintToA()

VOID WINAPI ImageView_PrintToA ( HWND  hwnd,
HINSTANCE  hInst,
LPCSTR  path,
int  nShow 
)

Definition at line 1213 of file shimgvw.c.

1214 {
1215  DPRINT("ImageView_PrintToA() not implemented\n");
1216 }
void DPRINT(...)
Definition: polytest.cpp:61

◆ ImageView_PrintToW()

VOID WINAPI ImageView_PrintToW ( HWND  hwnd,
HINSTANCE  hInst,
LPCWSTR  path,
int  nShow 
)

Definition at line 1219 of file shimgvw.c.

1220 {
1221  DPRINT("ImageView_PrintToW() not implemented\n");
1222 }
void DPRINT(...)
Definition: polytest.cpp:61

◆ ImageView_SaveSettings()

static VOID ImageView_SaveSettings ( HWND  hwnd)
static

Definition at line 776 of file shimgvw.c.

777 {
778  WINDOWPLACEMENT wp;
779  HKEY hKey;
780 
782  wp.length = sizeof(WINDOWPLACEMENT);
783  GetWindowPlacement(hwnd, &wp);
784 
790 
791  if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, NULL,
793  {
794  RegSetValueEx(hKey, _T("Settings"), 0, REG_BINARY, (LPBYTE)&shiSettings, sizeof(SHIMGVW_SETTINGS));
795  RegCloseKey(hKey);
796  }
797 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
#define SW_HIDE
Definition: winuser.h:762
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG top
Definition: windef.h:307
#define WPF_RESTORETOMAXIMIZED
Definition: winuser.h:2507
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:308
BOOL Maximized
Definition: shimgvw.h:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define _T(x)
Definition: vfdio.h:22
BOOL WINAPI IsZoomed(_In_ HWND)
RECT rcNormalPosition
Definition: winuser.h:3270
LONG bottom
Definition: windef.h:309
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by ImageView_WndProc().

◆ ImageView_UpdateWindow()

static VOID ImageView_UpdateWindow ( HWND  hwnd)
static

Definition at line 613 of file shimgvw.c.

614 {
617 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI UpdateWindow(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by ImageView_WndProc().

◆ ImageView_WndProc()

LRESULT CALLBACK ImageView_WndProc ( HWND  hwnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 942 of file shimgvw.c.

943 {
944  switch (Message)
945  {
946  case WM_CREATE:
947  {
949  return 0L;
950  }
951 
952  case WM_KEYDOWN:
953  switch (LOWORD(wParam))
954  {
955  case VK_LEFT:
957  break;
958 
959  case VK_RIGHT:
961  break;
962  }
963  break;
964 
965  case WM_COMMAND:
966  {
967  switch (wParam)
968  {
969  case IDC_PREV:
970  {
973  }
974  break;
975 
976  case IDC_NEXT:
977  {
980  }
981  break;
982 
983  case IDC_ZOOMP:
984  ZoomInOrOut(TRUE);
985  break;
986 
987  case IDC_ZOOMM:
989  break;
990 
991  case IDC_SAVE:
993  break;
994 
995  case IDC_PRINT:
996  pPrintImage(hwnd);
997  break;
998 
999  case IDC_ROT1:
1000  {
1001  if (image)
1002  {
1005  }
1006  break;
1007  }
1008 
1009  case IDC_ROT2:
1010  {
1011  if (image)
1012  {
1015  }
1016  break;
1017  }
1018  }
1019  }
1020  break;
1021 
1022  case WM_MOUSEWHEEL:
1026  break;
1027 
1028  case WM_NOTIFY:
1029  {
1030  LPNMHDR pnmhdr = (LPNMHDR)lParam;
1031 
1032  switch (pnmhdr->code)
1033  {
1034  case TTN_GETDISPINFO:
1035  {
1036  LPTOOLTIPTEXT lpttt;
1037  UINT idButton;
1038 
1039  lpttt = (LPTOOLTIPTEXT)lParam;
1040  idButton = (UINT)lpttt->hdr.idFrom;
1041  lpttt->hinst = hInstance;
1042 
1043  switch (idButton)
1044  {
1045  case IDC_PREV:
1046  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PREV_PIC);
1047  break;
1048  case IDC_NEXT:
1049  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEXT_PIC);
1050  break;
1051  case IDC_ZOOMP:
1052  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ZOOM_IN);
1053  break;
1054  case IDC_ZOOMM:
1055  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ZOOM_OUT);
1056  break;
1057  case IDC_SAVE:
1058  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SAVEAS);
1059  break;
1060  case IDC_PRINT:
1061  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINT);
1062  break;
1063  case IDC_ROT1:
1064  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ROT_COUNCW);
1065  break;
1066  case IDC_ROT2:
1067  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ROT_CLOCKW);
1068  break;
1069  }
1070  return TRUE;
1071  }
1072  }
1073  break;
1074  }
1075  case WM_SIZING:
1076  {
1077  LPRECT pRect = (LPRECT)lParam;
1078  if (pRect->right-pRect->left < 350)
1079  pRect->right = pRect->left + 350;
1080 
1081  if (pRect->bottom-pRect->top < 290)
1082  pRect->bottom = pRect->top + 290;
1083  return TRUE;
1084  }
1085  case WM_SIZE:
1086  {
1088  return 0;
1089  }
1090  case WM_DESTROY:
1091  {
1094  PostQuitMessage(0);
1095  break;
1096  }
1097  }
1098 
1099  return DefWindowProc(hwnd, Message, wParam, lParam);
1100 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDS_TOOLTIP_ROT_COUNCW
Definition: resource.h:59
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define IDC_ZOOMM
Definition: resource.h:23
WNDPROC PrevProc
Definition: shimgvw.c:41
#define IDS_TOOLTIP_NEXT_PIC
Definition: resource.h:54
#define WM_MOUSEWHEEL
Definition: treelist.c:96
LONG top
Definition: windef.h:307
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define VK_LEFT
Definition: winuser.h:2199
#define IDC_NEXT
Definition: fontview.h:17
LONG left
Definition: windef.h:306
struct SHIMGVW_FILENODE_INTERNAL * Next
Definition: shimgvw.h:21
#define IDC_ROT2
Definition: resource.h:27
LONG right
Definition: windef.h:308
#define IDC_SAVE
Definition: resource.h:16
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
#define IDS_TOOLTIP_PREV_PIC
Definition: resource.h:55
UINT code
Definition: winuser.h:3134
#define IDC_ROT1
Definition: resource.h:26
GpStatus WINGDIPAPI GdipImageRotateFlip(GpImage *image, RotateFlipType type)
Definition: image.c:5358
#define IDS_TOOLTIP_ZOOM_OUT
Definition: resource.h:57
short SHORT
Definition: pedump.c:59
static VOID pPrintImage(HWND hwnd)
Definition: shimgvw.c:434
#define TTN_GETDISPINFO
Definition: commctrl.h:1874
#define WM_SIZING
Definition: winuser.h:1789
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
LONG_PTR LPARAM
Definition: windef.h:208
#define LPRECT
Definition: precomp.h:28
switch(r->id)
Definition: btrfs.c:2980
static VOID ImageView_UpdateWindow(HWND hwnd)
Definition: shimgvw.c:613
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5807
SHIMGVW_FILENODE * currentFile
Definition: shimgvw.c:39
#define LPTOOLTIPTEXT
Definition: commctrl.h:1886
static VOID pLoadImageFromNode(SHIMGVW_FILENODE *node, HWND hwnd)
Definition: shimgvw.c:447
#define IDS_TOOLTIP_ZOOM_IN
Definition: resource.h:56
#define WM_SIZE
Definition: winuser.h:1593
#define IDC_PREV
Definition: fontview.h:16
static void ZoomInOrOut(BOOL bZoomIn)
Definition: shimgvw.c:185
#define BN_CLICKED
Definition: winuser.h:1907
HWND hDispWnd
Definition: shimgvw.c:43
CHAR Message[80]
Definition: alive.c:5
#define IDC_ZOOMP
Definition: resource.h:22
static const WCHAR L[]
Definition: oid.c:1250
static VOID ImageView_OnMouseWheel(HWND hwnd, INT x, INT y, INT zDelta, UINT fwKeys)
Definition: shimgvw.c:914
static VOID ImageView_OnSize(HWND hwnd, UINT state, INT cx, INT cy)
Definition: shimgvw.c:923
#define WM_COMMAND
Definition: winuser.h:1722
#define GWLP_WNDPROC
Definition: treelist.c:66
#define IDS_TOOLTIP_SAVEAS
Definition: resource.h:61
#define VK_RIGHT
Definition: winuser.h:2201
struct SHIMGVW_FILENODE_INTERNAL * Prev
Definition: shimgvw.h:20
unsigned int UINT
Definition: ndis.h:50
HINSTANCE hInstance
Definition: shimgvw.c:37
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
static void pSaveImageAs(HWND hwnd)
Definition: shimgvw.c:325
LONG bottom
Definition: windef.h:309
static VOID ImageView_InitControls(HWND hwnd)
Definition: shimgvw.c:895
static VOID ImageView_SaveSettings(HWND hwnd)
Definition: shimgvw.c:776
#define IDC_PRINT
Definition: fontview.h:14
LPARAM lParam
Definition: combotst.c:139
#define IDS_TOOLTIP_ROT_CLOCKW
Definition: resource.h:58
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_NOTIFY
Definition: richedit.h:61
#define IDS_TOOLTIP_PRINT
Definition: resource.h:60

Referenced by ImageView_CreateWindow().

◆ pBuildFileList()

static SHIMGVW_FILENODE* pBuildFileList ( LPWSTR  szFirstFile)
static

Definition at line 484 of file shimgvw.c.

485 {
486  HANDLE hFindHandle;
487  WCHAR *extension;
488  WCHAR szSearchPath[MAX_PATH];
489  WCHAR szSearchMask[MAX_PATH];
490  WCHAR szFileTypes[MAX_PATH];
491  WIN32_FIND_DATAW findData;
492  SHIMGVW_FILENODE *currentNode = NULL;
494  SHIMGVW_FILENODE *conductor = NULL;
495  ImageCodecInfo *codecInfo;
496  UINT num;
497  UINT size;
498  UINT j;
499 
500  StringCbCopyW(szSearchPath, sizeof(szSearchPath), szFirstFile);
501  PathRemoveFileSpecW(szSearchPath);
502 
504  codecInfo = malloc(size);
505  if (!codecInfo)
506  {
507  DPRINT1("malloc() failed in pLoadFileList()\n");
508  return NULL;
509  }
510 
511  GdipGetImageDecoders(num, size, codecInfo);
512 
513  root = malloc(sizeof(SHIMGVW_FILENODE));
514  if (!root)
515  {
516  DPRINT1("malloc() failed in pLoadFileList()\n");
517  free(codecInfo);
518  return NULL;
519  }
520 
521  conductor = root;
522 
523  for (j = 0; j < num; ++j)
524  {
525  StringCbCopyW(szFileTypes, sizeof(szFileTypes), codecInfo[j].FilenameExtension);
526 
527  extension = wcstok(szFileTypes, L";");
528  while (extension != NULL)
529  {
530  PathCombineW(szSearchMask, szSearchPath, extension);
531 
532  hFindHandle = FindFirstFileW(szSearchMask, &findData);
533  if (hFindHandle != INVALID_HANDLE_VALUE)
534  {
535  do
536  {
537  PathCombineW(conductor->FileName, szSearchPath, findData.cFileName);
538 
539  // compare the name of the requested file with the one currently found.
540  // if the name matches, the current node is returned by the function.
541  if (wcscmp(szFirstFile, conductor->FileName) == 0)
542  {
543  currentNode = conductor;
544  }
545 
546  conductor->Next = malloc(sizeof(SHIMGVW_FILENODE));
547 
548  // if malloc fails, make circular what we have and return it
549  if (!conductor->Next)
550  {
551  DPRINT1("malloc() failed in pLoadFileList()\n");
552 
553  conductor->Next = root;
554  root->Prev = conductor;
555 
556  FindClose(hFindHandle);
557  free(codecInfo);
558  return conductor;
559  }
560 
561  conductor->Next->Prev = conductor;
562  conductor = conductor->Next;
563  }
564  while (FindNextFileW(hFindHandle, &findData) != 0);
565 
566  FindClose(hFindHandle);
567  }
568 
569  extension = wcstok(NULL, L";");
570  }
571  }
572 
573  // we now have a node too much in the list. In case the requested file was not found,
574  // we use this node to store the name of it, otherwise we free it.
575  if (currentNode == NULL)
576  {
577  StringCchCopyW(conductor->FileName, MAX_PATH, szFirstFile);
578  currentNode = conductor;
579  }
580  else
581  {
582  conductor = conductor->Prev;
583  free(conductor->Next);
584  }
585 
586  // link the last node with the first one to make the list circular
587  conductor->Next = root;
588  root->Prev = conductor;
589  conductor = currentNode;
590 
591  free(codecInfo);
592 
593  return conductor;
594 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:624
#define free
Definition: debug_ros.c:5
struct _root root
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
struct SHIMGVW_FILENODE_INTERNAL * Next
Definition: shimgvw.h:21
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4946
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:4970
WCHAR FileName[MAX_PATH]
Definition: shimgvw.h:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
GLuint GLuint num
Definition: glext.h:9618
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct SHIMGVW_FILENODE_INTERNAL * Prev
Definition: shimgvw.h:20
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define malloc
Definition: debug_ros.c:4
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by ImageView_CreateWindow().

◆ pFreeFileList()

static VOID pFreeFileList ( SHIMGVW_FILENODE root)
static

Definition at line 597 of file shimgvw.c.

598 {
599  SHIMGVW_FILENODE *conductor;
600 
601  root->Prev->Next = NULL;
602  root->Prev = NULL;
603 
604  while (root)
605  {
606  conductor = root;
607  root = conductor->Next;
608  free(conductor);
609  }
610 }
#define free
Definition: debug_ros.c:5
struct _root root
struct SHIMGVW_FILENODE_INTERNAL * Next
Definition: shimgvw.h:21
smooth NULL
Definition: ftsmooth.c:416

Referenced by ImageView_CreateWindow().

◆ pLoadImage()

static void pLoadImage ( LPWSTR  szOpenFileName)
static

Definition at line 297 of file shimgvw.c.

298 {
299  /* check file presence */
300  if (GetFileAttributesW(szOpenFileName) == 0xFFFFFFFF)
301  {
302  DPRINT1("File %s not found!\n", szOpenFileName);
303  return;
304  }
305 
306  /* load now */
307  GdipLoadImageFromFile(szOpenFileName, &image);
308  if (!image)
309  {
310  DPRINT1("GdipLoadImageFromFile() failed\n");
311  return;
312  }
313  Anime_LoadInfo();
314 
315  if (szOpenFileName && szOpenFileName[0])
316  SHAddToRecentDocs(SHARD_PATHW, szOpenFileName);
317 
318  /* reset zoom */
319  ResetZoom();
320 
321  /* redraw */
323 }
#define TRUE
Definition: types.h:120
static void ResetZoom(void)
Definition: shimgvw.c:238
GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR *filename, GpImage **image)
Definition: image.c:2928
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:723
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
smooth NULL
Definition: ftsmooth.c:416
static BOOL Anime_LoadInfo(void)
Definition: shimgvw.c:76
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HWND hDispWnd
Definition: shimgvw.c:43
#define SHARD_PATHW
Definition: shlobj.h:1103
#define DPRINT1
Definition: precomp.h:8

Referenced by ImageView_CreateWindow(), and pLoadImageFromNode().

◆ pLoadImageFromNode()

static VOID pLoadImageFromNode ( SHIMGVW_FILENODE node,
HWND  hwnd 
)
static

Definition at line 447 of file shimgvw.c.

448 {
449  WCHAR szTitleBuf[800];
450  WCHAR szResStr[512];
451  LPWSTR pchFileTitle;
452 
453  if (image)
454  {
456  image = NULL;
457  }
458 
459  if (node == NULL)
460  {
462  return;
463  }
464 
465  pLoadImage(node->FileName);
466 
467  LoadStringW(hInstance, IDS_APPTITLE, szResStr, ARRAYSIZE(szResStr));
468  if (image != NULL)
469  {
470  pchFileTitle = PathFindFileNameW(node->FileName);
471  StringCbPrintfW(szTitleBuf, sizeof(szTitleBuf),
472  L"%ls%ls%ls", szResStr, L" - ", pchFileTitle);
473  SetWindowTextW(hwnd, szTitleBuf);
474  }
475  else
476  {
477  SetWindowTextW(hwnd, szResStr);
478  }
479 
481 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDS_APPTITLE
Definition: resource.h:3
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
static void pLoadImage(LPWSTR szOpenFileName)
Definition: shimgvw.c:297
HINSTANCE hInstance
Definition: shimgvw.c:37
static VOID EnableToolBarButtons(BOOL bEnable)
Definition: shimgvw.c:440
WCHAR * LPWSTR
Definition: xmlstorage.h:184
Definition: dlist.c:348

Referenced by ImageView_CreateWindow(), and ImageView_WndProc().

◆ pPrintImage()

static VOID pPrintImage ( HWND  hwnd)
static

Definition at line 434 of file shimgvw.c.

435 {
436  /* FIXME */
437 }

Referenced by ImageView_WndProc().

◆ pSaveImageAs()

static void pSaveImageAs ( HWND  hwnd)
static

Definition at line 325 of file shimgvw.c.

326 {
328  ImageCodecInfo *codecInfo;
329  WCHAR szSaveFileName[MAX_PATH];
330  WCHAR *szFilterMask;
331  GUID rawFormat;
332  UINT num;
333  UINT size;
334  size_t sizeRemain;
335  UINT j;
336  WCHAR *c;
337 
338  if (image == NULL)
339  return;
340 
342  codecInfo = malloc(size);
343  if (!codecInfo)
344  {
345  DPRINT1("malloc() failed in pSaveImageAs()\n");
346  return;
347  }
348 
349  GdipGetImageEncoders(num, size, codecInfo);
350  GdipGetImageRawFormat(image, &rawFormat);
351 
352  sizeRemain = 0;
353 
354  for (j = 0; j < num; ++j)
355  {
356  // 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.
357  sizeRemain = sizeRemain + (((wcslen(codecInfo[j].FormatDescription) + (wcslen(codecInfo[j].FilenameExtension) * 2) + 5) * sizeof(WCHAR)));
358  }
359 
360  /* Add two more chars for the last terminator */
361  sizeRemain = sizeRemain + (sizeof(WCHAR) * 2);
362 
363  szFilterMask = malloc(sizeRemain);
364  if (!szFilterMask)
365  {
366  DPRINT1("cannot allocate memory for filter mask in pSaveImageAs()");
367  free(codecInfo);
368  return;
369  }
370 
371  ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
372  ZeroMemory(szFilterMask, sizeRemain);
373  ZeroMemory(&sfn, sizeof(sfn));
374  sfn.lStructSize = sizeof(sfn);
375  sfn.hwndOwner = hwnd;
377  sfn.lpstrFile = szSaveFileName;
378  sfn.lpstrFilter = szFilterMask;
381 
382  c = szFilterMask;
383 
384  for (j = 0; j < num; ++j)
385  {
386  StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", codecInfo[j].FormatDescription, codecInfo[j].FilenameExtension);
387 
388  /* Skip the NULL character */
389  c++;
390  sizeRemain -= sizeof(*c);
391 
392  StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", codecInfo[j].FilenameExtension);
393 
394  /* Skip the NULL character */
395  c++;
396  sizeRemain -= sizeof(*c);
397 
398  if (IsEqualGUID(&rawFormat, &codecInfo[j].FormatID) != FALSE)
399  {
400  sfn.nFilterIndex = j + 1;
401  }
402  }
403 
404  if (GetSaveFileNameW(&sfn))
405  {
406  if (m_pDelayItem)
407  {
408  /* save animation */
410 
411  DPRINT1("FIXME: save animation\n");
412  if (GdipSaveImageToFile(image, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
413  {
414  DPRINT1("GdipSaveImageToFile() failed\n");
415  }
416 
418  }
419  else
420  {
421  /* save non-animation */
422  if (GdipSaveImageToFile(image, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
423  {
424  DPRINT1("GdipSaveImageToFile() failed\n");
425  }
426  }
427  }
428 
429  free(szFilterMask);
430  free(codecInfo);
431 }
HINSTANCE hInstance
Definition: commdlg.h:362
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD Flags
Definition: commdlg.h:373
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5021
LPCWSTR lpstrFilter
Definition: commdlg.h:363
#define free
Definition: debug_ros.c:5
LPWSTR lpstrFile
Definition: commdlg.h:367
#define ZeroMemory
Definition: winbase.h:1648
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
Definition: image.c:4428
#define ANIME_TIMER_ID
Definition: shimgvw.c:61
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4642
DWORD lStructSize
Definition: commdlg.h:360
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
Definition: image.c:2306
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
DWORD nFilterIndex
Definition: commdlg.h:366
GLsizeiptr size
Definition: glext.h:5919
OPENFILENAMEW sfn
Definition: eventvwr.c:118
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
const GLubyte * c
Definition: glext.h:8905
GLuint GLuint num
Definition: glext.h:9618
DWORD nMaxFile
Definition: commdlg.h:368
HWND hDispWnd
Definition: shimgvw.c:43
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HWND hwndOwner
Definition: commdlg.h:361
static const WCHAR L[]
Definition: oid.c:1250
PropertyItem * m_pDelayItem
Definition: shimgvw.c:59
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:4997
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
STRSAFEAPI StringCbPrintfExW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcbRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:623
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
HINSTANCE hInstance
Definition: shimgvw.c:37
#define DPRINT1
Definition: precomp.h:8
#define c
Definition: ke_i.h:80
#define malloc
Definition: debug_ros.c:4
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by ImageView_WndProc().

◆ ResetZoom()

static void ResetZoom ( void  )
static

Definition at line 238 of file shimgvw.c.

239 {
240  RECT Rect;
241  UINT ImageWidth, ImageHeight;
242 
243  if (image == NULL)
244  return;
245 
246  /* get disp window size and image size */
248  GdipGetImageWidth(image, &ImageWidth);
249  GdipGetImageHeight(image, &ImageHeight);
250 
251  /* compare two aspect rates. same as
252  (ImageHeight / ImageWidth < Rect.bottom / Rect.right) in real */
253  if (ImageHeight * Rect.right < Rect.bottom * ImageWidth)
254  {
255  if (Rect.right < ImageWidth)
256  {
257  /* it's large, shrink it */
258  ZoomPercents = (Rect.right * 100) / ImageWidth;
259  }
260  else
261  {
262  /* it's small. show as original size */
263  ZoomPercents = 100;
264  }
265  }
266  else
267  {
268  if (Rect.bottom < ImageHeight)
269  {
270  /* it's large, shrink it */
271  ZoomPercents = (Rect.bottom * 100) / ImageHeight;
272  }
273  else
274  {
275  /* it's small. show as original size */
276  ZoomPercents = 100;
277  }
278  }
279 }
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2342
UINT ZoomPercents
Definition: shimgvw.c:48
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2239
smooth NULL
Definition: ftsmooth.c:416
HWND hDispWnd
Definition: shimgvw.c:43
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
unsigned int UINT
Definition: ndis.h:50
struct Rect Rect

Referenced by ImageView_OnSize(), and pLoadImage().

◆ ZoomInOrOut()

static void ZoomInOrOut ( BOOL  bZoomIn)
static

Definition at line 185 of file shimgvw.c.

186 {
187  INT i;
188 
189  if (image == NULL)
190  return;
191 
192  if (bZoomIn) /* zoom in */
193  {
194  /* find next step */
195  for (i = 0; i < ARRAYSIZE(ZoomSteps); ++i)
196  {
197  if (ZoomPercents < ZoomSteps[i])
198  break;
199  }
200  if (i == ARRAYSIZE(ZoomSteps))
202  else
204 
205  /* update tool bar buttons */
207  if (ZoomPercents >= MAX_ZOOM)
209  else
211  }
212  else /* zoom out */
213  {
214  /* find previous step */
215  for (i = ARRAYSIZE(ZoomSteps); i > 0; )
216  {
217  --i;
218  if (ZoomSteps[i] < ZoomPercents)
219  break;
220  }
221  if (i < 0)
223  else
225 
226  /* update tool bar buttons */
228  if (ZoomPercents <= MIN_ZOOM)
230  else
232  }
233 
234  /* redraw */
236 }
#define TRUE
Definition: types.h:120
#define IDC_ZOOMM
Definition: resource.h:23
UINT ZoomPercents
Definition: shimgvw.c:48
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_ZOOM
Definition: shimgvw.c:47
int32_t INT
Definition: typedefs.h:57
static const UINT ZoomSteps[]
Definition: shimgvw.c:49
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TB_ENABLEBUTTON
Definition: commctrl.h:1038
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HWND hDispWnd
Definition: shimgvw.c:43
#define IDC_ZOOMP
Definition: resource.h:22
#define MIN_ZOOM
Definition: shimgvw.c:46
#define SendMessage
Definition: winuser.h:5818
HWND hToolBar
Definition: shimgvw.c:43

Referenced by ImageView_OnMouseWheel(), and ImageView_WndProc().

Variable Documentation

◆ Buttons

const TBBUTTON Buttons[]
static
Initial value:
=
{
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
}
#define TBICON_SAVE
Definition: resource.h:33
#define IDC_ZOOMM
Definition: resource.h:23
#define IDC_NEXT
Definition: fontview.h:17
#define IDC_ROT2
Definition: resource.h:27
#define IDC_SAVE
Definition: resource.h:16
#define TBICON_ROT2
Definition: resource.h:36
#define IDC_ROT1
Definition: resource.h:26
#define BTNS_BUTTON
Definition: commctrl.h:994
#define TBICON_PRINT
Definition: resource.h:34
#define BTNS_SEP
Definition: commctrl.h:995
#define IDC_PREV
Definition: fontview.h:16
#define TBICON_ZOOMM
Definition: resource.h:32
#define IDC_ZOOMP
Definition: resource.h:22
#define TBICON_PREV
Definition: resource.h:29
#define TBICON_ROT1
Definition: resource.h:35
#define TBICON_ZOOMP
Definition: resource.h:31
#define TBICON_NEXT
Definition: resource.h:30
#define TBSTATE_ENABLED
Definition: commctrl.h:970
#define IDC_PRINT
Definition: fontview.h:14

Definition at line 282 of file shimgvw.c.

Referenced by ImageView_CreateToolBar().

◆ currentFile

SHIMGVW_FILENODE* currentFile

Definition at line 39 of file shimgvw.c.

Referenced by ImageView_CreateWindow(), and ImageView_WndProc().

◆ hDispWnd

◆ hInstance

◆ hToolBar

HWND hToolBar

◆ image

Definition at line 40 of file shimgvw.c.

◆ m_nFrameCount

UINT m_nFrameCount = 0

◆ m_nFrameIndex

UINT m_nFrameIndex = 0

Definition at line 55 of file shimgvw.c.

Referenced by Anime_FreeInfo(), Anime_GetFrameDelay(), Anime_SetFrameIndex(), and Anime_Step().

◆ m_nLoopCount

UINT m_nLoopCount = (UINT)-1

Definition at line 58 of file shimgvw.c.

Referenced by Anime_FreeInfo(), Anime_LoadInfo(), and Anime_Step().

◆ m_nLoopIndex

UINT m_nLoopIndex = 0

Definition at line 57 of file shimgvw.c.

Referenced by Anime_FreeInfo(), and Anime_Step().

◆ m_pDelayItem

PropertyItem* m_pDelayItem = NULL

Definition at line 59 of file shimgvw.c.

Referenced by Anime_FreeInfo(), Anime_GetFrameDelay(), Anime_LoadInfo(), and pSaveImageAs().

◆ PrevProc

WNDPROC PrevProc = NULL

Definition at line 41 of file shimgvw.c.

Referenced by ImageView_DispWndProc(), ImageView_InitControls(), and ImageView_WndProc().

◆ shiSettings

◆ ZoomPercents

UINT ZoomPercents = 100

Definition at line 48 of file shimgvw.c.

Referenced by ImageView_DrawImage(), ResetZoom(), and ZoomInOrOut().

◆ ZoomSteps

const UINT ZoomSteps[]
static
Initial value:
=
{
10, 25, 50, 100, 200, 400, 800, 1600
}

Definition at line 49 of file shimgvw.c.

Referenced by ZoomInOrOut().