ReactOS 0.4.16-dev-1019-g2c2cdfd
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)
 
UINT ErrorBox (HWND hwnd, UINT Error)
 
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:87
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:35
static LPVOID QuickAlloc(SIZE_T cbSize, BOOL bZero)
Definition: shimgvw.h:82

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 253 of file util.c.

254{
256}
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
UINT ErrorBox(HWND hwnd, UINT Error)
Definition: util.c:247
_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 152 of file util.c.

153{
154 IContextMenu *pCM;
156 if (SUCCEEDED(hr))
157 {
159 IContextMenu_Release(pCM);
160 }
161}
Definition: File.h:16
LPARAM lParam
Definition: combotst.c:139
HRESULT GetUIObjectOfPath(HWND hwnd, PCWSTR File, REFIID riid, void **ppv)
Definition: util.c:135
static void DoShellContextMenu(HWND hwnd, IContextMenu *pCM, PCWSTR File, LPARAM lParam)
Definition: util.c:93
#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 209 of file util.c.

210{
211 const SIZE_T cch = lstrlenW(File) + 1;
213 if (pData)
214 {
215 pData->hwnd = hwnd;
216 pData->Verb = Verb; // Note: This assumes the string is valid for the lifetime of the thread.
217 pData->CmdId = CmdId;
218 pData->ImageId = ImageId;
219 CopyMemory(pData->File, File, cch * sizeof(*File));
221 }
222}
#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:173
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:1741

Referenced by Preview_pLoadImage().

◆ ErrorBox()

UINT ErrorBox ( HWND  hwnd,
UINT  Error 
)

Definition at line 16 of file misc.cpp.

17{
18 if (!Error)
19 Error = ERROR_INTERNAL_ERROR; // Note: geninst.cpp depends on this
20 WCHAR buf[400];
23 MessageBoxW(hOwner, buf, 0, MB_OK | MB_ICONSTOP);
24 return Error;
25}
BOOL Error
Definition: chkdsk.c:66
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _countof(array)
Definition: sndvol32.h:70
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:446
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:840
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:801
#define MB_ICONSTOP
Definition: winuser.h:814
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DisplayHelp().

◆ HResultFromGdiplus()

static HRESULT HResultFromGdiplus ( Status  status)
inlinestatic

Definition at line 119 of file shimgvw.h.

120{
121 switch ((UINT)status)
122 {
123 case Ok: return S_OK;
124 case InvalidParameter: return E_INVALIDARG;
125 case OutOfMemory: return E_OUTOFMEMORY;
131 }
132 return E_FAIL;
133}
#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:113
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 106 of file shimgvw.h.

107{
109 ret.QuadPart = value;
110 return ret;
111}
Definition: pdh_main.c:96
int ret

Referenced by LoadImageFromFileHandle().

◆ QuickAlloc()

static LPVOID QuickAlloc ( SIZE_T  cbSize,
BOOL  bZero 
)
inlinestatic

Definition at line 82 of file shimgvw.h.

83{
84 return HeapAlloc(GetProcessHeap(), (bZero ? HEAP_ZERO_MEMORY : 0), cbSize);
85}
#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 87 of file shimgvw.h.

88{
90}
#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 225 of file util.c.

226{
228 if (!*File)
229 return;
230
231 sei.hwnd = hwnd;
232 sei.lpVerb = Verb;
233 sei.lpFile = File;
234 sei.nShow = SW_SHOW;
235 if (!ShellExecuteExW(&sei))
236 {
237 DPRINT1("ShellExecuteExW(%ls, %ls) failed with code %ld\n", Verb, File, GetLastError());
238 }
239 else if (Quit)
240 {
241 // Destroy the window to quit the application
243 }
244}
#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:786
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Preview_Edit(), and Preview_pPrintImage().

◆ SHIMGVW_HResultFromWin32()

static HRESULT SHIMGVW_HResultFromWin32 ( DWORD  hr)
inlinestatic

Definition at line 113 of file shimgvw.h.

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

Referenced by HResultFromGdiplus().

◆ Swap16()

static WORD Swap16 ( WORD  v)
inlinestatic

Definition at line 92 of file shimgvw.h.

93{
94 return MAKEWORD(HIBYTE(v), LOBYTE(v));
95}
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 97 of file shimgvw.h.

98{
99 return MAKELONG(Swap16(HIWORD(v)), Swap16(LOWORD(v)));
100}
#define LOWORD(l)
Definition: pedump.c:82
static WORD Swap16(WORD v)
Definition: shimgvw.h:92
#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