ReactOS 0.4.16-dev-833-g4bc97ad
shimgvw.h File Reference
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <winreg.h>
#include <wingdi.h>
#include <wincon.h>
#include <objbase.h>
#include <gdiplus.h>
#include <shlwapi.h>
#include <strsafe.h>
#include <shobjidl.h>
#include <debug.h>
#include "resource.h"
Include dependency graph for shimgvw.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SHIMGVW_SETTINGS
 
struct  tagSHIMGVW_FILENODE
 
struct  tagANIME
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define INITGUID
 
#define COBJMACROS
 
#define WM_UPDATECOMMANDSTATE   (WM_APP + 0)
 
#define WC_PREVIEW   L"ShImgVw:CPreviewWnd"
 
#define WC_ZOOM   L"ShImgVw:CZoomWnd"
 

Typedefs

typedef struct tagSHIMGVW_FILENODE SHIMGVW_FILENODE
 
typedef struct tagANIME ANIME
 
typedef struct tagANIMEPANIME
 

Functions

void Anime_FreeInfo (PANIME pAnime)
 
BOOL Anime_LoadInfo (PANIME pAnime)
 
void Anime_SetTimerWnd (PANIME pAnime, HWND hwndTimer)
 
void Anime_SetFrameIndex (PANIME pAnime, UINT nFrameIndex)
 
void Anime_Start (PANIME pAnime, DWORD dwDelay)
 
void Anime_Pause (PANIME pAnime)
 
BOOL Anime_OnTimer (PANIME pAnime, WPARAM wParam)
 
void DoShellContextMenuOnFile (HWND hwnd, PCWSTR File, LPARAM lParam)
 
void EnableCommandIfVerbExists (UINT ImageId, HWND hwnd, UINT CmdId, PCWSTR Verb, PCWSTR File)
 
void ShellExecuteVerb (HWND hwnd, PCWSTR Verb, PCWSTR File, BOOL Quit)
 
void DisplayHelp (HWND hwnd)
 
static LPVOID QuickAlloc (SIZE_T cbSize, BOOL bZero)
 
static VOID QuickFree (LPVOID ptr)
 
static WORD Swap16 (WORD v)
 
static UINT Swap32 (UINT v)
 
static ULARGE_INTEGER MakeULargeInteger (UINT64 value)
 
static HRESULT SHIMGVW_HResultFromWin32 (DWORD hr)
 
static HRESULT HResultFromGdiplus (Status status)
 

Variables

HINSTANCE g_hInstance
 
GpImageg_pImage
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 12 of file shimgvw.h.

◆ COBJMACROS

#define COBJMACROS

Definition at line 15 of file shimgvw.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 13 of file shimgvw.h.

◆ INITGUID

#define INITGUID

Definition at line 14 of file shimgvw.h.

◆ WC_PREVIEW

#define WC_PREVIEW   L"ShImgVw:CPreviewWnd"

Definition at line 54 of file shimgvw.h.

◆ WC_ZOOM

#define WC_ZOOM   L"ShImgVw:CZoomWnd"

Definition at line 55 of file shimgvw.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file shimgvw.h.

◆ WM_UPDATECOMMANDSTATE

#define WM_UPDATECOMMANDSTATE   (WM_APP + 0)

Definition at line 33 of file shimgvw.h.

Typedef Documentation

◆ ANIME

◆ PANIME

typedef struct tagANIME * PANIME

◆ SHIMGVW_FILENODE

Function Documentation

◆ Anime_FreeInfo()

void Anime_FreeInfo ( PANIME  pAnime)

Definition at line 12 of file anime.c.

13{
14 if (pAnime->m_pDelayItem)
15 {
16 QuickFree(pAnime->m_pDelayItem);
17 pAnime->m_pDelayItem = NULL;
18 }
19 pAnime->m_nFrameIndex = 0;
20 pAnime->m_nFrameCount = 0;
21 pAnime->m_nLoopIndex = 0;
22 pAnime->m_nLoopCount = (UINT)-1;
23}
#define NULL
Definition: types.h:112
unsigned int UINT
Definition: ndis.h:50
static VOID QuickFree(LPVOID ptr)
Definition: shimgvw.h:86
UINT m_nLoopCount
Definition: shimgvw.h:63
UINT m_nFrameIndex
Definition: shimgvw.h:60
UINT m_nLoopIndex
Definition: shimgvw.h:62
PropertyItem * m_pDelayItem
Definition: shimgvw.h:64
UINT m_nFrameCount
Definition: shimgvw.h:61

Referenced by Anime_LoadInfo(), and Preview_pFreeImage().

◆ Anime_LoadInfo()

BOOL Anime_LoadInfo ( PANIME  pAnime)

Definition at line 89 of file anime.c.

90{
91 UINT nDimCount = 0;
92 UINT cbItem;
94
95 Anime_Pause(pAnime);
96 Anime_FreeInfo(pAnime);
97
98 if (!g_pImage)
99 return FALSE;
100
102 if (nDimCount)
103 {
104 GUID *dims = (GUID *)QuickAlloc(nDimCount * sizeof(GUID), TRUE);
105 if (dims)
106 {
109 pAnime->m_nFrameCount = result;
110 QuickFree(dims);
111 }
112 }
113
114 result = 0;
116 cbItem = result;
117 if (cbItem)
118 {
119 pAnime->m_pDelayItem = (PropertyItem *)QuickAlloc(cbItem, FALSE);
121 }
122
123 result = 0;
125 cbItem = result;
126 if (cbItem)
127 {
128 PropertyItem *pItem = (PropertyItem *)QuickAlloc(cbItem, FALSE);
129 if (pItem)
130 {
131 if (GdipGetPropertyItem(g_pImage, PropertyTagLoopCount, cbItem, pItem) == Ok)
132 {
133 pAnime->m_nLoopCount = *(WORD *)pItem->value;
134 }
135 QuickFree(pItem);
136 }
137 }
138
139 Anime_Start(pAnime, 0);
140
141 return pAnime->m_pDelayItem != NULL;
142}
void Anime_Start(PANIME pAnime, DWORD dwDelay)
Definition: anime.c:35
void Anime_FreeInfo(PANIME pAnime)
Definition: anime.c:12
void Anime_Pause(PANIME pAnime)
Definition: anime.c:30
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GDIPCONST GUID *dimensionID, UINT *count)
Definition: image.c:2913
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsCount(GpImage *image, UINT *count)
Definition: image.c:2933
GpStatus WINGDIPAPI GdipGetPropertyItem(GpImage *image, PROPID propid, UINT size, PropertyItem *buffer)
Definition: image.c:2682
GpStatus WINGDIPAPI GdipGetPropertyItemSize(GpImage *image, PROPID propid, UINT *size)
Definition: image.c:2536
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsList(GpImage *image, GUID *dimensionIDs, UINT count)
Definition: image.c:2948
unsigned short WORD
Definition: ntddk_ex.h:93
#define PropertyTagFrameDelay
#define PropertyTagLoopCount
@ Ok
Definition: gdiplustypes.h:26
GLuint64EXT * result
Definition: glext.h:11304
GpImage * g_pImage
Definition: shimgvw.c:34
static LPVOID QuickAlloc(SIZE_T cbSize, BOOL bZero)
Definition: shimgvw.h:81

Referenced by Preview_pLoadImage().

◆ Anime_OnTimer()

BOOL Anime_OnTimer ( PANIME  pAnime,
WPARAM  wParam 
)

Definition at line 76 of file anime.c.

77{
78 DWORD dwDelay;
79
81 return FALSE;
82
83 Anime_Pause(pAnime);
84 if (Anime_Step(pAnime, &dwDelay))
85 Anime_Start(pAnime, dwDelay);
86 return TRUE;
87}
BOOL Anime_Step(PANIME pAnime, DWORD *pdwDelay)
Definition: anime.c:50
#define ANIME_TIMER_ID
Definition: anime.c:10
WPARAM wParam
Definition: combotst.c:138
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by ZoomWndProc().

◆ Anime_Pause()

void Anime_Pause ( PANIME  pAnime)

Definition at line 30 of file anime.c.

31{
33}
HWND m_hwndTimer
Definition: shimgvw.h:65
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by Anime_LoadInfo(), Anime_OnTimer(), Preview_pSaveImage(), and Preview_pSaveImageAs().

◆ Anime_SetFrameIndex()

void Anime_SetFrameIndex ( PANIME  pAnime,
UINT  nFrameIndex 
)

Definition at line 144 of file anime.c.

145{
146 if (nFrameIndex < pAnime->m_nFrameCount)
147 {
148 GUID guid = FrameDimensionTime;
149 if (Ok != GdipImageSelectActiveFrame(g_pImage, &guid, nFrameIndex))
150 {
151 guid = FrameDimensionPage;
153 }
154 }
155 pAnime->m_nFrameIndex = nFrameIndex;
156}
GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *dimensionID, UINT frame)
Definition: image.c:4350
const GUID * guid

Referenced by Anime_Step().

◆ Anime_SetTimerWnd()

void Anime_SetTimerWnd ( PANIME  pAnime,
HWND  hwndTimer 
)

Definition at line 25 of file anime.c.

26{
27 pAnime->m_hwndTimer = hwndTimer;
28}

Referenced by Preview_OnCreate().

◆ Anime_Start()

void Anime_Start ( PANIME  pAnime,
DWORD  dwDelay 
)

Definition at line 35 of file anime.c.

36{
37 if (pAnime->m_pDelayItem)
38 SetTimer(pAnime->m_hwndTimer, ANIME_TIMER_ID, dwDelay, NULL);
39}
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

Referenced by Anime_LoadInfo(), Anime_OnTimer(), Preview_pSaveImage(), and Preview_pSaveImageAs().

◆ DisplayHelp()

void DisplayHelp ( HWND  hwnd)

Definition at line 245 of file util.c.

246{
248}
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define SHELL_ErrorBox
Definition: shellutils.h:126
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by Preview_OnCommand().

◆ DoShellContextMenuOnFile()

void DoShellContextMenuOnFile ( HWND  hwnd,
PCWSTR  File,
LPARAM  lParam 
)

Definition at line 150 of file util.c.

151{
152 IContextMenu *pCM;
154 if (SUCCEEDED(hr))
155 {
157 IContextMenu_Release(pCM);
158 }
159}
Definition: File.h:16
LPARAM lParam
Definition: combotst.c:139
HRESULT GetUIObjectOfPath(HWND hwnd, PCWSTR File, REFIID riid, void **ppv)
Definition: util.c:134
static void DoShellContextMenu(HWND hwnd, IContextMenu *pCM, PCWSTR File, LPARAM lParam)
Definition: util.c:92
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)

Referenced by ZoomWndProc().

◆ EnableCommandIfVerbExists()

void EnableCommandIfVerbExists ( UINT  ImageId,
HWND  hwnd,
UINT  CmdId,
PCWSTR  Verb,
PCWSTR  File 
)

Definition at line 207 of file util.c.

208{
209 const SIZE_T cch = lstrlenW(File) + 1;
211 if (pData)
212 {
213 pData->hwnd = hwnd;
214 pData->Verb = Verb; // Note: This assumes the string is valid for the lifetime of the thread.
215 pData->CmdId = CmdId;
216 pData->ImageId = ImageId;
217 CopyMemory(pData->File, File, cch * sizeof(*File));
219 }
220}
#define lstrlenW
Definition: compat.h:750
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
static DWORD CALLBACK EnableCommandIfVerbExistsProc(LPVOID ThreadParam)
Definition: util.c:171
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define CTF_COINIT
Definition: shlwapi.h:1981
#define CTF_INSIST
Definition: shlwapi.h:1978
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CopyMemory
Definition: winbase.h:1735

Referenced by Preview_pLoadImage().

◆ HResultFromGdiplus()

static HRESULT HResultFromGdiplus ( Status  status)
inlinestatic

Definition at line 118 of file shimgvw.h.

119{
120 switch ((UINT)status)
121 {
122 case Ok: return S_OK;
123 case InvalidParameter: return E_INVALIDARG;
124 case OutOfMemory: return E_OUTOFMEMORY;
130 }
131 return E_FAIL;
132}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
@ FileNotFound
Definition: gdiplustypes.h:36
@ AccessDenied
Definition: gdiplustypes.h:38
@ InvalidParameter
Definition: gdiplustypes.h:28
@ OutOfMemory
Definition: gdiplustypes.h:29
@ Win32Error
Definition: gdiplustypes.h:33
@ NotImplemented
Definition: gdiplustypes.h:32
@ UnknownImageFormat
Definition: gdiplustypes.h:39
#define S_OK
Definition: intsafe.h:52
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HRESULT SHIMGVW_HResultFromWin32(DWORD hr)
Definition: shimgvw.h:112
Definition: ps.c:97
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_BAD_FORMAT
Definition: winerror.h:114
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by LoadImageFromStream().

◆ MakeULargeInteger()

static ULARGE_INTEGER MakeULargeInteger ( UINT64  value)
inlinestatic

Definition at line 105 of file shimgvw.h.

106{
108 ret.QuadPart = value;
109 return ret;
110}
Definition: pdh_main.c:94
int ret

Referenced by LoadImageFromFileHandle().

◆ QuickAlloc()

static LPVOID QuickAlloc ( SIZE_T  cbSize,
BOOL  bZero 
)
inlinestatic

Definition at line 81 of file shimgvw.h.

82{
83 return HeapAlloc(GetProcessHeap(), (bZero ? HEAP_ZERO_MEMORY : 0), cbSize);
84}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

Referenced by Anime_LoadInfo(), pBuildFileList(), Preview_OnCreate(), Preview_pSaveImage(), and Preview_pSaveImageAs().

◆ QuickFree()

static VOID QuickFree ( LPVOID  ptr)
inlinestatic

Definition at line 86 of file shimgvw.h.

87{
89}
#define HeapFree(x, y, z)
Definition: compat.h:735
static PVOID ptr
Definition: dispmode.c:27

Referenced by Anime_FreeInfo(), Anime_LoadInfo(), pBuildFileList(), pFreeFileList(), Preview_OnCreate(), Preview_OnDestroy(), Preview_pSaveImage(), and Preview_pSaveImageAs().

◆ ShellExecuteVerb()

void ShellExecuteVerb ( HWND  hwnd,
PCWSTR  Verb,
PCWSTR  File,
BOOL  Quit 
)

Definition at line 223 of file util.c.

224{
226 if (!*File)
227 return;
228
229 sei.hwnd = hwnd;
230 sei.lpVerb = Verb;
231 sei.lpFile = File;
232 sei.nShow = SW_SHOW;
233 if (!ShellExecuteExW(&sei))
234 {
235 DPRINT1("ShellExecuteExW(%ls, %ls) failed with code %ld\n", Verb, File, GetLastError());
236 }
237 else if (Quit)
238 {
239 // Destroy the window to quit the application
241 }
242}
#define DPRINT1
Definition: precomp.h:8
#define SEE_MASK_ASYNCOK
Definition: shellapi.h:54
#define SEE_MASK_INVOKEIDLIST
Definition: shellapi.h:28
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2452
#define SW_SHOW
Definition: winuser.h:778
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Preview_Edit(), and Preview_pPrintImage().

◆ SHIMGVW_HResultFromWin32()

static HRESULT SHIMGVW_HResultFromWin32 ( DWORD  hr)
inlinestatic

Definition at line 112 of file shimgvw.h.

113{
114 // HRESULT_FROM_WIN32 will evaluate its parameter twice, this function will not.
115 return HRESULT_FROM_WIN32(hr);
116}

Referenced by HResultFromGdiplus().

◆ Swap16()

static WORD Swap16 ( WORD  v)
inlinestatic

Definition at line 91 of file shimgvw.h.

92{
93 return MAKEWORD(HIBYTE(v), LOBYTE(v));
94}
const GLdouble * v
Definition: gl.h:2040
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define MAKEWORD(a, b)
Definition: typedefs.h:248

Referenced by Swap32().

◆ Swap32()

static UINT Swap32 ( UINT  v)
inlinestatic

Definition at line 96 of file shimgvw.h.

97{
98 return MAKELONG(Swap16(HIWORD(v)), Swap16(LOWORD(v)));
99}
#define LOWORD(l)
Definition: pedump.c:82
static WORD Swap16(WORD v)
Definition: shimgvw.h:91
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247

Variable Documentation

◆ g_hInstance

HINSTANCE g_hInstance
extern

Definition at line 18 of file MainWindow.cpp.

◆ g_pImage