ReactOS 0.4.15-dev-7918-g2a2556c
shimgvw.c File Reference
#include "shimgvw.h"
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
#include <shellapi.h>
Include dependency graph for shimgvw.c:

Go to the source code of this file.

Classes

struct  TB_BUTTON_CONFIG
 
struct  tagPREVIEW_DATA
 

Macros

#define TB_IMAGE_WIDTH   16
 
#define TB_IMAGE_HEIGHT   16
 
#define SLIDESHOW_TIMER_ID   0xFACE
 
#define SLIDESHOW_TIMER_INTERVAL   5000 /* 5 seconds */
 
#define MIN_ZOOM   s_ZoomSteps[0]
 
#define MAX_ZOOM   s_ZoomSteps[_countof(s_ZoomSteps) - 1]
 
#define DEFINE_BTN_INFO(_name)    { TBICON_##_name, IDC_##_name, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }
 
#define DEFINE_BTN_SEPARATOR    { -1, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0 }
 
#define DEFINE_BTN_CONFIG(_name)   { IDB_##_name, IDS_TOOLTIP_##_name }
 

Typedefs

typedef struct tagPREVIEW_DATA PREVIEW_DATA
 
typedef struct tagPREVIEW_DATAPPREVIEW_DATA
 

Functions

static PPREVIEW_DATA Preview_GetData (HWND hwnd)
 
static BOOL Preview_IsMainWnd (HWND hwnd)
 
static VOID Preview_RestartTimer (HWND hwnd)
 
static VOID ZoomWnd_UpdateScroll (PPREVIEW_DATA pData, HWND hwnd, BOOL bResetPos)
 
static VOID Preview_UpdateZoom (PPREVIEW_DATA pData, UINT NewZoom, BOOL bEnableBestFit, BOOL bEnableRealSize)
 
static VOID Preview_ZoomInOrOut (PPREVIEW_DATA pData, BOOL bZoomIn)
 
static VOID Preview_ResetZoom (PPREVIEW_DATA pData)
 
static VOID Preview_UpdateTitle (PPREVIEW_DATA pData, LPCWSTR FileName)
 
static VOID Preview_pFreeImage (PPREVIEW_DATA pData)
 
IStreamMemStreamFromFile (LPCWSTR pszFileName)
 
static VOID Preview_pLoadImage (PPREVIEW_DATA pData, LPCWSTR szOpenFileName)
 
static VOID Preview_pLoadImageFromNode (PPREVIEW_DATA pData, SHIMGVW_FILENODE *pNode)
 
static BOOL Preview_pSaveImage (PPREVIEW_DATA pData, LPCWSTR pszFile)
 
static VOID Preview_pSaveImageAs (PPREVIEW_DATA pData)
 
static VOID Preview_pPrintImage (PPREVIEW_DATA pData)
 
static VOID Preview_UpdateUI (PPREVIEW_DATA pData)
 
static VOID Preview_UpdateImage (PPREVIEW_DATA pData)
 
static SHIMGVW_FILENODEpBuildFileList (LPCWSTR szFirstFile)
 
static VOID pFreeFileList (SHIMGVW_FILENODE *root)
 
static HBRUSH CreateCheckerBoardBrush (VOID)
 
static VOID ZoomWnd_OnDraw (PPREVIEW_DATA pData, HDC hdc, LPRECT prcPaint, LPRECT prcClient)
 
static VOID ZoomWnd_OnPaint (PPREVIEW_DATA pData, HWND hwnd)
 
static VOID ImageView_ResetSettings (VOID)
 
static BOOL ImageView_LoadSettings (VOID)
 
static VOID ImageView_SaveSettings (VOID)
 
static BOOL Preview_CreateToolBar (PPREVIEW_DATA pData)
 
static VOID Preview_EndSlideShow (HWND hwnd)
 
static VOID ZoomWnd_OnButtonDown (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID ZoomWnd_OnMouseMove (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL ZoomWnd_OnSetCursor (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID ZoomWnd_OnButtonUp (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID ZoomWnd_OnHVScroll (PPREVIEW_DATA pData, HWND hwnd, WPARAM wParam, BOOL bVertical)
 
static VOID ZoomWnd_OnMouseWheel (HWND hwnd, INT x, INT y, INT zDelta, UINT fwKeys)
 
LRESULT CALLBACK ZoomWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL Preview_OnCreate (HWND hwnd, LPCREATESTRUCT pCS)
 
static VOID Preview_OnMoveSize (HWND hwnd)
 
static VOID Preview_OnSize (HWND hwnd)
 
static VOID Preview_Delete (PPREVIEW_DATA pData)
 
static VOID Preview_Edit (HWND hwnd)
 
static VOID Preview_ToggleSlideShow (PPREVIEW_DATA pData)
 
static VOID Preview_GoNextPic (PPREVIEW_DATA pData, BOOL bNext)
 
static VOID Preview_OnCommand (HWND hwnd, UINT nCommandID)
 
static LRESULT Preview_OnNotify (HWND hwnd, LPNMHDR pnmhdr)
 
static VOID Preview_OnDestroy (HWND hwnd)
 
static VOID Preview_OnDropFiles (HWND hwnd, HDROP hDrop)
 
LRESULT CALLBACK PreviewWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LONG ImageView_Main (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 g_hInstance = NULL
 
HWND g_hMainWnd = NULL
 
HWND g_hwndFullscreen = NULL
 
SHIMGVW_FILENODEg_pCurrentFile = NULL
 
GpImageg_pImage = NULL
 
SHIMGVW_SETTINGS g_Settings
 
static const UINT s_ZoomSteps []
 
static const TBBUTTON s_Buttons []
 
static const TB_BUTTON_CONFIG s_ButtonConfig []
 

Macro Definition Documentation

◆ DEFINE_BTN_CONFIG

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

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

◆ DEFINE_BTN_SEPARATOR

#define DEFINE_BTN_SEPARATOR    { -1, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0 }

Definition at line 43 of file shimgvw.c.

◆ MAX_ZOOM

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

Definition at line 37 of file shimgvw.c.

◆ MIN_ZOOM

#define MIN_ZOOM   s_ZoomSteps[0]

Definition at line 36 of file shimgvw.c.

◆ SLIDESHOW_TIMER_ID

#define SLIDESHOW_TIMER_ID   0xFACE

Definition at line 21 of file shimgvw.c.

◆ SLIDESHOW_TIMER_INTERVAL

#define SLIDESHOW_TIMER_INTERVAL   5000 /* 5 seconds */

Definition at line 22 of file shimgvw.c.

◆ TB_IMAGE_HEIGHT

#define TB_IMAGE_HEIGHT   16

Definition at line 18 of file shimgvw.c.

◆ TB_IMAGE_WIDTH

#define TB_IMAGE_WIDTH   16

Definition at line 17 of file shimgvw.c.

Typedef Documentation

◆ PPREVIEW_DATA

◆ PREVIEW_DATA

Function Documentation

◆ CreateCheckerBoardBrush()

static HBRUSH CreateCheckerBoardBrush ( VOID  )
static

Definition at line 730 of file shimgvw.c.

731{
732 static const CHAR pattern[] =
733 "\x28\x00\x00\x00\x10\x00\x00\x00\x10\x00\x00\x00\x01\x00\x04\x00\x00\x00"
734 "\x00\x00\x80\x00\x00\x00\x23\x2E\x00\x00\x23\x2E\x00\x00\x10\x00\x00\x00"
735 "\x00\x00\x00\x00\x99\x99\x99\x00\xCC\xCC\xCC\x00\x00\x00\x00\x00\x00\x00"
736 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
737 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
738 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11\x11\x11"
739 "\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00"
740 "\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00"
741 "\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11"
742 "\x11\x11\x00\x00\x00\x00\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00"
743 "\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11"
744 "\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11"
745 "\x00\x00\x00\x00\x11\x11\x11\x11\x00\x00\x00\x00\x11\x11\x11\x11";
746
748}
GLubyte * pattern
Definition: glext.h:7787
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
char CHAR
Definition: xmlstorage.h:175

Referenced by ZoomWnd_OnDraw().

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

1785{
1786 switch (dwReason)
1787 {
1788 case DLL_PROCESS_ATTACH:
1789 g_hInstance = hinstDLL;
1790 break;
1791 }
1792
1793 return TRUE;
1794}
DWORD dwReason
Definition: misc.cpp:154
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
HINSTANCE g_hInstance
Definition: shimgvw.c:24

◆ ImageView_Fullscreen()

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

Definition at line 1747 of file shimgvw.c.

1748{
1750}
LONG ImageView_Main(HWND hwnd, LPCWSTR szFileName)
Definition: shimgvw.c:1651
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ ImageView_FullscreenA()

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

Definition at line 1753 of file shimgvw.c.

1754{
1755 WCHAR szFile[MAX_PATH];
1756
1757 if (MultiByteToWideChar(CP_ACP, 0, path, -1, szFile, _countof(szFile)))
1758 {
1759 ImageView_Main(hwnd, szFile);
1760 }
1761}
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define MultiByteToWideChar
Definition: compat.h:110
#define _countof(array)
Definition: sndvol32.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ImageView_FullscreenW()

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

Definition at line 1741 of file shimgvw.c.

1742{
1744}

◆ ImageView_LoadSettings()

static BOOL ImageView_LoadSettings ( VOID  )
static

Definition at line 909 of file shimgvw.c.

910{
911 HKEY hKey;
913 LSTATUS nError;
914
915 nError = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\shimgvw", 0, KEY_READ, &hKey);
916 if (nError != ERROR_SUCCESS)
917 return FALSE;
918
919 dwSize = sizeof(g_Settings);
920 nError = RegQueryValueExW(hKey, L"Settings", NULL, NULL, (LPBYTE)&g_Settings, &dwSize);
922
923 return ((nError == ERROR_SUCCESS) && (dwSize == sizeof(g_Settings)));
924}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
SHIMGVW_SETTINGS g_Settings
Definition: shimgvw.c:29
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by ImageView_Main().

◆ ImageView_Main()

LONG ImageView_Main ( HWND  hwnd,
LPCWSTR  szFileName 
)

Definition at line 1651 of file shimgvw.c.

1652{
1653 struct GdiplusStartupInput gdiplusStartupInput;
1654 ULONG_PTR gdiplusToken;
1656 WCHAR szTitle[256];
1657 HWND hMainWnd;
1658 MSG msg;
1659 HACCEL hAccel;
1660 HRESULT hrCoInit;
1661 INITCOMMONCONTROLSEX Icc = { .dwSize = sizeof(Icc), .dwICC = ICC_WIN95_CLASSES };
1662
1664
1665 /* Initialize COM */
1667 if (FAILED(hrCoInit))
1668 DPRINT1("Warning, CoInitializeEx failed with code=%08X\n", (int)hrCoInit);
1669
1672
1673 /* Initialize GDI+ */
1674 ZeroMemory(&gdiplusStartupInput, sizeof(gdiplusStartupInput));
1675 gdiplusStartupInput.GdiplusVersion = 1;
1676 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1677
1678 /* Register window classes */
1679 ZeroMemory(&WndClass, sizeof(WndClass));
1680 WndClass.lpszClassName = WC_PREVIEW;
1681 WndClass.lpfnWndProc = PreviewWndProc;
1682 WndClass.hInstance = g_hInstance;
1683 WndClass.style = CS_HREDRAW | CS_VREDRAW;
1686 WndClass.hbrBackground = (HBRUSH)UlongToHandle(COLOR_3DFACE + 1);
1687 if (!RegisterClassW(&WndClass))
1688 return -1;
1689 WndClass.lpszClassName = WC_ZOOM;
1690 WndClass.lpfnWndProc = ZoomWndProc;
1692 WndClass.hbrBackground = GetStockBrush(NULL_BRUSH); /* less flicker */
1693 if (!RegisterClassW(&WndClass))
1694 return -1;
1695
1696 /* Create the main window */
1701 NULL, NULL, g_hInstance, (LPVOID)szFileName);
1702
1703 /* Create accelerator table for keystrokes */
1705
1706 /* Show the main window now */
1709 else
1711
1713
1714 /* Message Loop */
1715 while (GetMessageW(&msg, NULL, 0, 0) > 0)
1716 {
1718 continue;
1720 continue;
1721
1724 }
1725
1726 /* Destroy accelerator table */
1728
1730
1731 GdiplusShutdown(gdiplusToken);
1732
1733 /* Release COM resources */
1734 if (SUCCEEDED(hrCoInit))
1736
1737 return 0;
1738}
#define msg(x)
Definition: auth_time.c:54
#define IDS_APPTITLE
Definition: resource.h:3
#define DPRINT1
Definition: precomp.h:8
#define UlongToHandle(ul)
Definition: basetsd.h:97
WCHAR WndClass[]
Definition: capicon.c:23
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define IDI_APP_ICON
Definition: resource.h:4
#define IDR_ACCELERATOR
Definition: resource.h:103
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
void WINAPI GdiplusShutdown(ULONG_PTR)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
HWND hMainWnd
Definition: magnifier.c:32
HACCEL hAccel
Definition: main.c:47
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:280
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
LRESULT CALLBACK ZoomWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:1141
LRESULT CALLBACK PreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:1579
static BOOL ImageView_LoadSettings(VOID)
Definition: shimgvw.c:909
HWND g_hwndFullscreen
Definition: shimgvw.c:26
static VOID ImageView_SaveSettings(VOID)
Definition: shimgvw.c:927
static VOID ImageView_ResetSettings(VOID)
Definition: shimgvw.c:899
#define WC_PREVIEW
Definition: shimgvw.h:50
#define WC_ZOOM
Definition: shimgvw.h:51
BOOL Maximized
Definition: shimgvw.h:36
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ZeroMemory
Definition: winbase.h:1712
#define GetStockBrush(i)
Definition: windowsx.h:307
#define NULL_BRUSH
Definition: wingdi.h:901
#define SW_SHOWNORMAL
Definition: winuser.h:770
#define CS_VREDRAW
Definition: winuser.h:658
#define SW_SHOWMAXIMIZED
Definition: winuser.h:773
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
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 UpdateWindow(_In_ HWND)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL WINAPI DestroyAcceleratorTable(_In_ HACCEL)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075
#define COLOR_3DFACE
Definition: winuser.h:929
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

◆ ImageView_PrintTo()

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

Definition at line 1764 of file shimgvw.c.

1765{
1766 DPRINT("ImageView_PrintTo() not implemented\n");
1767}
#define DPRINT
Definition: sndvol32.h:71

◆ ImageView_PrintToA()

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

Definition at line 1770 of file shimgvw.c.

1771{
1772 DPRINT("ImageView_PrintToA() not implemented\n");
1773}

◆ ImageView_PrintToW()

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

Definition at line 1776 of file shimgvw.c.

1777{
1778 DPRINT("ImageView_PrintToW() not implemented\n");
1779}

◆ ImageView_ResetSettings()

static VOID ImageView_ResetSettings ( VOID  )
static

Definition at line 899 of file shimgvw.c.

900{
904 g_Settings.Width = 520;
905 g_Settings.Height = 400;
906}
#define CW_USEDEFAULT
Definition: winuser.h:225

Referenced by ImageView_Main().

◆ ImageView_SaveSettings()

static VOID ImageView_SaveSettings ( VOID  )
static

Definition at line 927 of file shimgvw.c.

928{
929 HKEY hKey;
930 LSTATUS nError;
931
932 nError = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\shimgvw",
933 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
934 if (nError != ERROR_SUCCESS)
935 return;
936
937 RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE)&g_Settings, sizeof(g_Settings));
939}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_WRITE
Definition: nt_native.h:1031

Referenced by ImageView_Main().

◆ MemStreamFromFile()

IStream * MemStreamFromFile ( LPCWSTR  pszFileName)

Definition at line 357 of file shimgvw.c.

358{
360 DWORD dwFileSize, dwRead;
361 LPBYTE pbMemFile = NULL;
362 IStream *pStream;
363
365 OPEN_EXISTING, 0, NULL);
367 return NULL;
368
370 pbMemFile = QuickAlloc(dwFileSize, FALSE);
371 if (!dwFileSize || (dwFileSize == INVALID_FILE_SIZE) || !pbMemFile)
372 {
374 return NULL;
375 }
376
377 if (!ReadFile(hFile, pbMemFile, dwFileSize, &dwRead, NULL) || (dwRead != dwFileSize))
378 {
379 QuickFree(pbMemFile);
381 return NULL;
382 }
383
385 pStream = SHCreateMemStream(pbMemFile, dwFileSize);
386 QuickFree(pbMemFile);
387 return pStream;
388}
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
DWORD dwFileSize
Definition: more.c:40
_In_ HANDLE hFile
Definition: mswsock.h:90
IStream *WINAPI SHCreateMemStream(const BYTE *lpbData, UINT dwDataLen)
Definition: regstream.c:652
static LPVOID QuickAlloc(SIZE_T cbSize, BOOL bZero)
Definition: shimgvw.h:72
static VOID QuickFree(LPVOID ptr)
Definition: shimgvw.h:77
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define INVALID_FILE_SIZE
Definition: winbase.h:548

Referenced by Preview_pLoadImage().

◆ pBuildFileList()

static SHIMGVW_FILENODE * pBuildFileList ( LPCWSTR  szFirstFile)
static

Definition at line 599 of file shimgvw.c.

600{
601 HANDLE hFindHandle;
602 WCHAR *extension;
603 WCHAR szSearchPath[MAX_PATH];
604 WCHAR szSearchMask[MAX_PATH];
605 WCHAR szFileTypes[MAX_PATH];
606 WIN32_FIND_DATAW findData;
607 SHIMGVW_FILENODE *currentNode = NULL;
609 SHIMGVW_FILENODE *conductor = NULL;
610 ImageCodecInfo *codecInfo;
611 UINT num;
612 UINT size;
613 UINT j;
614
615 StringCbCopyW(szSearchPath, sizeof(szSearchPath), szFirstFile);
616 PathRemoveFileSpecW(szSearchPath);
617
619 codecInfo = QuickAlloc(size, FALSE);
620 if (!codecInfo)
621 {
622 DPRINT1("QuickAlloc() failed in pLoadFileList()\n");
623 return NULL;
624 }
625
626 GdipGetImageDecoders(num, size, codecInfo);
627
629 if (!root)
630 {
631 DPRINT1("QuickAlloc() failed in pLoadFileList()\n");
632 QuickFree(codecInfo);
633 return NULL;
634 }
635
636 conductor = root;
637
638 for (j = 0; j < num; ++j)
639 {
640 StringCbCopyW(szFileTypes, sizeof(szFileTypes), codecInfo[j].FilenameExtension);
641
642 extension = wcstok(szFileTypes, L";");
643 while (extension != NULL)
644 {
645 PathCombineW(szSearchMask, szSearchPath, extension);
646
647 hFindHandle = FindFirstFileW(szSearchMask, &findData);
648 if (hFindHandle != INVALID_HANDLE_VALUE)
649 {
650 do
651 {
652 PathCombineW(conductor->FileName, szSearchPath, findData.cFileName);
653
654 // compare the name of the requested file with the one currently found.
655 // if the name matches, the current node is returned by the function.
656 if (_wcsicmp(szFirstFile, conductor->FileName) == 0)
657 {
658 currentNode = conductor;
659 }
660
661 conductor->Next = QuickAlloc(sizeof(SHIMGVW_FILENODE), FALSE);
662
663 // if QuickAlloc fails, make circular what we have and return it
664 if (!conductor->Next)
665 {
666 DPRINT1("QuickAlloc() failed in pLoadFileList()\n");
667
668 conductor->Next = root;
669 root->Prev = conductor;
670
671 FindClose(hFindHandle);
672 QuickFree(codecInfo);
673 return conductor;
674 }
675
676 conductor->Next->Prev = conductor;
677 conductor = conductor->Next;
678 }
679 while (FindNextFileW(hFindHandle, &findData) != 0);
680
681 FindClose(hFindHandle);
682 }
683
684 extension = wcstok(NULL, L";");
685 }
686 }
687
688 // we now have a node too much in the list. In case the requested file was not found,
689 // we use this node to store the name of it, otherwise we free it.
690 if (currentNode == NULL)
691 {
692 StringCchCopyW(conductor->FileName, MAX_PATH, szFirstFile);
693 currentNode = conductor;
694 }
695 else
696 {
697 conductor = conductor->Prev;
698 QuickFree(conductor->Next);
699 }
700
701 // link the last node with the first one to make the list circular
702 conductor->Next = root;
703 root->Prev = conductor;
704 conductor = currentNode;
705
706 QuickFree(codecInfo);
707
708 return conductor;
709}
struct _root root
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4994
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:5018
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
GLsizeiptr size
Definition: glext.h:5919
GLuint GLuint num
Definition: glext.h:9618
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
unsigned int UINT
Definition: ndis.h:50
#define PathCombineW
Definition: pathcch.h:317
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
WCHAR FileName[MAX_PATH]
Definition: shimgvw.h:45
struct tagSHIMGVW_FILENODE * Next
Definition: shimgvw.h:47
struct tagSHIMGVW_FILENODE * Prev
Definition: shimgvw.h:46

Referenced by Preview_Delete(), Preview_OnCreate(), and Preview_OnDropFiles().

◆ pFreeFileList()

static VOID pFreeFileList ( SHIMGVW_FILENODE root)
static

Definition at line 712 of file shimgvw.c.

713{
714 SHIMGVW_FILENODE *conductor;
715
716 if (!root)
717 return;
718
719 root->Prev->Next = NULL;
720 root->Prev = NULL;
721
722 while (root)
723 {
724 conductor = root;
725 root = conductor->Next;
726 QuickFree(conductor);
727 }
728}

Referenced by Preview_Delete(), Preview_OnDestroy(), and Preview_OnDropFiles().

◆ Preview_CreateToolBar()

static BOOL Preview_CreateToolBar ( PPREVIEW_DATA  pData)
static

Definition at line 942 of file shimgvw.c.

943{
944 HWND hwndToolBar;
945 HIMAGELIST hImageList, hOldImageList;
947
948 if (!Preview_IsMainWnd(pData->m_hwnd))
949 return TRUE; /* FIXME */
950
951 style |= CCS_BOTTOM;
952 hwndToolBar = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL, style,
953 0, 0, 0, 0, pData->m_hwnd, NULL, g_hInstance, NULL);
954 if (!hwndToolBar)
955 return FALSE;
956
957 pData->m_hwndToolBar = hwndToolBar;
958
959 SendMessageW(hwndToolBar, TB_BUTTONSTRUCTSIZE, sizeof(s_Buttons[0]), 0);
961
963 if (hImageList == NULL)
964 return FALSE;
965
966 for (UINT n = 0; n < _countof(s_ButtonConfig); n++)
967 {
969 ImageList_AddMasked(hImageList, hBitmap, RGB(255, 255, 255));
971 }
972
973 hOldImageList = (HIMAGELIST)SendMessageW(hwndToolBar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
974 ImageList_Destroy(hOldImageList);
975
977
978 return TRUE;
979}
Arabic default style
Definition: afstyles.h:94
static HBITMAP hBitmap
Definition: timezone.c:26
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define RGB(r, g, b)
Definition: precomp.h:71
pKey DeleteObject()
GLdouble n
Definition: glext.h:7729
static HBITMAP
Definition: button.c:44
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define TB_ADDBUTTONS
Definition: commctrl.h:1271
#define TB_SETEXTENDEDSTYLE
Definition: commctrl.h:1190
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define CCS_BOTTOM
Definition: commctrl.h:2244
struct _IMAGELIST * HIMAGELIST
Definition: commctrl.h:324
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TB_SETIMAGELIST
Definition: commctrl.h:1150
#define TBSTYLE_EX_HIDECLIPPEDBUTTONS
Definition: commctrl.h:1013
#define TOOLBARCLASSNAMEW
Definition: commctrl.h:943
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define ILC_MASK
Definition: commctrl.h:351
#define ILC_COLOR24
Definition: commctrl.h:357
static BOOL Preview_IsMainWnd(HWND hwnd)
Definition: shimgvw.c:124
#define TB_IMAGE_HEIGHT
Definition: shimgvw.c:18
static const TBBUTTON s_Buttons[]
Definition: shimgvw.c:47
#define TB_IMAGE_WIDTH
Definition: shimgvw.c:17
static const TB_BUTTON_CONFIG s_ButtonConfig[]
Definition: shimgvw.c:82
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
LONG_PTR LPARAM
Definition: windef.h:208
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2163
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by Preview_OnCreate().

◆ Preview_Delete()

static VOID Preview_Delete ( PPREVIEW_DATA  pData)
static

Definition at line 1313 of file shimgvw.c.

1314{
1315 WCHAR szCurFile[MAX_PATH + 1], szNextFile[MAX_PATH];
1316 HWND hwnd = pData->m_hwnd;
1317 SHFILEOPSTRUCTW FileOp = { hwnd, FO_DELETE };
1318
1319 if (!pData->m_szFile[0])
1320 return;
1321
1322 /* FileOp.pFrom must be double-null-terminated */
1323 GetFullPathNameW(pData->m_szFile, _countof(szCurFile) - 1, szCurFile, NULL);
1324 szCurFile[_countof(szCurFile) - 2] = UNICODE_NULL; /* Avoid buffer overrun */
1325 szCurFile[lstrlenW(szCurFile) + 1] = UNICODE_NULL;
1326
1327 szNextFile[0] = UNICODE_NULL;
1328 if (g_pCurrentFile)
1329 {
1330 GetFullPathNameW(g_pCurrentFile->Next->FileName, _countof(szNextFile), szNextFile, NULL);
1331 szNextFile[_countof(szNextFile) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
1332 }
1333
1334 /* Confirm file deletion and delete if allowed */
1335 FileOp.pFrom = szCurFile;
1336 FileOp.fFlags = FOF_ALLOWUNDO;
1337 if (SHFileOperationW(&FileOp) != 0)
1338 {
1339 DPRINT("Preview_Delete: SHFileOperationW() failed or canceled\n");
1340 return;
1341 }
1342
1343 /* Reload the file list and go next file */
1345 g_pCurrentFile = pBuildFileList(szNextFile);
1347}
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
#define UNICODE_NULL
#define FOF_ALLOWUNDO
Definition: shellapi.h:147
#define FO_DELETE
Definition: shellapi.h:138
SHIMGVW_FILENODE * g_pCurrentFile
Definition: shimgvw.c:27
static VOID Preview_pLoadImageFromNode(PPREVIEW_DATA pData, SHIMGVW_FILENODE *pNode)
Definition: shimgvw.c:426
static SHIMGVW_FILENODE * pBuildFileList(LPCWSTR szFirstFile)
Definition: shimgvw.c:599
static VOID pFreeFileList(SHIMGVW_FILENODE *root)
Definition: shimgvw.c:712
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1987
LPCWSTR pFrom
Definition: shellapi.h:357
FILEOP_FLAGS fFlags
Definition: shellapi.h:359

Referenced by Preview_OnCommand().

◆ Preview_Edit()

static VOID Preview_Edit ( HWND  hwnd)
static

Definition at line 1350 of file shimgvw.c.

1351{
1354
1355 if (!pData->m_szFile[0])
1356 return;
1357
1358 ZeroMemory(&sei, sizeof(sei));
1359 sei.cbSize = sizeof(sei);
1360 sei.lpVerb = L"edit";
1361 sei.lpFile = pData->m_szFile;
1362 sei.nShow = SW_SHOWNORMAL;
1363 if (!ShellExecuteExW(&sei))
1364 {
1365 DPRINT1("Preview_Edit: ShellExecuteExW() failed with code %ld\n", GetLastError());
1366 }
1367 else
1368 {
1369 // Destroy the window to quit the application
1371 }
1372}
static PPREVIEW_DATA Preview_GetData(HWND hwnd)
Definition: shimgvw.c:118
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2391
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Preview_OnCommand().

◆ Preview_EndSlideShow()

static VOID Preview_EndSlideShow ( HWND  hwnd)
static

Definition at line 982 of file shimgvw.c.

983{
985 return;
986
991}
static VOID Preview_ResetZoom(PPREVIEW_DATA pData)
Definition: shimgvw.c:274
HWND g_hMainWnd
Definition: shimgvw.c:25
#define SLIDESHOW_TIMER_ID
Definition: shimgvw.c:21
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by Preview_OnCommand(), and ZoomWnd_OnButtonDown().

◆ Preview_GetData()

◆ Preview_GoNextPic()

static VOID Preview_GoNextPic ( PPREVIEW_DATA  pData,
BOOL  bNext 
)
static

Definition at line 1401 of file shimgvw.c.

1402{
1403 Preview_RestartTimer(pData->m_hwnd);
1404 if (g_pCurrentFile)
1405 {
1406 if (bNext)
1408 else
1413 }
1414}
static VOID Preview_UpdateImage(PPREVIEW_DATA pData)
Definition: shimgvw.c:590
static VOID Preview_RestartTimer(HWND hwnd)
Definition: shimgvw.c:130
static VOID Preview_UpdateUI(PPREVIEW_DATA pData)
Definition: shimgvw.c:582

Referenced by Preview_OnCommand(), and PreviewWndProc().

◆ Preview_IsMainWnd()

static BOOL Preview_IsMainWnd ( HWND  hwnd)
inlinestatic

◆ Preview_OnCommand()

static VOID Preview_OnCommand ( HWND  hwnd,
UINT  nCommandID 
)
static

Definition at line 1417 of file shimgvw.c.

1418{
1420
1421 switch (nCommandID)
1422 {
1423 case IDC_PREV_PIC:
1425 break;
1426
1427 case IDC_NEXT_PIC:
1429 break;
1430
1431 case IDC_BEST_FIT:
1433 break;
1434
1435 case IDC_REAL_SIZE:
1437 break;
1438
1439 case IDC_SLIDE_SHOW:
1441 break;
1442
1443 case IDC_ZOOM_IN:
1445 break;
1446
1447 case IDC_ZOOM_OUT:
1449 break;
1450
1451 case IDC_ENDSLIDESHOW:
1453 break;
1454
1455 default:
1456 break;
1457 }
1458
1459 if (!Preview_IsMainWnd(hwnd))
1460 return;
1461
1462 // The following commands are for main window only:
1463 switch (nCommandID)
1464 {
1465 case IDC_SAVEAS:
1467 break;
1468
1469 case IDC_PRINT:
1471 break;
1472
1473 case IDC_ROT_CLOCKW:
1474 if (g_pImage)
1475 {
1478 }
1479 break;
1480
1481 case IDC_ROT_COUNCW:
1482 if (g_pImage)
1483 {
1486 }
1487 break;
1488
1489 case IDC_ROT_CWSAVE:
1490 if (g_pImage)
1491 {
1493 Preview_pSaveImage(pData, pData->m_szFile);
1495 }
1496 break;
1497
1498 case IDC_ROT_CCWSAVE:
1499 if (g_pImage)
1500 {
1502 Preview_pSaveImage(pData, pData->m_szFile);
1504 }
1505 break;
1506
1507 case IDC_DELETE:
1511 break;
1512
1513 case IDC_MODIFY:
1515 break;
1516
1517 default:
1518 break;
1519 }
1520}
#define IDC_SAVEAS
Definition: resource.h:17
GpStatus WINGDIPAPI GdipImageRotateFlip(GpImage *image, RotateFlipType type)
Definition: image.c:5406
#define IDC_ZOOM_IN
Definition: resource.h:39
#define IDC_SLIDE_SHOW
Definition: resource.h:38
#define IDC_ROT_COUNCW
Definition: resource.h:42
#define IDC_REAL_SIZE
Definition: resource.h:37
#define IDC_MODIFY
Definition: resource.h:48
#define IDC_ENDSLIDESHOW
Definition: resource.h:50
#define IDC_NEXT_PIC
Definition: resource.h:35
#define IDC_ROT_CWSAVE
Definition: resource.h:43
#define IDC_PREV_PIC
Definition: resource.h:34
#define IDC_BEST_FIT
Definition: resource.h:36
#define IDC_DELETE
Definition: resource.h:45
#define IDC_ZOOM_OUT
Definition: resource.h:40
#define IDC_ROT_CLOCKW
Definition: resource.h:41
#define IDC_ROT_CCWSAVE
Definition: resource.h:44
#define IDC_PRINT
Definition: fontview.h:14
@ Rotate270FlipNone
@ Rotate90FlipNone
static VOID Preview_Delete(PPREVIEW_DATA pData)
Definition: shimgvw.c:1313
static VOID Preview_ToggleSlideShow(PPREVIEW_DATA pData)
Definition: shimgvw.c:1375
static VOID Preview_UpdateZoom(PPREVIEW_DATA pData, UINT NewZoom, BOOL bEnableBestFit, BOOL bEnableRealSize)
Definition: shimgvw.c:212
static VOID Preview_GoNextPic(PPREVIEW_DATA pData, BOOL bNext)
Definition: shimgvw.c:1401
static VOID Preview_pPrintImage(PPREVIEW_DATA pData)
Definition: shimgvw.c:576
static VOID Preview_EndSlideShow(HWND hwnd)
Definition: shimgvw.c:982
static VOID Preview_ZoomInOrOut(PPREVIEW_DATA pData, BOOL bZoomIn)
Definition: shimgvw.c:240
static VOID Preview_pSaveImageAs(PPREVIEW_DATA pData)
Definition: shimgvw.c:479
static BOOL Preview_pSaveImage(PPREVIEW_DATA pData, LPCWSTR pszFile)
Definition: shimgvw.c:432
GpImage * g_pImage
Definition: shimgvw.c:28
static VOID Preview_Edit(HWND hwnd)
Definition: shimgvw.c:1350

Referenced by PreviewWndProc().

◆ Preview_OnCreate()

static BOOL Preview_OnCreate ( HWND  hwnd,
LPCREATESTRUCT  pCS 
)
static

Definition at line 1200 of file shimgvw.c.

1201{
1202 DWORD exstyle = 0;
1203 HWND hwndZoom;
1205 pData->m_hwnd = hwnd;
1207
1209
1210 if (g_hMainWnd == NULL)
1211 {
1212 g_hMainWnd = hwnd;
1213 exstyle |= WS_EX_CLIENTEDGE;
1214 }
1215 else if (g_hwndFullscreen == NULL)
1216 {
1218 }
1219 else
1220 {
1221 return FALSE;
1222 }
1223
1224 hwndZoom = CreateWindowExW(exstyle, WC_ZOOM, NULL, WS_CHILD | WS_VISIBLE,
1225 0, 0, 0, 0, hwnd, NULL, g_hInstance, NULL);
1226 if (!hwndZoom)
1227 {
1229 return FALSE;
1230 }
1231
1232 pData->m_hwndZoom = hwndZoom;
1234 Anime_SetTimerWnd(&pData->m_Anime, pData->m_hwndZoom);
1235
1237 {
1239 return FALSE;
1240 }
1241
1242 if (pCS && pCS->lpCreateParams)
1243 {
1245 WCHAR szFile[MAX_PATH];
1246
1247 /* Make sure the path has no quotes on it */
1248 StringCchCopyW(szFile, _countof(szFile), pszFileName);
1249 PathUnquoteSpacesW(szFile);
1250
1255 }
1256
1257 return TRUE;
1258}
void Anime_SetTimerWnd(PANIME pAnime, HWND hwndTimer)
Definition: anime.c:25
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:522
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static BOOL Preview_CreateToolBar(PPREVIEW_DATA pData)
Definition: shimgvw.c:942
LPVOID lpCreateParams
Definition: winuser.h:2940
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define SetWindowLongPtrW
Definition: winuser.h:5346

Referenced by PreviewWndProc().

◆ Preview_OnDestroy()

static VOID Preview_OnDestroy ( HWND  hwnd)
static

Definition at line 1539 of file shimgvw.c.

1540{
1542
1544
1547
1549
1550 SetWindowLongPtrW(pData->m_hwndZoom, GWLP_USERDATA, 0);
1551 DestroyWindow(pData->m_hwndZoom);
1552 pData->m_hwndZoom = NULL;
1553
1554 DestroyWindow(pData->m_hwndToolBar);
1555 pData->m_hwndToolBar = NULL;
1556
1559
1560 PostQuitMessage(0);
1561}
static VOID Preview_pFreeImage(PPREVIEW_DATA pData)
Definition: shimgvw.c:338
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by PreviewWndProc().

◆ Preview_OnDropFiles()

static VOID Preview_OnDropFiles ( HWND  hwnd,
HDROP  hDrop 
)
static

Definition at line 1564 of file shimgvw.c.

1565{
1566 WCHAR szFile[MAX_PATH];
1568
1569 DragQueryFileW(hDrop, 0, szFile, _countof(szFile));
1570
1574
1575 DragFinish(hDrop);
1576}
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:538
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:622

Referenced by PreviewWndProc().

◆ Preview_OnMoveSize()

static VOID Preview_OnMoveSize ( HWND  hwnd)
static

Definition at line 1261 of file shimgvw.c.

1262{
1263 WINDOWPLACEMENT wp;
1264 RECT *prc;
1265
1267 return;
1268
1269 wp.length = sizeof(WINDOWPLACEMENT);
1271
1272 /* Remember window position and size */
1273 prc = &wp.rcNormalPosition;
1274 g_Settings.X = prc->left;
1275 g_Settings.Y = prc->top;
1279}
_Out_ LPRECT prc
Definition: ntgdi.h:1658
RECT rcNormalPosition
Definition: winuser.h:3295
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
BOOL WINAPI IsIconic(_In_ HWND)
BOOL WINAPI IsZoomed(_In_ HWND)
struct _WINDOWPLACEMENT WINDOWPLACEMENT

Referenced by Preview_OnSize(), and PreviewWndProc().

◆ Preview_OnNotify()

static LRESULT Preview_OnNotify ( HWND  hwnd,
LPNMHDR  pnmhdr 
)
static

Definition at line 1523 of file shimgvw.c.

1524{
1525 switch (pnmhdr->code)
1526 {
1527 case TTN_GETDISPINFOW:
1528 {
1529 LPTOOLTIPTEXTW lpttt = (LPTOOLTIPTEXTW)pnmhdr;
1530 lpttt->hinst = g_hInstance;
1531 lpttt->lpszText = MAKEINTRESOURCEW(s_ButtonConfig[lpttt->hdr.idFrom - IDC_TOOL_BASE].ids);
1532 break;
1533 }
1534 }
1535 return 0;
1536}
#define IDC_TOOL_BASE
Definition: resource.h:32
#define LPTOOLTIPTEXTW
Definition: commctrl.h:1887
#define TTN_GETDISPINFOW
Definition: commctrl.h:1873
UINT code
Definition: winuser.h:3159

Referenced by PreviewWndProc().

◆ Preview_OnSize()

static VOID Preview_OnSize ( HWND  hwnd)
static

Definition at line 1282 of file shimgvw.c.

1283{
1284 RECT rc, rcClient;
1286 HWND hToolBar = pData->m_hwndToolBar;
1287 INT cx, cy;
1288
1289 /* We want 32-bit values. Don't use WM_SIZE lParam */
1290 GetClientRect(hwnd, &rcClient);
1291 cx = rcClient.right;
1292 cy = rcClient.bottom;
1293
1294 if (Preview_IsMainWnd(pData->m_hwnd))
1295 {
1297 GetWindowRect(hToolBar, &rc);
1298
1299 MoveWindow(pData->m_hwndZoom, 0, 0, cx, cy - (rc.bottom - rc.top), TRUE);
1300
1301 if (!IsIconic(hwnd)) /* Is it not minimized? */
1303
1305 }
1306 else
1307 {
1308 MoveWindow(pData->m_hwndZoom, 0, 0, cx, cy, TRUE);
1309 }
1310}
HWND hToolBar
Definition: mplay32.c:23
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define TB_AUTOSIZE
Definition: commctrl.h:1137
_Out_opt_ int * cx
Definition: commctrl.h:585
static VOID Preview_OnMoveSize(HWND hwnd)
Definition: shimgvw.c:1261
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by PreviewWndProc().

◆ Preview_pFreeImage()

static VOID Preview_pFreeImage ( PPREVIEW_DATA  pData)
static

Definition at line 338 of file shimgvw.c.

339{
340 Anime_FreeInfo(&pData->m_Anime);
341
342 if (g_pImage)
343 {
345 g_pImage = NULL;
346 }
347
348 if (pData->m_pMemStream)
349 {
350 pData->m_pMemStream->lpVtbl->Release(pData->m_pMemStream);
351 pData->m_pMemStream = NULL;
352 }
353
354 pData->m_szFile[0] = UNICODE_NULL;
355}
void Anime_FreeInfo(PANIME pAnime)
Definition: anime.c:12
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155

Referenced by Preview_OnDestroy(), and Preview_pLoadImage().

◆ Preview_pLoadImage()

static VOID Preview_pLoadImage ( PPREVIEW_DATA  pData,
LPCWSTR  szOpenFileName 
)
static

Definition at line 391 of file shimgvw.c.

392{
394
395 pData->m_pMemStream = MemStreamFromFile(szOpenFileName);
396 if (!pData->m_pMemStream)
397 {
398 DPRINT1("MemStreamFromFile() failed\n");
400 return;
401 }
402
403 /* NOTE: GdipLoadImageFromFile locks the file.
404 Avoid file locking by using GdipLoadImageFromStream and memory stream. */
405 GdipLoadImageFromStream(pData->m_pMemStream, &g_pImage);
406 if (!g_pImage)
407 {
408 DPRINT1("GdipLoadImageFromStream() failed\n");
411 return;
412 }
413
414 Anime_LoadInfo(&pData->m_Anime);
415
416 SHAddToRecentDocs(SHARD_PATHW, szOpenFileName);
417 GetFullPathNameW(szOpenFileName, _countof(pData->m_szFile), pData->m_szFile, NULL);
418
419 /* Reset zoom and redraw display */
421
422 Preview_UpdateTitle(pData, szOpenFileName);
423}
BOOL Anime_LoadInfo(PANIME pAnime)
Definition: anime.c:89
GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream *stream, GpImage **image)
Definition: image.c:4405
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:813
static VOID Preview_UpdateTitle(PPREVIEW_DATA pData, LPCWSTR FileName)
Definition: shimgvw.c:320
IStream * MemStreamFromFile(LPCWSTR pszFileName)
Definition: shimgvw.c:357
#define SHARD_PATHW
Definition: shlobj.h:1169

Referenced by Preview_pLoadImageFromNode().

◆ Preview_pLoadImageFromNode()

static VOID Preview_pLoadImageFromNode ( PPREVIEW_DATA  pData,
SHIMGVW_FILENODE pNode 
)
static

Definition at line 426 of file shimgvw.c.

427{
428 Preview_pLoadImage(pData, (pNode ? pNode->FileName : NULL));
429}
static VOID Preview_pLoadImage(PPREVIEW_DATA pData, LPCWSTR szOpenFileName)
Definition: shimgvw.c:391

Referenced by Preview_Delete(), Preview_GoNextPic(), Preview_OnCreate(), and Preview_OnDropFiles().

◆ Preview_pPrintImage()

static VOID Preview_pPrintImage ( PPREVIEW_DATA  pData)
static

Definition at line 576 of file shimgvw.c.

577{
578 /* FIXME */
579}

Referenced by Preview_OnCommand().

◆ Preview_pSaveImage()

static BOOL Preview_pSaveImage ( PPREVIEW_DATA  pData,
LPCWSTR  pszFile 
)
static

Definition at line 432 of file shimgvw.c.

433{
434 ImageCodecInfo *codecInfo;
435 GUID rawFormat;
436 UINT j, num, nFilterIndex, size;
437 BOOL ret = FALSE;
438
439 if (g_pImage == NULL)
440 return FALSE;
441
443 codecInfo = QuickAlloc(size, FALSE);
444 if (!codecInfo)
445 {
446 DPRINT1("QuickAlloc() failed in pSaveImage()\n");
447 return FALSE;
448 }
449 GdipGetImageEncoders(num, size, codecInfo);
450
451 GdipGetImageRawFormat(g_pImage, &rawFormat);
452 if (IsEqualGUID(&rawFormat, &ImageFormatMemoryBMP))
453 rawFormat = ImageFormatBMP;
454
455 nFilterIndex = 0;
456 for (j = 0; j < num; ++j)
457 {
458 if (IsEqualGUID(&rawFormat, &codecInfo[j].FormatID))
459 {
460 nFilterIndex = j + 1;
461 break;
462 }
463 }
464
465 Anime_Pause(&pData->m_Anime);
466
467 ret = (nFilterIndex > 0) &&
468 (GdipSaveImageToFile(g_pImage, pszFile, &codecInfo[nFilterIndex - 1].Clsid, NULL) == Ok);
469 if (!ret)
470 DPRINT1("GdipSaveImageToFile() failed\n");
471
472 Anime_Start(&pData->m_Anime, 0);
473
474 QuickFree(codecInfo);
475 return ret;
476}
void Anime_Start(PANIME pAnime, DWORD dwDelay)
Definition: anime.c:35
void Anime_Pause(PANIME pAnime)
Definition: anime.c:30
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
Definition: image.c:2354
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:5045
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
Definition: image.c:4476
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5069
unsigned int BOOL
Definition: ntddk_ex.h:94
@ Ok
Definition: gdiplustypes.h:26
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
int ret

Referenced by Preview_OnCommand().

◆ Preview_pSaveImageAs()

static VOID Preview_pSaveImageAs ( PPREVIEW_DATA  pData)
static

Definition at line 479 of file shimgvw.c.

480{
482 ImageCodecInfo *codecInfo;
483 WCHAR szSaveFileName[MAX_PATH];
484 WCHAR *szFilterMask;
485 GUID rawFormat;
486 UINT num, size, j;
487 size_t sizeRemain;
488 WCHAR *c;
489 HWND hwnd = pData->m_hwnd;
490
491 if (g_pImage == NULL)
492 return;
493
495 codecInfo = QuickAlloc(size, FALSE);
496 if (!codecInfo)
497 {
498 DPRINT1("QuickAlloc() failed in pSaveImageAs()\n");
499 return;
500 }
501
502 GdipGetImageEncoders(num, size, codecInfo);
503
504 GdipGetImageRawFormat(g_pImage, &rawFormat);
505 if (IsEqualGUID(&rawFormat, &ImageFormatMemoryBMP))
506 rawFormat = ImageFormatBMP;
507
508 sizeRemain = 0;
509 for (j = 0; j < num; ++j)
510 {
511 // 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.
512 sizeRemain = sizeRemain + (((wcslen(codecInfo[j].FormatDescription) + (wcslen(codecInfo[j].FilenameExtension) * 2) + 5) * sizeof(WCHAR)));
513 }
514
515 /* Add two more chars for the last terminator */
516 sizeRemain += (sizeof(WCHAR) * 2);
517
518 szFilterMask = QuickAlloc(sizeRemain, FALSE);
519 if (!szFilterMask)
520 {
521 DPRINT1("cannot allocate memory for filter mask in pSaveImageAs()");
522 QuickFree(codecInfo);
523 return;
524 }
525
526 ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
527 ZeroMemory(szFilterMask, sizeRemain);
528 ZeroMemory(&sfn, sizeof(sfn));
529 sfn.lStructSize = sizeof(sfn);
531 sfn.lpstrFile = szSaveFileName;
532 sfn.lpstrFilter = szFilterMask;
533 sfn.nMaxFile = _countof(szSaveFileName);
535 sfn.lpstrDefExt = L"png";
536
537 c = szFilterMask;
538
539 for (j = 0; j < num; ++j)
540 {
541 StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", codecInfo[j].FormatDescription, codecInfo[j].FilenameExtension);
542
543 /* Skip the NULL character */
544 c++;
545 sizeRemain -= sizeof(*c);
546
547 StringCbPrintfExW(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", codecInfo[j].FilenameExtension);
548
549 /* Skip the NULL character */
550 c++;
551 sizeRemain -= sizeof(*c);
552
553 if (IsEqualGUID(&rawFormat, &codecInfo[j].FormatID))
554 {
555 sfn.nFilterIndex = j + 1;
556 }
557 }
558
560 {
561 Anime_Pause(&pData->m_Anime);
562
563 if (GdipSaveImageToFile(g_pImage, szSaveFileName, &codecInfo[sfn.nFilterIndex - 1].Clsid, NULL) != Ok)
564 {
565 DPRINT1("GdipSaveImageToFile() failed\n");
566 }
567
568 Anime_Start(&pData->m_Anime, 0);
569 }
570
571 QuickFree(szFilterMask);
572 QuickFree(codecInfo);
573}
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4801
OPENFILENAMEW sfn
Definition: eventvwr.c:101
const GLubyte * c
Definition: glext.h:8905
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define c
Definition: ke_i.h:80
STRSAFEAPI StringCbPrintfExW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcbRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:623
HWND hwndOwner
Definition: commdlg.h:361
DWORD Flags
Definition: commdlg.h:373
LPWSTR lpstrFile
Definition: commdlg.h:367
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
DWORD lStructSize
Definition: commdlg.h:360
DWORD nMaxFile
Definition: commdlg.h:368
LPCWSTR lpstrFilter
Definition: commdlg.h:363
DWORD nFilterIndex
Definition: commdlg.h:366

Referenced by Preview_OnCommand().

◆ Preview_ResetZoom()

static VOID Preview_ResetZoom ( PPREVIEW_DATA  pData)
static

Definition at line 274 of file shimgvw.c.

275{
276 RECT Rect;
277 UINT ImageWidth, ImageHeight, NewZoom;
278
279 if (g_pImage == NULL)
280 return;
281
282 /* get disp window size and image size */
283 GetClientRect(pData->m_hwndZoom, &Rect);
284 GdipGetImageWidth(g_pImage, &ImageWidth);
285 GdipGetImageHeight(g_pImage, &ImageHeight);
286
287 /* compare two aspect rates. same as
288 (ImageHeight / ImageWidth < Rect.bottom / Rect.right) in real */
289 if (ImageHeight * Rect.right < Rect.bottom * ImageWidth)
290 {
291 if (Rect.right < ImageWidth)
292 {
293 /* it's large, shrink it */
294 NewZoom = (Rect.right * 100) / ImageWidth;
295 }
296 else
297 {
298 /* it's small. show as original size */
299 NewZoom = 100;
300 }
301 }
302 else
303 {
304 if (Rect.bottom < ImageHeight)
305 {
306 /* it's large, shrink it */
307 NewZoom = (Rect.bottom * 100) / ImageHeight;
308 }
309 else
310 {
311 /* it's small. show as original size */
312 NewZoom = 100;
313 }
314 }
315
317}
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2390
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2287

Referenced by Preview_EndSlideShow(), Preview_OnCommand(), Preview_OnSize(), Preview_pLoadImage(), and Preview_UpdateImage().

◆ Preview_RestartTimer()

static VOID Preview_RestartTimer ( HWND  hwnd)
static

Definition at line 130 of file shimgvw.c.

131{
133 {
136 }
137}
#define SLIDESHOW_TIMER_INTERVAL
Definition: shimgvw.c:22
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

Referenced by Preview_GoNextPic(), Preview_ToggleSlideShow(), and Preview_UpdateZoom().

◆ Preview_ToggleSlideShow()

static VOID Preview_ToggleSlideShow ( PPREVIEW_DATA  pData)
static

Definition at line 1375 of file shimgvw.c.

1376{
1378 {
1380 WCHAR szTitle[256];
1383 0, 0, 0, 0, NULL, NULL, g_hInstance, NULL);
1384 }
1385
1387 {
1391 }
1392 else
1393 {
1397 }
1398}
#define WS_POPUP
Definition: pedump.c:616
#define WS_EX_TOPMOST
Definition: pedump.c:647
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by Preview_OnCommand().

◆ Preview_UpdateImage()

static VOID Preview_UpdateImage ( PPREVIEW_DATA  pData)
static

Definition at line 590 of file shimgvw.c.

591{
592 if (!Preview_IsMainWnd(pData->m_hwnd))
594
595 ZoomWnd_UpdateScroll(pData, pData->m_hwndZoom, TRUE);
596}
static VOID ZoomWnd_UpdateScroll(PPREVIEW_DATA pData, HWND hwnd, BOOL bResetPos)
Definition: shimgvw.c:140

Referenced by Preview_GoNextPic(), Preview_OnCommand(), and Preview_OnCreate().

◆ Preview_UpdateTitle()

static VOID Preview_UpdateTitle ( PPREVIEW_DATA  pData,
LPCWSTR  FileName 
)
static

Definition at line 320 of file shimgvw.c.

321{
322 WCHAR szText[MAX_PATH + 100];
323 LPWSTR pchFileTitle;
324
325 LoadStringW(g_hInstance, IDS_APPTITLE, szText, _countof(szText));
326
327 pchFileTitle = PathFindFileNameW(FileName);
328 if (pchFileTitle && *pchFileTitle)
329 {
330 StringCchCatW(szText, _countof(szText), L" - ");
331 StringCchCatW(szText, _countof(szText), pchFileTitle);
332 }
333
334 SetWindowTextW(pData->m_hwnd, szText);
335}
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Preview_pLoadImage().

◆ Preview_UpdateUI()

static VOID Preview_UpdateUI ( PPREVIEW_DATA  pData)
static

Definition at line 582 of file shimgvw.c.

583{
584 BOOL bEnable = (g_pImage != NULL);
587}
#define TB_ENABLEBUTTON
Definition: commctrl.h:1042
_In_ BOOL bEnable
Definition: winddi.h:3426
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by Preview_GoNextPic(), Preview_OnCommand(), and Preview_OnCreate().

◆ Preview_UpdateZoom()

static VOID Preview_UpdateZoom ( PPREVIEW_DATA  pData,
UINT  NewZoom,
BOOL  bEnableBestFit,
BOOL  bEnableRealSize 
)
static

Definition at line 212 of file shimgvw.c.

213{
214 BOOL bEnableZoomIn, bEnableZoomOut;
215 HWND hToolBar = pData->m_hwndToolBar;
216
217 pData->m_nZoomPercents = NewZoom;
218
219 /* Check if a zoom button of the toolbar must be grayed */
220 bEnableZoomIn = (NewZoom < MAX_ZOOM);
221 bEnableZoomOut = (NewZoom > MIN_ZOOM);
222
223 /* Update toolbar buttons */
228
229 /* Redraw the display window */
230 InvalidateRect(pData->m_hwndZoom, NULL, TRUE);
231
232 /* Restart timer if necessary */
234
235 /* Update scroll info */
236 ZoomWnd_UpdateScroll(pData, pData->m_hwndZoom, FALSE);
237}
#define MAX_ZOOM
Definition: shimgvw.c:37
#define MIN_ZOOM
Definition: shimgvw.c:36
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by Preview_OnCommand(), Preview_ResetZoom(), and Preview_ZoomInOrOut().

◆ Preview_ZoomInOrOut()

static VOID Preview_ZoomInOrOut ( PPREVIEW_DATA  pData,
BOOL  bZoomIn 
)
static

Definition at line 240 of file shimgvw.c.

241{
242 UINT i, NewZoom;
243
244 if (g_pImage == NULL)
245 return;
246
247 if (bZoomIn) /* zoom in */
248 {
249 /* find next step */
250 for (i = 0; i < _countof(s_ZoomSteps); ++i)
251 {
252 if (pData->m_nZoomPercents < s_ZoomSteps[i])
253 break;
254 }
255 NewZoom = ((i >= _countof(s_ZoomSteps)) ? MAX_ZOOM : s_ZoomSteps[i]);
256 }
257 else /* zoom out */
258 {
259 /* find previous step */
260 for (i = _countof(s_ZoomSteps); i > 0; )
261 {
262 --i;
263 if (s_ZoomSteps[i] < pData->m_nZoomPercents)
264 break;
265 }
266 NewZoom = ((i < 0) ? MIN_ZOOM : s_ZoomSteps[i]);
267 }
268
269 /* Update toolbar and refresh screen */
270 Preview_UpdateZoom(pData, NewZoom, TRUE, TRUE);
271}
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
static const UINT s_ZoomSteps[]
Definition: shimgvw.c:31

Referenced by Preview_OnCommand(), and ZoomWnd_OnMouseWheel().

◆ PreviewWndProc()

LRESULT CALLBACK PreviewWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1579 of file shimgvw.c.

1580{
1581 switch (uMsg)
1582 {
1583 case WM_CREATE:
1584 {
1586 return -1;
1587 break;
1588 }
1589 case WM_COMMAND:
1590 {
1592 break;
1593 }
1594 case WM_NOTIFY:
1595 {
1597 }
1598 case WM_GETMINMAXINFO:
1599 {
1600 MINMAXINFO *pMMI = (MINMAXINFO*)lParam;
1601 pMMI->ptMinTrackSize.x = 350;
1602 pMMI->ptMinTrackSize.y = 290;
1603 break;
1604 }
1605 case WM_MOVE:
1606 {
1608 break;
1609 }
1610 case WM_SIZE:
1611 {
1613 break;
1614 }
1615 case WM_DROPFILES:
1616 {
1618 break;
1619 }
1620 case WM_SYSCOLORCHANGE:
1621 {
1623 InvalidateRect(pData->m_hwnd, NULL, TRUE);
1624 InvalidateRect(pData->m_hwndZoom, NULL, TRUE);
1625 break;
1626 }
1627 case WM_DESTROY:
1628 {
1630 break;
1631 }
1632 case WM_TIMER:
1633 {
1635 {
1638 }
1639 break;
1640 }
1641 default:
1642 {
1643 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
1644 }
1645 }
1646
1647 return 0;
1648}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
static BOOL Preview_OnCreate(HWND hwnd, LPCREATESTRUCT pCS)
Definition: shimgvw.c:1200
static VOID Preview_OnSize(HWND hwnd)
Definition: shimgvw.c:1282
static VOID Preview_OnDropFiles(HWND hwnd, HDROP hDrop)
Definition: shimgvw.c:1564
static LRESULT Preview_OnNotify(HWND hwnd, LPNMHDR pnmhdr)
Definition: shimgvw.c:1523
static VOID Preview_OnCommand(HWND hwnd, UINT nCommandID)
Definition: shimgvw.c:1417
static VOID Preview_OnDestroy(HWND hwnd)
Definition: shimgvw.c:1539
POINT ptMinTrackSize
Definition: winuser.h:3630
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1608
#define WM_SIZE
Definition: winuser.h:1611
#define WM_DROPFILES
Definition: winuser.h:1825
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1626
#define WM_GETMINMAXINFO
Definition: winuser.h:1640
#define WM_TIMER
Definition: winuser.h:1742
#define WM_MOVE
Definition: winuser.h:1610
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by ImageView_Main().

◆ ZoomWnd_OnButtonDown()

static VOID ZoomWnd_OnButtonDown ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 994 of file shimgvw.c.

995{
997 HWND hParent = GetParent(hwnd);
998 if ((uMsg == WM_LBUTTONDOWN) || (uMsg == WM_RBUTTONDOWN))
999 {
1000 if (!Preview_IsMainWnd(hParent))
1001 Preview_EndSlideShow(hParent);
1002 return;
1003 }
1004
1005 pData->m_nMouseDownMsg = uMsg;
1006 pData->m_ptOrigin.x = GET_X_LPARAM(lParam);
1007 pData->m_ptOrigin.y = GET_Y_LPARAM(lParam);
1010}
#define IDC_HANDDRAG
Definition: resource.h:25
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HWND WINAPI SetCapture(_In_ HWND hWnd)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
HWND WINAPI GetParent(_In_ HWND)

Referenced by ZoomWndProc().

◆ ZoomWnd_OnButtonUp()

static VOID ZoomWnd_OnButtonUp ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1041 of file shimgvw.c.

1042{
1044 pData->m_nMouseDownMsg = 0;
1046}
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890

Referenced by ZoomWndProc().

◆ ZoomWnd_OnDraw()

static VOID ZoomWnd_OnDraw ( PPREVIEW_DATA  pData,
HDC  hdc,
LPRECT  prcPaint,
LPRECT  prcClient 
)
static

Definition at line 751 of file shimgvw.c.

756{
757 GpGraphics *graphics;
758 INT ZoomedWidth, ZoomedHeight;
759 RECT rect, rcClient = *prcClient;
760 HDC hdcMem;
761 HBRUSH hBrush;
762 HPEN hPen;
763 HGDIOBJ hbrOld, hbmOld, hPenOld;
764 UINT uFlags;
765 HBITMAP hbmMem;
766 SIZE paintSize = { prcPaint->right - prcPaint->left, prcPaint->bottom - prcPaint->top };
767 COLORREF color0, color1;
768 GpImageAttributes *imageAttributes;
769
770 /* We use a memory bitmap to reduce flickering */
772 hbmMem = CreateCompatibleBitmap(hdc, paintSize.cx, paintSize.cy);
773 hbmOld = SelectObject(hdcMem, hbmMem);
774
775 /* Choose colors */
776 if (Preview_IsMainWnd(pData->m_hwnd))
777 {
778 color0 = GetSysColor(COLOR_WINDOW);
780 }
781 else
782 {
783 color0 = RGB(0, 0, 0);
784 color1 = RGB(255, 255, 255);
785 }
786
787 hBrush = CreateSolidBrush(color0);
788 SetBkColor(hdcMem, color0);
789
790 hPen = CreatePen(PS_SOLID, 1, color1);
791 SetTextColor(hdcMem, color1);
792
793 /* Fill background */
794 SetRect(&rect, 0, 0, paintSize.cx, paintSize.cy);
795 FillRect(hdcMem, &rect, hBrush);
796
797 DeleteObject(hBrush);
798
799 if (g_pImage == NULL)
800 {
801 WCHAR szText[128];
803
805 OffsetRect(&rcClient, -prcPaint->left, -prcPaint->top);
806 DrawTextW(hdcMem, szText, -1, &rcClient, DT_SINGLELINE | DT_CENTER | DT_VCENTER |
808 }
809 else
810 {
811 UINT ImageWidth, ImageHeight;
812
813 GdipGetImageWidth(g_pImage, &ImageWidth);
814 GdipGetImageHeight(g_pImage, &ImageHeight);
815
816 ZoomedWidth = (ImageWidth * pData->m_nZoomPercents) / 100;
817 ZoomedHeight = (ImageHeight * pData->m_nZoomPercents) / 100;
818
819 GdipCreateFromHDC(hdcMem, &graphics);
820 if (!graphics)
821 {
822 DPRINT1("error: GdipCreateFromHDC\n");
823 return;
824 }
825
827
828 if (pData->m_nZoomPercents % 100 == 0)
829 {
832 }
833 else
834 {
837 }
838
839 rect.left = (rcClient.right - ZoomedWidth ) / 2;
840 rect.top = (rcClient.bottom - ZoomedHeight) / 2;
841 rect.right = rect.left + ZoomedWidth;
842 rect.bottom = rect.top + ZoomedHeight;
844 -prcPaint->left - pData->m_xScrollOffset,
845 -prcPaint->top - pData->m_yScrollOffset);
846
847 InflateRect(&rect, +1, +1); /* Add Rectangle() pen width */
848
849 /* Draw a rectangle. Fill by checker board if necessary */
852 else
854 hPenOld = SelectObject(hdcMem, hPen);
855 Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);
858
859 InflateRect(&rect, -1, -1); /* Subtract Rectangle() pen width */
860
861 /* Image attributes are required to draw image correctly */
862 GdipCreateImageAttributes(&imageAttributes);
864 GetBkColor(hdcMem) | 0xFF000000, TRUE);
865
866 /* Draw image. -0.5f is used for interpolation */
868 rect.left, rect.top,
869 rect.right - rect.left, rect.bottom - rect.top,
870 -0.5f, -0.5f, ImageWidth, ImageHeight,
871 UnitPixel, imageAttributes, NULL, NULL);
872
873 GdipDisposeImageAttributes(imageAttributes);
874 GdipDeleteGraphics(graphics);
875 }
876
877 BitBlt(hdc, prcPaint->left, prcPaint->top, paintSize.cx, paintSize.cy, hdcMem, 0, 0, SRCCOPY);
880}
UINT uFlags
Definition: api.c:59
GpStatus WINGDIPAPI GdipDrawImageRectRect(GpGraphics *graphics, GpImage *image, REAL dstx, REAL dsty, REAL dstwidth, REAL dstheight, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageattr, DrawImageAbort callback, VOID *callbackData)
Definition: graphics.c:3494
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2395
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2581
GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, InterpolationMode mode)
Definition: graphics.c:6143
GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
Definition: graphics.c:6289
GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags)
Definition: image.c:5314
#define IDS_NOPREVIEW
Definition: resource.h:72
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
@ SmoothingModeNone
Definition: gdiplusenums.h:126
@ SmoothingModeHighQuality
Definition: gdiplusenums.h:125
@ ImageFlagsHasTranslucent
Definition: gdiplusenums.h:336
@ ImageFlagsHasAlpha
Definition: gdiplusenums.h:335
@ WrapModeTile
Definition: gdiplusenums.h:207
@ UnitPixel
Definition: gdiplusenums.h:29
@ InterpolationModeHighQualityBilinear
Definition: gdiplusenums.h:149
@ InterpolationModeNearestNeighbor
Definition: gdiplusenums.h:148
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, WrapMode wrap, ARGB argb, BOOL clamp)
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
static HBRUSH CreateCheckerBoardBrush(VOID)
Definition: shimgvw.c:730
& rect
Definition: startmenu.cpp:1413
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
HDC hdcMem
Definition: welcome.c:104
DWORD COLORREF
Definition: windef.h:300
#define GetStockFont(i)
Definition: windowsx.h:308
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586
DWORD WINAPI GetSysColor(_In_ int)
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_WINDOW
Definition: winuser.h:918
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_WINDOWTEXT
Definition: winuser.h:921
#define DT_SINGLELINE
Definition: winuser.h:540
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by ZoomWnd_OnPaint().

◆ ZoomWnd_OnHVScroll()

static VOID ZoomWnd_OnHVScroll ( PPREVIEW_DATA  pData,
HWND  hwnd,
WPARAM  wParam,
BOOL  bVertical 
)
static

Definition at line 1049 of file shimgvw.c.

1050{
1051 UINT ImageWidth, ImageHeight, ZoomedWidth, ZoomedHeight;
1052 RECT rcClient;
1053 UINT nBar = (bVertical ? SB_VERT : SB_HORZ);
1054 SCROLLINFO si = { sizeof(si), SIF_ALL };
1055 GetScrollInfo(hwnd, nBar, &si);
1056
1057 if (!g_pImage)
1058 return;
1059
1060 if (bVertical)
1061 {
1063 return;
1064 }
1065 else
1066 {
1068 return;
1069 }
1070
1071 switch (LOWORD(wParam))
1072 {
1073 case SB_THUMBTRACK:
1074 case SB_THUMBPOSITION:
1075 si.nPos = (SHORT)HIWORD(wParam);
1076 break;
1077 case SB_LINELEFT:
1078 si.nPos -= 48;
1079 break;
1080 case SB_LINERIGHT:
1081 si.nPos += 48;
1082 break;
1083 case SB_PAGELEFT:
1084 si.nPos -= si.nPage;
1085 break;
1086 case SB_PAGERIGHT:
1087 si.nPos += si.nPage;
1088 break;
1089 }
1090
1091 si.fMask = SIF_POS;
1092 SetScrollInfo(hwnd, nBar, &si, TRUE);
1093 GetScrollInfo(hwnd, nBar, &si);
1094
1095 GetClientRect(hwnd, &rcClient);
1096
1097 if (bVertical)
1098 {
1099 GdipGetImageHeight(g_pImage, &ImageHeight);
1100 ZoomedHeight = (ImageHeight * pData->m_nZoomPercents) / 100;
1101 pData->m_yScrollOffset = si.nPos - (ZoomedHeight - rcClient.bottom) / 2;
1102 }
1103 else
1104 {
1105 GdipGetImageWidth(g_pImage, &ImageWidth);
1106 ZoomedWidth = (ImageWidth * pData->m_nZoomPercents) / 100;
1107 pData->m_xScrollOffset = si.nPos - (ZoomedWidth - rcClient.right) / 2;
1108 }
1109
1111}
#define WS_VSCROLL
Definition: pedump.c:627
short SHORT
Definition: pedump.c:59
#define WS_HSCROLL
Definition: pedump.c:628
#define HIWORD(l)
Definition: typedefs.h:247
#define SB_THUMBTRACK
Definition: winuser.h:573
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SB_VERT
Definition: winuser.h:553
#define SB_LINERIGHT
Definition: winuser.h:567
#define SB_LINELEFT
Definition: winuser.h:566
#define SIF_ALL
Definition: winuser.h:1232
#define SIF_POS
Definition: winuser.h:1234
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define GWL_STYLE
Definition: winuser.h:852
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SB_HORZ
Definition: winuser.h:552
#define SB_PAGELEFT
Definition: winuser.h:570
#define SB_THUMBPOSITION
Definition: winuser.h:572

Referenced by ZoomWndProc().

◆ ZoomWnd_OnMouseMove()

static VOID ZoomWnd_OnMouseMove ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1013 of file shimgvw.c.

1014{
1017
1018 if (pData->m_nMouseDownMsg == WM_MBUTTONDOWN)
1019 {
1020 INT x = GetScrollPos(hwnd, SB_HORZ) - (pt.x - pData->m_ptOrigin.x);
1021 INT y = GetScrollPos(hwnd, SB_VERT) - (pt.y - pData->m_ptOrigin.y);
1024 pData->m_ptOrigin = pt;
1025 }
1026}
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define WM_HSCROLL
Definition: winuser.h:1743
#define WM_VSCROLL
Definition: winuser.h:1744
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
#define WM_MBUTTONDOWN
Definition: winuser.h:1782

Referenced by ZoomWndProc().

◆ ZoomWnd_OnMouseWheel()

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

Definition at line 1114 of file shimgvw.c.

1115{
1117 if (zDelta == 0)
1118 return;
1119
1120 if (GetKeyState(VK_CONTROL) < 0)
1121 {
1122 Preview_ZoomInOrOut(pData, zDelta > 0);
1123 }
1124 else if (GetKeyState(VK_SHIFT) < 0)
1125 {
1126 if (zDelta > 0)
1128 else
1130 }
1131 else
1132 {
1133 if (zDelta > 0)
1135 else
1137 }
1138}
#define SB_LINEUP
Definition: winuser.h:564
#define VK_CONTROL
Definition: winuser.h:2203
#define SB_LINEDOWN
Definition: winuser.h:565
#define VK_SHIFT
Definition: winuser.h:2202
SHORT WINAPI GetKeyState(_In_ int)

Referenced by ZoomWndProc().

◆ ZoomWnd_OnPaint()

static VOID ZoomWnd_OnPaint ( PPREVIEW_DATA  pData,
HWND  hwnd 
)
static

Definition at line 883 of file shimgvw.c.

884{
885 PAINTSTRUCT ps;
886 HDC hDC;
887 RECT rcClient;
888
889 hDC = BeginPaint(hwnd, &ps);
890 if (hDC)
891 {
892 GetClientRect(hwnd, &rcClient);
893 ZoomWnd_OnDraw(pData, hDC, &ps.rcPaint, &rcClient);
894 EndPaint(hwnd, &ps);
895 }
896}
static HDC hDC
Definition: 3dtext.c:33
static VOID ZoomWnd_OnDraw(PPREVIEW_DATA pData, HDC hdc, LPRECT prcPaint, LPRECT prcClient)
Definition: shimgvw.c:751
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by ZoomWndProc().

◆ ZoomWnd_OnSetCursor()

static BOOL ZoomWnd_OnSetCursor ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1029 of file shimgvw.c.

1030{
1032 if (pData->m_nMouseDownMsg == WM_MBUTTONDOWN)
1033 {
1035 return TRUE;
1036 }
1037 return FALSE;
1038}

Referenced by ZoomWndProc().

◆ ZoomWnd_UpdateScroll()

static VOID ZoomWnd_UpdateScroll ( PPREVIEW_DATA  pData,
HWND  hwnd,
BOOL  bResetPos 
)
static

Definition at line 140 of file shimgvw.c.

141{
142 RECT rcClient;
143 UINT ImageWidth, ImageHeight, ZoomedWidth, ZoomedHeight;
144 SCROLLINFO si;
145 BOOL bShowHorz, bShowVert;
146
147 if (bResetPos)
148 pData->m_xScrollOffset = pData->m_yScrollOffset = 0;
149
150 if (!g_pImage)
151 {
154 return;
155 }
156
157 GdipGetImageWidth(g_pImage, &ImageWidth);
158 GdipGetImageHeight(g_pImage, &ImageHeight);
159
160 ZoomedWidth = (ImageWidth * pData->m_nZoomPercents) / 100;
161 ZoomedHeight = (ImageHeight * pData->m_nZoomPercents) / 100;
162
163 GetClientRect(hwnd, &rcClient);
164
165 bShowHorz = (rcClient.right < ZoomedWidth);
166 bShowVert = (rcClient.bottom < ZoomedHeight);
167 ShowScrollBar(hwnd, SB_HORZ, bShowHorz);
168 ShowScrollBar(hwnd, SB_VERT, bShowVert);
169
170 GetClientRect(hwnd, &rcClient);
171
172 ZeroMemory(&si, sizeof(si));
173 si.cbSize = sizeof(si);
174 si.fMask = SIF_ALL;
175
176 if (bShowHorz)
177 {
179 si.nPage = rcClient.right;
180 si.nMin = 0;
181 si.nMax = ZoomedWidth;
182 si.nPos = (ZoomedWidth - rcClient.right) / 2 + pData->m_xScrollOffset;
183 si.nPos = max(min(si.nPos, si.nMax - (INT)si.nPage), si.nMin);
185 pData->m_xScrollOffset = si.nPos - (ZoomedWidth - rcClient.right) / 2;
186 }
187 else
188 {
189 pData->m_xScrollOffset = 0;
190 }
191
192 if (bShowVert)
193 {
195 si.nPage = rcClient.bottom;
196 si.nMin = 0;
197 si.nMax = ZoomedHeight;
198 si.nPos = (ZoomedHeight - rcClient.bottom) / 2 + pData->m_yScrollOffset;
199 si.nPos = max(min(si.nPos, si.nMax - (INT)si.nPage), si.nMin);
201 pData->m_yScrollOffset = si.nPos - (ZoomedHeight - rcClient.bottom) / 2;
202 }
203 else
204 {
205 pData->m_yScrollOffset = 0;
206 }
207
209}
#define min(a, b)
Definition: monoChain.cc:55
#define max(a, b)
Definition: svc.c:63
#define SB_BOTH
Definition: winuser.h:555
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)

Referenced by Preview_UpdateImage(), and Preview_UpdateZoom().

◆ ZoomWndProc()

LRESULT CALLBACK ZoomWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1141 of file shimgvw.c.

1142{
1144 switch (uMsg)
1145 {
1146 case WM_LBUTTONDOWN:
1147 case WM_MBUTTONDOWN:
1148 case WM_RBUTTONDOWN:
1149 {
1151 break;
1152 }
1153 case WM_MOUSEMOVE:
1154 {
1156 break;
1157 }
1158 case WM_SETCURSOR:
1159 {
1160 if (!ZoomWnd_OnSetCursor(hwnd, uMsg, wParam, lParam))
1161 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
1162 }
1163 case WM_LBUTTONUP:
1164 case WM_MBUTTONUP:
1165 case WM_RBUTTONUP:
1166 {
1168 break;
1169 }
1170 case WM_PAINT:
1171 {
1173 break;
1174 }
1175 case WM_MOUSEWHEEL:
1176 {
1179 break;
1180 }
1181 case WM_HSCROLL:
1182 case WM_VSCROLL:
1184 break;
1185 case WM_TIMER:
1186 {
1187 if (Anime_OnTimer(&pData->m_Anime, wParam))
1189 break;
1190 }
1191 default:
1192 {
1193 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
1194 }
1195 }
1196 return 0;
1197}
BOOL Anime_OnTimer(PANIME pAnime, WPARAM wParam)
Definition: anime.c:76
static VOID ZoomWnd_OnMouseWheel(HWND hwnd, INT x, INT y, INT zDelta, UINT fwKeys)
Definition: shimgvw.c:1114
static BOOL ZoomWnd_OnSetCursor(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:1029
static VOID ZoomWnd_OnMouseMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:1013
static VOID ZoomWnd_OnHVScroll(PPREVIEW_DATA pData, HWND hwnd, WPARAM wParam, BOOL bVertical)
Definition: shimgvw.c:1049
static VOID ZoomWnd_OnPaint(PPREVIEW_DATA pData, HWND hwnd)
Definition: shimgvw.c:883
static VOID ZoomWnd_OnButtonUp(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:1041
static VOID ZoomWnd_OnButtonDown(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shimgvw.c:994
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define WM_PAINT
Definition: winuser.h:1620
#define WM_RBUTTONUP
Definition: winuser.h:1780
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define WM_SETCURSOR
Definition: winuser.h:1636
#define WM_MBUTTONUP
Definition: winuser.h:1783

Referenced by ImageView_Main().

Variable Documentation

◆ g_hInstance

◆ g_hMainWnd

HWND g_hMainWnd = NULL

◆ g_hwndFullscreen

HWND g_hwndFullscreen = NULL

Definition at line 26 of file shimgvw.c.

Referenced by ImageView_Main(), Preview_OnCreate(), and Preview_ToggleSlideShow().

◆ g_pCurrentFile

◆ g_pImage

◆ g_Settings

◆ s_ButtonConfig

const TB_BUTTON_CONFIG s_ButtonConfig[]
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_BTN_CONFIG(ROT_CWSAVE),
DEFINE_BTN_CONFIG(ROT_CCWSAVE),
DEFINE_BTN_CONFIG(HELP_TOC),
}
#define SLIDE_SHOW
#define MODIFY(p, i, v)
Definition: check.c:44
#define DELETE
Definition: nt_native.h:57
#define DEFINE_BTN_CONFIG(_name)
Definition: shimgvw.c:80

Definition at line 82 of file shimgvw.c.

Referenced by Preview_CreateToolBar(), and Preview_OnNotify().

◆ s_Buttons

const TBBUTTON s_Buttons[]
static
Initial value:

Definition at line 47 of file shimgvw.c.

Referenced by Preview_CreateToolBar().

◆ s_ZoomSteps

const UINT s_ZoomSteps[]
static
Initial value:
=
{
5, 10, 25, 50, 100, 200, 300, 500, 1000, 2000, 4000
}

Definition at line 31 of file shimgvw.c.

Referenced by Preview_ZoomInOrOut().