ReactOS  0.4.15-dev-2095-g7caf9e9
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.

Classes

struct  TB_BUTTON_CONFIG
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define INITGUID
 
#define NDEBUG
 
#define MIN_ZOOM   ZoomSteps[0]
 
#define MAX_ZOOM   ZoomSteps[_countof(ZoomSteps)-1]
 
#define DEFINE_BTN_INFO(_name)   { TBICON_##_name, IDC_##_name, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }
 
#define DEFINE_BTN_SEPARATOR   { 15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0 }
 
#define DEFINE_BTN_CONFIG(_name)   { IDB_##_name, IDS_TOOLTIP_##_name }
 
#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 (LPCWSTR 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 (VOID)
 
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, LPCWSTR 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 []
 
static const TBBUTTON Buttons []
 
static const TB_BUTTON_CONFIG BtnConfig []
 
UINT m_nFrameIndex = 0
 
UINT m_nFrameCount = 0
 
UINT m_nLoopIndex = 0
 
UINT m_nLoopCount = (UINT)-1
 
PropertyItemm_pDelayItem = NULL
 

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 120 of file shimgvw.c.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 11 of file shimgvw.c.

◆ DEFINE_BTN_CONFIG

#define DEFINE_BTN_CONFIG (   _name)    { IDB_##_name, IDS_TOOLTIP_##_name }

Definition at line 93 of file shimgvw.c.

◆ DEFINE_BTN_INFO

#define DEFINE_BTN_INFO (   _name)    { TBICON_##_name, IDC_##_name, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }

Definition at line 63 of file shimgvw.c.

◆ DEFINE_BTN_SEPARATOR

#define DEFINE_BTN_SEPARATOR   { 15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0 }

Definition at line 66 of file shimgvw.c.

◆ INITGUID

#define INITGUID

Definition at line 12 of file shimgvw.c.

◆ MAX_ZOOM

#define MAX_ZOOM   ZoomSteps[_countof(ZoomSteps)-1]

Definition at line 54 of file shimgvw.c.

◆ MIN_ZOOM

#define MIN_ZOOM   ZoomSteps[0]

Definition at line 53 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 122 of file shimgvw.c.

123 {
124  if (m_pDelayItem)
125  {
127  m_pDelayItem = NULL;
128  }
129  m_nFrameIndex = 0;
130  m_nFrameCount = 0;
131  m_nLoopIndex = 0;
132  m_nLoopCount = (UINT)-1;
133 }
#define free
Definition: debug_ros.c:5
UINT m_nLoopIndex
Definition: shimgvw.c:116
PropertyItem * m_pDelayItem
Definition: shimgvw.c:118
UINT m_nLoopCount
Definition: shimgvw.c:117
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
UINT m_nFrameIndex
Definition: shimgvw.c:114
UINT m_nFrameCount
Definition: shimgvw.c:115

Referenced by Anime_LoadInfo(), and ImageView_CreateWindow().

◆ Anime_GetFrameDelay()

DWORD Anime_GetFrameDelay ( UINT  nFrameIndex)

Definition at line 209 of file shimgvw.c.

210 {
211  if (nFrameIndex < m_nFrameCount && m_pDelayItem)
212  {
213  return ((DWORD *)m_pDelayItem->value)[m_nFrameIndex] * 10;
214  }
215  return 0;
216 }
unsigned long DWORD
Definition: ntddk_ex.h:95
PropertyItem * m_pDelayItem
Definition: shimgvw.c:118
UINT m_nFrameIndex
Definition: shimgvw.c:114
UINT m_nFrameCount
Definition: shimgvw.c:115

Referenced by Anime_Step().

◆ Anime_LoadInfo()

static BOOL Anime_LoadInfo ( void  )
static

Definition at line 135 of file shimgvw.c.

136 {
137  GUID *dims;
138  UINT nDimCount = 0;
139  UINT cbItem;
140  UINT result;
141  PropertyItem *pItem;
142 
143  Anime_FreeInfo();
145 
146  if (!image)
147  return FALSE;
148 
150  if (nDimCount)
151  {
152  dims = (GUID *)calloc(nDimCount, sizeof(GUID));
153  if (dims)
154  {
155  GdipImageGetFrameDimensionsList(image, dims, nDimCount);
158  free(dims);
159  }
160  }
161 
162  result = 0;
164  cbItem = result;
165  if (cbItem)
166  {
167  m_pDelayItem = (PropertyItem *)malloc(cbItem);
169  }
170 
171  result = 0;
173  cbItem = result;
174  if (cbItem)
175  {
176  pItem = (PropertyItem *)malloc(cbItem);
177  if (pItem)
178  {
179  if (GdipGetPropertyItem(image, PropertyTagLoopCount, cbItem, pItem) == Ok)
180  {
181  m_nLoopCount = *(WORD *)pItem->value;
182  }
183  free(pItem);
184  }
185  }
186 
187  if (m_pDelayItem)
188  {
190  }
191 
192  return m_pDelayItem != NULL;
193 }
#define PropertyTagLoopCount
GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GDIPCONST GUID *dimensionID, UINT *count)
Definition: image.c:2865
GLuint64EXT * result
Definition: glext.h:11304
#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:120
#define FALSE
Definition: types.h:117
#define PropertyTagFrameDelay
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
static void Anime_FreeInfo(void)
Definition: shimgvw.c:122
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:118
UINT m_nLoopCount
Definition: shimgvw.c:117
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:115

Referenced by pLoadImage().

◆ Anime_SetFrameIndex()

static void Anime_SetFrameIndex ( UINT  nFrameIndex)
static

Definition at line 195 of file shimgvw.c.

196 {
197  if (nFrameIndex < m_nFrameCount)
198  {
199  GUID guid = FrameDimensionTime;
200  if (Ok != GdipImageSelectActiveFrame(image, &guid, nFrameIndex))
201  {
202  guid = FrameDimensionPage;
203  GdipImageSelectActiveFrame(image, &guid, nFrameIndex);
204  }
205  }
206  m_nFrameIndex = nFrameIndex;
207 }
const GUID * guid
GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *dimensionID, UINT frame)
Definition: image.c:4302
UINT m_nFrameIndex
Definition: shimgvw.c:114
UINT m_nFrameCount
Definition: shimgvw.c:115

Referenced by Anime_Step().

◆ Anime_Step()

BOOL Anime_Step ( DWORD pdwDelay)

Definition at line 218 of file shimgvw.c.

219 {
220  *pdwDelay = INFINITE;
221  if (m_nLoopCount == (UINT)-1)
222  return FALSE;
223 
224  if (m_nFrameIndex + 1 < m_nFrameCount)
225  {
226  *pdwDelay = Anime_GetFrameDelay(m_nFrameIndex);
228  ++m_nFrameIndex;
229  return TRUE;
230  }
231 
232  if (m_nLoopCount == 0 || m_nLoopIndex < m_nLoopCount)
233  {
234  *pdwDelay = Anime_GetFrameDelay(m_nFrameIndex);
236  m_nFrameIndex = 0;
237  ++m_nLoopIndex;
238  return TRUE;
239  }
240 
241  return FALSE;
242 }
#define TRUE
Definition: types.h:120
UINT m_nLoopIndex
Definition: shimgvw.c:116
#define FALSE
Definition: types.h:117
DWORD Anime_GetFrameDelay(UINT nFrameIndex)
Definition: shimgvw.c:209
static void Anime_SetFrameIndex(UINT nFrameIndex)
Definition: shimgvw.c:195
UINT m_nLoopCount
Definition: shimgvw.c:117
unsigned int UINT
Definition: ndis.h:50
UINT m_nFrameIndex
Definition: shimgvw.c:114
UINT m_nFrameCount
Definition: shimgvw.c:115
#define INFINITE
Definition: serial.h:102

Referenced by ImageView_OnTimer().

◆ CreateCheckerBoardBrush()

static HBRUSH CreateCheckerBoardBrush ( HDC  hdc)
static

Definition at line 665 of file shimgvw.c.

666 {
667  static const CHAR pattern[] =
668  "\x28\x00\x00\x00\x10\x00\x00\x00\x10\x00\x00\x00\x01\x00\x04\x00\x00\x00"
669  "\x00\x00\x80\x00\x00\x00\x23\x2E\x00\x00\x23\x2E\x00\x00\x10\x00\x00\x00"
670  "\x00\x00\x00\x00\x99\x99\x99\x00\xCC\xCC\xCC\x00\x00\x00\x00\x00\x00\x00"
671  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
672  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
673  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11\x11\x11"
674  "\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00"
675  "\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00"
676  "\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11"
677  "\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00"
678  "\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11"
679  "\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11"
680  "\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11";
681 
683 }
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:132
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: shimgvw.c:37

◆ EnableToolBarButtons()

static VOID EnableToolBarButtons ( BOOL  bEnable)
static

Definition at line 483 of file shimgvw.c.

484 {
487 }
#define TB_ENABLEBUTTON
Definition: commctrl.h:1038
#define IDC_SAVEAS
Definition: resource.h:17
_In_ BOOL bEnable
Definition: winddi.h:3426
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
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 843 of file shimgvw.c.

844 {
847  0, 0, 0, 0, hwnd,
848  0, hInstance, NULL);
849  if (hToolBar != NULL)
850  {
851  HIMAGELIST hImageList;
852 
855 
857  sizeof(Buttons[0]), 0);
858 
860  if (hImageList == NULL) return FALSE;
861 
862  for (UINT n = 0; n < _countof(BtnConfig); n++)
863  {
866  }
867 
869  0, (LPARAM)hImageList));
870 
872 
873  return TRUE;
874  }
875 
876  return FALSE;
877 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1130
#define TBSTYLE_EX_HIDECLIPPEDBUTTONS
Definition: commctrl.h:1009
#define RGB(r, g, b)
Definition: precomp.h:62
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729
static const TB_BUTTON_CONFIG BtnConfig[]
Definition: shimgvw.c:95
#define WS_CHILD
Definition: pedump.c:617
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 FALSE
Definition: types.h:117
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define TB_IMAGE_HEIGHT
Definition: shimgvw.h:4
#define CreateWindowEx
Definition: winuser.h:5730
#define TOOLBARCLASSNAME
Definition: commctrl.h:942
LONG_PTR LPARAM
Definition: windef.h:208
#define CCS_BOTTOM
Definition: commctrl.h:2240
#define TB_SETIMAGELIST
Definition: commctrl.h:1146
#define _countof(array)
Definition: sndvol32.h:68
#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
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
HINSTANCE hInstance
Definition: shimgvw.c:37
#define TB_IMAGE_WIDTH
Definition: shimgvw.h:3
HWND hToolBar
Definition: shimgvw.c:43
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static const TBBUTTON Buttons[]
Definition: shimgvw.c:70
#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,
LPCWSTR  szFileName 
)

Definition at line 1087 of file shimgvw.c.

1088 {
1091  WNDCLASSW WndClass = {0};
1092  WCHAR szBuf[512];
1093  WCHAR szInitialFile[MAX_PATH];
1094  HWND hMainWnd;
1095  MSG msg;
1096  HACCEL hKbdAccel;
1097  INITCOMMONCONTROLSEX Icc = { .dwSize = sizeof(Icc), .dwICC = ICC_WIN95_CLASSES };
1098 
1099  InitCommonControlsEx(&Icc);
1100 
1101  if (!ImageView_LoadSettings())
1102  {
1104  shiSettings.Left = 0;
1105  shiSettings.Top = 0;
1106  shiSettings.Right = 520;
1107  shiSettings.Bottom = 400;
1108  }
1109 
1110  // Initialize GDI+
1111  gdiplusStartupInput.GdiplusVersion = 1;
1112  gdiplusStartupInput.DebugEventCallback = NULL;
1113  gdiplusStartupInput.SuppressBackgroundThread = FALSE;
1114  gdiplusStartupInput.SuppressExternalCodecs = FALSE;
1115 
1117  pLoadImage(szFileName);
1118 
1119  // Create the window
1120  WndClass.lpszClassName = L"shimgvw_window";
1121  WndClass.lpfnWndProc = ImageView_WndProc;
1122  WndClass.hInstance = hInstance;
1123  WndClass.style = CS_HREDRAW | CS_VREDRAW;
1125  WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
1126  WndClass.hbrBackground = NULL; /* less flicker */
1127 
1128  if (!RegisterClassW(&WndClass)) return -1;
1129 
1130  LoadStringW(hInstance, IDS_APPTITLE, szBuf, _countof(szBuf));
1131  hMainWnd = CreateWindowExW(0, L"shimgvw_window", szBuf,
1134  0, 0, NULL, NULL, hInstance, NULL);
1135 
1136  // make sure the path has no quotes on it
1137  StringCbCopyW(szInitialFile, sizeof(szInitialFile), szFileName);
1138  PathUnquoteSpacesW(szInitialFile);
1139 
1140  currentFile = pBuildFileList(szInitialFile);
1141  if (currentFile)
1142  {
1144  }
1145 
1146  /* Create accelerator table for keystrokes */
1148 
1149  // Show it
1152 
1153  // Message Loop
1154  for (;;)
1155  {
1156  if (GetMessageW(&msg, NULL, 0, 0) <= 0)
1157  break;
1158 
1159  if (!TranslateAcceleratorW(hMainWnd, hKbdAccel, &msg))
1160  {
1163  }
1164  }
1165 
1166  /* Destroy accelerator table */
1167  DestroyAcceleratorTable(hKbdAccel);
1168 
1170 
1171  if (image)
1172  {
1174  image = NULL;
1175  }
1176 
1177  Anime_FreeInfo();
1178 
1180  return -1;
1181 }
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#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)
static BOOL ImageView_LoadSettings(VOID)
Definition: shimgvw.c:801
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
uint32_t ULONG_PTR
Definition: typedefs.h:65
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
BOOL Maximized
Definition: shimgvw.h:10
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
LRESULT CALLBACK ImageView_WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:963
#define CW_USEDEFAULT
Definition: winuser.h:225
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
static SHIMGVW_FILENODE * pBuildFileList(LPWSTR szFirstFile)
Definition: shimgvw.c:527
#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:122
#define CS_VREDRAW
Definition: winuser.h:653
static VOID pLoadImageFromNode(SHIMGVW_FILENODE *node, HWND hwnd)
Definition: shimgvw.c:490
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
void WINAPI GdiplusShutdown(ULONG_PTR)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
HWND hMainWnd
Definition: magnifier.c:32
static const WCHAR L[]
Definition: oid.c:1250
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
static VOID pFreeFileList(SHIMGVW_FILENODE *root)
Definition: shimgvw.c:640
#define LoadCursor
Definition: winuser.h:5787
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Gdiplus::GdiplusStartupInput gdiplusStartupInput
Definition: winmain.cpp:33
BOOL WINAPI DestroyAcceleratorTable(_In_ HACCEL)
ULONG_PTR gdiplusToken
Definition: winmain.cpp:34
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1029
#define NULL
Definition: types.h:112
HINSTANCE hInstance
Definition: shimgvw.c:37
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define IDR_ACCELERATOR
Definition: resource.h:91
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define IDI_APP_ICON
Definition: resource.h:4
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define WS_VISIBLE
Definition: pedump.c:620
static void pLoadImage(LPCWSTR szOpenFileName)
Definition: shimgvw.c:340
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 893 of file shimgvw.c.

894 {
895  switch (Message)
896  {
897  case WM_PAINT:
898  {
900  return 0L;
901  }
902  case WM_TIMER:
903  {
904  if (wParam == ANIME_TIMER_ID)
905  {
907  return 0;
908  }
909  break;
910  }
911  }
913 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WNDPROC PrevProc
Definition: shimgvw.c:41
#define ANIME_TIMER_ID
Definition: shimgvw.c:120
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:686
static void ImageView_OnTimer(HWND hwnd)
Definition: shimgvw.c:879
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPARAM lParam
Definition: combotst.c:139

Referenced by ImageView_InitControls().

◆ ImageView_DrawImage()

static VOID ImageView_DrawImage ( HWND  hwnd)
static

Definition at line 686 of file shimgvw.c.

687 {
688  GpGraphics *graphics;
689  UINT ImageWidth, ImageHeight;
690  INT ZoomedWidth, ZoomedHeight, x, y;
691  PAINTSTRUCT ps;
692  RECT rect, margin;
693  HDC hdc;
694  HBRUSH white;
695  HGDIOBJ hbrOld;
696  UINT uFlags;
697  WCHAR szText[128];
698  HGDIOBJ hFontOld;
699 
700  hdc = BeginPaint(hwnd, &ps);
701  if (!hdc)
702  {
703  DPRINT1("BeginPaint() failed\n");
704  return;
705  }
706 
707  GdipCreateFromHDC(hdc, &graphics);
708  if (!graphics)
709  {
710  DPRINT1("GdipCreateFromHDC() failed\n");
711  return;
712  }
713 
715  white = GetStockObject(WHITE_BRUSH);
716 
717  if (image == NULL)
718  {
719  FillRect(hdc, &rect, white);
720 
722 
723  SetTextColor(hdc, RGB(0, 0, 0));
725 
728  DT_NOPREFIX);
729  SelectObject(hdc, hFontOld);
730  }
731  else
732  {
733  GdipGetImageWidth(image, &ImageWidth);
734  GdipGetImageHeight(image, &ImageHeight);
735 
736  ZoomedWidth = (ImageWidth * ZoomPercents) / 100;
737  ZoomedHeight = (ImageHeight * ZoomPercents) / 100;
738 
739  x = (rect.right - ZoomedWidth) / 2;
740  y = (rect.bottom - ZoomedHeight) / 2;
741 
742  // Fill top part
743  margin = rect;
744  margin.bottom = y - 1;
745  FillRect(hdc, &margin, white);
746  // Fill bottom part
747  margin.top = y + ZoomedHeight + 1;
748  margin.bottom = rect.bottom;
749  FillRect(hdc, &margin, white);
750  // Fill left part
751  margin.top = y - 1;
752  margin.bottom = y + ZoomedHeight + 1;
753  margin.right = x - 1;
754  FillRect(hdc, &margin, white);
755  // Fill right part
756  margin.left = x + ZoomedWidth + 1;
757  margin.right = rect.right;
758  FillRect(hdc, &margin, white);
759 
760  DPRINT("x = %d, y = %d, ImageWidth = %u, ImageHeight = %u\n");
761  DPRINT("rect.right = %ld, rect.bottom = %ld\n", rect.right, rect.bottom);
762  DPRINT("ZoomPercents = %d, ZoomedWidth = %d, ZoomedHeight = %d\n",
763  ZoomPercents, ZoomedWidth, ZoomedWidth);
764 
765  if (ZoomPercents % 100 == 0)
766  {
769  }
770  else
771  {
774  }
775 
776  uFlags = 0;
778 
780  {
781  HBRUSH hbr = CreateCheckerBoardBrush(hdc);
782  hbrOld = SelectObject(hdc, hbr);
783  Rectangle(hdc, x - 1, y - 1, x + ZoomedWidth + 1, y + ZoomedHeight + 1);
784  SelectObject(hdc, hbrOld);
785  DeleteObject(hbr);
786  }
787  else
788  {
790  Rectangle(hdc, x - 1, y - 1, x + ZoomedWidth + 1, y + ZoomedHeight + 1);
791  SelectObject(hdc, hbrOld);
792  }
793 
794  GdipDrawImageRectI(graphics, image, x, y, ZoomedWidth, ZoomedHeight);
795  }
796  GdipDeleteGraphics(graphics);
797  EndPaint(hwnd, &ps);
798 }
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:46
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
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:58
& rect
Definition: startmenu.cpp:1413
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
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
#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 _countof(array)
Definition: sndvol32.h:68
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
HDC hdc
Definition: main.c:9
static HBRUSH CreateCheckerBoardBrush(HDC hdc)
Definition: shimgvw.c:665
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
#define NULL
Definition: types.h:112
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
#define DPRINT
Definition: sndvol32.h:71
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define IDS_NOPREVIEW
Definition: resource.h:62
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, LPCWSTR szFileName)
Definition: shimgvw.c:1087

◆ 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, path, -1, szFile, _countof(szFile)))
1201  {
1202  ImageView_CreateWindow(hwnd, szFile);
1203  }
1204 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG WINAPI ImageView_CreateWindow(HWND hwnd, LPCWSTR szFileName)
Definition: shimgvw.c:1087
#define CP_ACP
Definition: compat.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define MultiByteToWideChar
Definition: compat.h:110

◆ 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, LPCWSTR szFileName)
Definition: shimgvw.c:1087

◆ ImageView_InitControls()

static VOID ImageView_InitControls ( HWND  hwnd)
static

Definition at line 916 of file shimgvw.c.

917 {
921 
923 
926  0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
927 
930 
932 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
WNDPROC PrevProc
Definition: shimgvw.c:41
#define TRUE
Definition: types.h:120
#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:893
#define SetWindowLongPtr
Definition: treelist.c:70
static BOOL ImageView_CreateToolBar(HWND hwnd)
Definition: shimgvw.c:843
#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
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
#define NULL
Definition: types.h:112
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 ( VOID  )
static

Definition at line 801 of file shimgvw.c.

802 {
803  HKEY hKey;
804  DWORD dwSize;
805  LONG nError;
806 
807  nError = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\shimgvw", 0, KEY_READ, &hKey);
808  if (nError)
809  return FALSE;
810 
811  dwSize = sizeof(shiSettings);
812  nError = RegQueryValueExW(hKey, L"Settings", NULL, NULL, (LPBYTE)&shiSettings, &dwSize);
813  RegCloseKey(hKey);
814 
815  return !nError;
816 }
SHIMGVW_SETTINGS shiSettings
Definition: shimgvw.c:38
#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
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
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 935 of file shimgvw.c.

936 {
937  if (zDelta != 0)
938  {
939  ZoomInOrOut(zDelta > 0);
940  }
941 }
static void ZoomInOrOut(BOOL bZoomIn)
Definition: shimgvw.c:244

Referenced by ImageView_WndProc().

◆ ImageView_OnSize()

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

Definition at line 944 of file shimgvw.c.

945 {
946  RECT rc;
947 
949 
950  GetWindowRect(hToolBar, &rc);
951 
952  MoveWindow(hDispWnd, 0, 0, cx, cy - (rc.bottom - rc.top), TRUE);
953 
954  /* is it maximized or restored? */
956  {
957  /* reset zoom */
958  ResetZoom();
959  }
960 }
static void ResetZoom(void)
Definition: shimgvw.c:297
#define SIZE_MAXIMIZED
Definition: winuser.h:2482
#define TRUE
Definition: types.h:120
#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)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_Out_opt_ int * cx
Definition: commctrl.h:581
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 879 of file shimgvw.c.

880 {
881  DWORD dwDelay;
882 
885 
886  if (Anime_Step(&dwDelay))
887  {
888  SetTimer(hwnd, ANIME_TIMER_ID, dwDelay, NULL);
889  }
890 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL Anime_Step(DWORD *pdwDelay)
Definition: shimgvw.c:218
#define ANIME_TIMER_ID
Definition: shimgvw.c:120
#define FALSE
Definition: types.h:117
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)
#define NULL
Definition: types.h:112

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 }
#define DPRINT
Definition: sndvol32.h:71

◆ 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 }
#define DPRINT
Definition: sndvol32.h:71

◆ 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 }
#define DPRINT
Definition: sndvol32.h:71

◆ ImageView_SaveSettings()

static VOID ImageView_SaveSettings ( HWND  hwnd)
static

Definition at line 819 of file shimgvw.c.

820 {
821  WINDOWPLACEMENT wp;
822  HKEY hKey;
823 
825  wp.length = sizeof(WINDOWPLACEMENT);
826  GetWindowPlacement(hwnd, &wp);
827 
833 
834  if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, NULL,
836  {
837  RegSetValueEx(hKey, _T("Settings"), 0, REG_BINARY, (LPBYTE)&shiSettings, sizeof(SHIMGVW_SETTINGS));
838  RegCloseKey(hKey);
839  }
840 }
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
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
FxAutoRegKey hKey
BOOL WINAPI IsZoomed(_In_ HWND)
#define NULL
Definition: types.h:112
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 659 of file shimgvw.c.

660 {
663 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI UpdateWindow(_In_ HWND)
#define FALSE
Definition: types.h:117
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define NULL
Definition: types.h:112

Referenced by ImageView_WndProc().

◆ ImageView_WndProc()

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

Definition at line 963 of file shimgvw.c.

964 {
965  switch (Message)
966  {
967  case WM_CREATE:
968  {
970  return 0L;
971  }
972 
973  case WM_COMMAND:
974  {
975  switch (LOWORD(wParam))
976  {
977  case IDC_PREV_PIC:
980  break;
981 
982  case IDC_NEXT_PIC:
985  break;
986 
987  case IDC_BEST_FIT:
988  DPRINT1("IDC_BEST_FIT unimplemented\n");
989  break;
990 
991  case IDC_REAL_SIZE:
992  DPRINT1("IDC_REAL_SIZE unimplemented\n");
993  break;
994 
995  case IDC_SLIDE_SHOW:
996  DPRINT1("IDC_SLIDE_SHOW unimplemented\n");
997  break;
998 
999  case IDC_ZOOM_IN:
1000  ZoomInOrOut(TRUE);
1001  break;
1002 
1003  case IDC_ZOOM_OUT:
1004  ZoomInOrOut(FALSE);
1005  break;
1006 
1007  case IDC_SAVEAS:
1008  pSaveImageAs(hwnd);
1009  break;
1010 
1011  case IDC_PRINT:
1012  pPrintImage(hwnd);
1013  break;
1014 
1015  case IDC_ROT_CLOCKW:
1016  if (image)
1017  {
1020  }
1021  break;
1022 
1023  case IDC_ROT_COUNCW:
1024  if (image)
1025  {
1028  }
1029  break;
1030  }
1031  }
1032  break;
1033 
1034  case WM_MOUSEWHEEL:
1038  break;
1039 
1040  case WM_NOTIFY:
1041  {
1042  LPNMHDR pnmhdr = (LPNMHDR)lParam;
1043 
1044  switch (pnmhdr->code)
1045  {
1046  case TTN_GETDISPINFO:
1047  {
1048  LPTOOLTIPTEXTW lpttt;
1049 
1050  lpttt = (LPTOOLTIPTEXTW)lParam;
1051  lpttt->hinst = hInstance;
1052 
1053  lpttt->lpszText = MAKEINTRESOURCEW(BtnConfig[lpttt->hdr.idFrom - IDC_TOOL_BASE].ids);
1054  return TRUE;
1055  }
1056  }
1057  break;
1058  }
1059  case WM_SIZING:
1060  {
1061  LPRECT pRect = (LPRECT)lParam;
1062  if (pRect->right-pRect->left < 350)
1063  pRect->right = pRect->left + 350;
1064 
1065  if (pRect->bottom-pRect->top < 290)
1066  pRect->bottom = pRect->top + 290;
1067  return TRUE;
1068  }
1069  case WM_SIZE:
1070  {
1072  return 0;
1073  }
1074  case WM_DESTROY:
1075  {
1078  PostQuitMessage(0);
1079  break;
1080  }
1081  }
1082 
1084 }
#define IDC_ROT_CLOCKW
Definition: resource.h:36
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WNDPROC PrevProc
Definition: shimgvw.c:41
#define IDC_ZOOM_OUT
Definition: resource.h:35
#define TRUE
Definition: types.h:120
#define IDC_REAL_SIZE
Definition: resource.h:32
#define WM_MOUSEWHEEL
Definition: treelist.c:96
LONG top
Definition: windef.h:307
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static const TB_BUTTON_CONFIG BtnConfig[]
Definition: shimgvw.c:95
LONG left
Definition: windef.h:306
struct SHIMGVW_FILENODE_INTERNAL * Next
Definition: shimgvw.h:21
LONG right
Definition: windef.h:308
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_TOOL_BASE
Definition: resource.h:27
UINT code
Definition: winuser.h:3134
GpStatus WINGDIPAPI GdipImageRotateFlip(GpImage *image, RotateFlipType type)
Definition: image.c:5358
#define FALSE
Definition: types.h:117
short SHORT
Definition: pedump.c:59
static VOID pPrintImage(HWND hwnd)
Definition: shimgvw.c:477
#define TTN_GETDISPINFO
Definition: commctrl.h:1874
#define IDC_ROT_COUNCW
Definition: resource.h:37
#define WM_SIZING
Definition: winuser.h:1789
LONG_PTR LPARAM
Definition: windef.h:208
#define LPRECT
Definition: precomp.h:28
#define IDC_ZOOM_IN
Definition: resource.h:34
static VOID ImageView_UpdateWindow(HWND hwnd)
Definition: shimgvw.c:659
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_SAVEAS
Definition: resource.h:17
SHIMGVW_FILENODE * currentFile
Definition: shimgvw.c:39
static VOID pLoadImageFromNode(SHIMGVW_FILENODE *node, HWND hwnd)
Definition: shimgvw.c:490
#define WM_SIZE
Definition: winuser.h:1593
#define IDC_SLIDE_SHOW
Definition: resource.h:33
static void ZoomInOrOut(BOOL bZoomIn)
Definition: shimgvw.c:244
#define LPTOOLTIPTEXTW
Definition: commctrl.h:1883
HWND hDispWnd
Definition: shimgvw.c:43
CHAR Message[80]
Definition: alive.c:5
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:935
static VOID ImageView_OnSize(HWND hwnd, UINT state, INT cx, INT cy)
Definition: shimgvw.c:944
#define WM_COMMAND
Definition: winuser.h:1722
#define GWLP_WNDPROC
Definition: treelist.c:66
struct SHIMGVW_FILENODE_INTERNAL * Prev
Definition: shimgvw.h:20
#define IDC_NEXT_PIC
Definition: resource.h:30
#define IDC_BEST_FIT
Definition: resource.h:31
unsigned int UINT
Definition: ndis.h:50
HINSTANCE hInstance
Definition: shimgvw.c:37
#define DPRINT1
Definition: precomp.h:8
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define IDC_PREV_PIC
Definition: resource.h:29
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:247
static void pSaveImageAs(HWND hwnd)
Definition: shimgvw.c:368
LONG bottom
Definition: windef.h:309
static VOID ImageView_InitControls(HWND hwnd)
Definition: shimgvw.c:916
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static VOID ImageView_SaveSettings(HWND hwnd)
Definition: shimgvw.c:819
#define IDC_PRINT
Definition: fontview.h:14
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by ImageView_CreateWindow().

◆ pBuildFileList()

static SHIMGVW_FILENODE* pBuildFileList ( LPWSTR  szFirstFile)
static

Definition at line 527 of file shimgvw.c.

528 {
529  HANDLE hFindHandle;
530  WCHAR *extension;
531  WCHAR szSearchPath[MAX_PATH];
532  WCHAR szSearchMask[MAX_PATH];
533  WCHAR szFileTypes[MAX_PATH];
534  WIN32_FIND_DATAW findData;
535  SHIMGVW_FILENODE *currentNode = NULL;
537  SHIMGVW_FILENODE *conductor = NULL;
538  ImageCodecInfo *codecInfo;
539  UINT num;
540  UINT size;
541  UINT j;
542 
543  StringCbCopyW(szSearchPath, sizeof(szSearchPath), szFirstFile);
544  PathRemoveFileSpecW(szSearchPath);
545 
547  codecInfo = malloc(size);
548  if (!codecInfo)
549  {
550  DPRINT1("malloc() failed in pLoadFileList()\n");
551  return NULL;
552  }
553 
554  GdipGetImageDecoders(num, size, codecInfo);
555 
556  root = malloc(sizeof(SHIMGVW_FILENODE));
557  if (!root)
558  {
559  DPRINT1("malloc() failed in pLoadFileList()\n");
560  free(codecInfo);
561  return NULL;
562  }
563 
564  conductor = root;
565 
566  for (j = 0; j < num; ++j)
567  {
568  StringCbCopyW(szFileTypes, sizeof(szFileTypes), codecInfo[j].FilenameExtension);
569 
570  extension = wcstok(szFileTypes, L";");
571  while (extension != NULL)
572  {
573  PathCombineW(szSearchMask, szSearchPath, extension);
574 
575  hFindHandle = FindFirstFileW(szSearchMask, &findData);
576  if (hFindHandle != INVALID_HANDLE_VALUE)
577  {
578  do
579  {
580  PathCombineW(conductor->FileName, szSearchPath, findData.cFileName);
581 
582  // compare the name of the requested file with the one currently found.
583  // if the name matches, the current node is returned by the function.
584  if (wcscmp(szFirstFile, conductor->FileName) == 0)
585  {
586  currentNode = conductor;
587  }
588 
589  conductor->Next = malloc(sizeof(SHIMGVW_FILENODE));
590 
591  // if malloc fails, make circular what we have and return it
592  if (!conductor->Next)
593  {
594  DPRINT1("malloc() failed in pLoadFileList()\n");
595 
596  conductor->Next = root;
597  root->Prev = conductor;
598 
599  FindClose(hFindHandle);
600  free(codecInfo);
601  return conductor;
602  }
603 
604  conductor->Next->Prev = conductor;
605  conductor = conductor->Next;
606  }
607  while (FindNextFileW(hFindHandle, &findData) != 0);
608 
609  FindClose(hFindHandle);
610  }
611 
612  extension = wcstok(NULL, L";");
613  }
614  }
615 
616  // we now have a node too much in the list. In case the requested file was not found,
617  // we use this node to store the name of it, otherwise we free it.
618  if (currentNode == NULL)
619  {
620  StringCchCopyW(conductor->FileName, MAX_PATH, szFirstFile);
621  currentNode = conductor;
622  }
623  else
624  {
625  conductor = conductor->Prev;
626  free(conductor->Next);
627  }
628 
629  // link the last node with the first one to make the list circular
630  conductor->Next = root;
631  root->Prev = conductor;
632  conductor = currentNode;
633 
634  free(codecInfo);
635 
636  return conductor;
637 }
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:590
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
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:34
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 NULL
Definition: types.h:112
#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 640 of file shimgvw.c.

641 {
642  SHIMGVW_FILENODE *conductor;
643 
644  if (!root)
645  return;
646 
647  root->Prev->Next = NULL;
648  root->Prev = NULL;
649 
650  while (root)
651  {
652  conductor = root;
653  root = conductor->Next;
654  free(conductor);
655  }
656 }
#define free
Definition: debug_ros.c:5
struct _root root
struct SHIMGVW_FILENODE_INTERNAL * Next
Definition: shimgvw.h:21
#define NULL
Definition: types.h:112

Referenced by ImageView_CreateWindow().

◆ pLoadImage()

static void pLoadImage ( LPCWSTR  szOpenFileName)
static

Definition at line 340 of file shimgvw.c.

341 {
342  /* check file presence */
343  if (GetFileAttributesW(szOpenFileName) == 0xFFFFFFFF)
344  {
345  DPRINT1("File %s not found!\n", szOpenFileName);
346  return;
347  }
348 
349  /* load now */
350  GdipLoadImageFromFile(szOpenFileName, &image);
351  if (!image)
352  {
353  DPRINT1("GdipLoadImageFromFile() failed\n");
354  return;
355  }
356  Anime_LoadInfo();
357 
358  if (szOpenFileName && szOpenFileName[0])
359  SHAddToRecentDocs(SHARD_PATHW, szOpenFileName);
360 
361  /* reset zoom */
362  ResetZoom();
363 
364  /* redraw */
366 }
static void ResetZoom(void)
Definition: shimgvw.c:297
GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR *filename, GpImage **image)
Definition: image.c:2928
#define TRUE
Definition: types.h:120
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:809
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
static BOOL Anime_LoadInfo(void)
Definition: shimgvw.c:135
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 NULL
Definition: types.h:112
#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 490 of file shimgvw.c.

491 {
492  WCHAR szTitleBuf[800];
493  WCHAR szResStr[512];
494  LPWSTR pchFileTitle;
495 
496  if (image)
497  {
499  image = NULL;
500  }
501 
502  if (node == NULL)
503  {
505  return;
506  }
507 
508  pLoadImage(node->FileName);
509 
510  LoadStringW(hInstance, IDS_APPTITLE, szResStr, _countof(szResStr));
511  if (image != NULL)
512  {
513  pchFileTitle = PathFindFileNameW(node->FileName);
514  StringCbPrintfW(szTitleBuf, sizeof(szTitleBuf),
515  L"%ls%ls%ls", szResStr, L" - ", pchFileTitle);
516  SetWindowTextW(hwnd, szTitleBuf);
517  }
518  else
519  {
520  SetWindowTextW(hwnd, szResStr);
521  }
522 
524 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDS_APPTITLE
Definition: resource.h:3
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)
#define FALSE
Definition: types.h:117
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
#define _countof(array)
Definition: sndvol32.h:68
static const WCHAR L[]
Definition: oid.c:1250
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
#define NULL
Definition: types.h:112
HINSTANCE hInstance
Definition: shimgvw.c:37
static VOID EnableToolBarButtons(BOOL bEnable)
Definition: shimgvw.c:483
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void pLoadImage(LPCWSTR szOpenFileName)
Definition: shimgvw.c:340
Definition: dlist.c:348

Referenced by ImageView_CreateWindow(), and ImageView_WndProc().

◆ pPrintImage()

static VOID pPrintImage ( HWND  hwnd)
static

Definition at line 477 of file shimgvw.c.

478 {
479  /* FIXME */
480 }

Referenced by ImageView_WndProc().

◆ pSaveImageAs()

static void pSaveImageAs ( HWND  hwnd)
static

Definition at line 368 of file shimgvw.c.

369 {
371  ImageCodecInfo *codecInfo;
372  WCHAR szSaveFileName[MAX_PATH];
373  WCHAR *szFilterMask;
374  GUID rawFormat;
375  UINT num;
376  UINT size;
377  size_t sizeRemain;
378  UINT j;
379  WCHAR *c;
380 
381  if (image == NULL)
382  return;
383 
385  codecInfo = malloc(size);
386  if (!codecInfo)
387  {
388  DPRINT1("malloc() failed in pSaveImageAs()\n");
389  return;
390  }
391 
392  GdipGetImageEncoders(num, size, codecInfo);
393  GdipGetImageRawFormat(image, &rawFormat);
394 
395  sizeRemain = 0;
396 
397  for (j = 0; j < num; ++j)
398  {
399  // 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.
400  sizeRemain = sizeRemain + (((wcslen(codecInfo[j].FormatDescription) + (wcslen(codecInfo[j].FilenameExtension) * 2) + 5) * sizeof(WCHAR)));
401  }
402 
403  /* Add two more chars for the last terminator */
404  sizeRemain = sizeRemain + (sizeof(WCHAR) * 2);
405 
406  szFilterMask = malloc(sizeRemain);
407  if (!szFilterMask)
408  {
409  DPRINT1("cannot allocate memory for filter mask in pSaveImageAs()");
410  free(codecInfo);
411  return;
412  }
413 
414  ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
415  ZeroMemory(szFilterMask, sizeRemain);
416  ZeroMemory(&sfn, sizeof(sfn));
417  sfn.lStructSize = sizeof(sfn);
418  sfn.hwndOwner = hwnd;
420  sfn.lpstrFile = szSaveFileName;
421  sfn.lpstrFilter = szFilterMask;
424 
425  c = szFilterMask;
426 
427  for (j = 0; j < num; ++j)
428  {
429  StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", codecInfo[j].FormatDescription, codecInfo[j].FilenameExtension);
430 
431  /* Skip the NULL character */
432  c++;
433  sizeRemain -= sizeof(*c);
434 
435  StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", codecInfo[j].FilenameExtension);
436 
437  /* Skip the NULL character */
438  c++;
439  sizeRemain -= sizeof(*c);
440 
441  if (IsEqualGUID(&rawFormat, &codecInfo[j].FormatID) != FALSE)
442  {
443  sfn.nFilterIndex = j + 1;
444  }
445  }
446 
447  if (GetSaveFileNameW(&sfn))
448  {
449  if (m_pDelayItem)
450  {
451  /* save animation */
453 
454  DPRINT1("FIXME: save animation\n");
455  if (GdipSaveImageToFile(image, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
456  {
457  DPRINT1("GdipSaveImageToFile() failed\n");
458  }
459 
461  }
462  else
463  {
464  /* save non-animation */
465  if (GdipSaveImageToFile(image, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
466  {
467  DPRINT1("GdipSaveImageToFile() failed\n");
468  }
469  }
470  }
471 
472  free(szFilterMask);
473  free(codecInfo);
474 }
#define OFN_EXPLORER
Definition: commdlg.h:104
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:1664
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:120
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4736
DWORD lStructSize
Definition: commdlg.h:360
#define FALSE
Definition: types.h:117
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:34
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:118
#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
#define NULL
Definition: types.h:112
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 297 of file shimgvw.c.

298 {
299  RECT Rect;
300  UINT ImageWidth, ImageHeight;
301 
302  if (image == NULL)
303  return;
304 
305  /* get disp window size and image size */
307  GdipGetImageWidth(image, &ImageWidth);
308  GdipGetImageHeight(image, &ImageHeight);
309 
310  /* compare two aspect rates. same as
311  (ImageHeight / ImageWidth < Rect.bottom / Rect.right) in real */
312  if (ImageHeight * Rect.right < Rect.bottom * ImageWidth)
313  {
314  if (Rect.right < ImageWidth)
315  {
316  /* it's large, shrink it */
317  ZoomPercents = (Rect.right * 100) / ImageWidth;
318  }
319  else
320  {
321  /* it's small. show as original size */
322  ZoomPercents = 100;
323  }
324  }
325  else
326  {
327  if (Rect.bottom < ImageHeight)
328  {
329  /* it's large, shrink it */
330  ZoomPercents = (Rect.bottom * 100) / ImageHeight;
331  }
332  else
333  {
334  /* it's small. show as original size */
335  ZoomPercents = 100;
336  }
337  }
338 }
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2342
UINT ZoomPercents
Definition: shimgvw.c:46
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2239
HWND hDispWnd
Definition: shimgvw.c:43
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
struct Rect Rect

Referenced by ImageView_OnSize(), and pLoadImage().

◆ ZoomInOrOut()

static void ZoomInOrOut ( BOOL  bZoomIn)
static

Definition at line 244 of file shimgvw.c.

245 {
246  UINT i;
247 
248  if (image == NULL)
249  return;
250 
251  if (bZoomIn) /* zoom in */
252  {
253  /* find next step */
254  for (i = 0; i < _countof(ZoomSteps); ++i)
255  {
256  if (ZoomPercents < ZoomSteps[i])
257  break;
258  }
259  if (i == _countof(ZoomSteps))
261  else
263 
264  /* update tool bar buttons */
266  if (ZoomPercents >= MAX_ZOOM)
268  else
270  }
271  else /* zoom out */
272  {
273  /* find previous step */
274  for (i = _countof(ZoomSteps); i > 0; )
275  {
276  --i;
277  if (ZoomSteps[i] < ZoomPercents)
278  break;
279  }
280  if (i < 0)
282  else
284 
285  /* update tool bar buttons */
287  if (ZoomPercents <= MIN_ZOOM)
289  else
291  }
292 
293  /* redraw */
295 }
#define IDC_ZOOM_OUT
Definition: resource.h:35
#define TRUE
Definition: types.h:120
UINT ZoomPercents
Definition: shimgvw.c:46
#define MAX_ZOOM
Definition: shimgvw.c:54
static const UINT ZoomSteps[]
Definition: shimgvw.c:48
#define FALSE
Definition: types.h:117
#define TB_ENABLEBUTTON
Definition: commctrl.h:1038
#define IDC_ZOOM_IN
Definition: resource.h:34
#define _countof(array)
Definition: sndvol32.h:68
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HWND hDispWnd
Definition: shimgvw.c:43
#define MIN_ZOOM
Definition: shimgvw.c:53
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
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HWND hToolBar
Definition: shimgvw.c:43

Referenced by ImageView_OnMouseWheel(), and ImageView_WndProc().

Variable Documentation

◆ BtnConfig

const TB_BUTTON_CONFIG BtnConfig[]
static
Initial value:
=
{
DEFINE_BTN_CONFIG(PREV_PIC),
DEFINE_BTN_CONFIG(NEXT_PIC),
DEFINE_BTN_CONFIG(BEST_FIT),
DEFINE_BTN_CONFIG(REAL_SIZE),
DEFINE_BTN_CONFIG(ZOOM_OUT),
DEFINE_BTN_CONFIG(ROT_CLOCKW),
DEFINE_BTN_CONFIG(ROT_COUNCW),
}
#define MODIFY(p, i, v)
Definition: check.c:44
#define SLIDE_SHOW
#define DEFINE_BTN_CONFIG(_name)
Definition: shimgvw.c:93
#define DELETE
Definition: nt_native.h:57

Definition at line 95 of file shimgvw.c.

Referenced by ImageView_CreateToolBar(), and ImageView_WndProc().

◆ Buttons

const TBBUTTON Buttons[]
static
Initial value:
=
{
DEFINE_BTN_INFO(PREV_PIC),
DEFINE_BTN_INFO(NEXT_PIC),
DEFINE_BTN_INFO(BEST_FIT),
DEFINE_BTN_INFO(REAL_SIZE),
DEFINE_BTN_INFO(ZOOM_IN),
DEFINE_BTN_INFO(ZOOM_OUT),
DEFINE_BTN_INFO(ROT_CLOCKW),
DEFINE_BTN_INFO(ROT_COUNCW),
DEFINE_BTN_INFO(SAVEAS),
}
#define MODIFY(p, i, v)
Definition: check.c:44
#define DEFINE_BTN_SEPARATOR
Definition: shimgvw.c:66
#define DEFINE_BTN_INFO(_name)
Definition: shimgvw.c:63
#define SLIDE_SHOW
#define DELETE
Definition: nt_native.h:57

Definition at line 70 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 114 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 117 of file shimgvw.c.

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

◆ m_nLoopIndex

UINT m_nLoopIndex = 0

Definition at line 116 of file shimgvw.c.

Referenced by Anime_FreeInfo(), and Anime_Step().

◆ m_pDelayItem

PropertyItem* m_pDelayItem = NULL

Definition at line 118 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 46 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 48 of file shimgvw.c.

Referenced by ZoomInOrOut().