- Start implementing shimgvw.dll
authorDmitry Chapyshev <dmitry@reactos.org>
Wed, 28 May 2008 19:52:46 +0000 (19:52 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Wed, 28 May 2008 19:52:46 +0000 (19:52 +0000)
svn path=/trunk/; revision=33741

18 files changed:
reactos/dll/win32/shimgvw/lang/en-US.rc [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/main.ico [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/next.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/prev.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/print.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/rot1.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/rot2.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/save.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/zoomm.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/res/zoomp.bmp [new file with mode: 0644]
reactos/dll/win32/shimgvw/resource.h [new file with mode: 0644]
reactos/dll/win32/shimgvw/rsrc.rc [new file with mode: 0644]
reactos/dll/win32/shimgvw/shimgvw.c [new file with mode: 0644]
reactos/dll/win32/shimgvw/shimgvw.h [new file with mode: 0644]
reactos/dll/win32/shimgvw/shimgvw.rbuild [new file with mode: 0644]
reactos/dll/win32/shimgvw/shimgvw.rc [new file with mode: 0644]
reactos/dll/win32/shimgvw/shimgvw.spec [new file with mode: 0644]
reactos/dll/win32/win32.rbuild

diff --git a/reactos/dll/win32/shimgvw/lang/en-US.rc b/reactos/dll/win32/shimgvw/lang/en-US.rc
new file mode 100644 (file)
index 0000000..af6bde0
--- /dev/null
@@ -0,0 +1,17 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+STRINGTABLE
+BEGIN
+       IDS_APPTITLE    "ReactOS Picture and Fax Viewer"
+    IDS_SETASDESKBG "Set as Desktop Background"
+
+    /* Tooltips */
+    IDS_TOOLTIP_NEXT_PIC   "Next Picture"
+    IDS_TOOLTIP_PREV_PIC   "Previous Picture"
+    IDS_TOOLTIP_ZOOM_IN    "Zoom In (+)"
+    IDS_TOOLTIP_ZOOM_OUT   "Zoom Out (-)"
+    IDS_TOOLTIP_ROT_CLOCKW "Rotate Clockwise (Ctrl+K)"
+    IDS_TOOLTIP_ROT_COUNCW "Rotate Counterclockwise (Ctrl+L)"
+    IDS_TOOLTIP_PRINT      "Print (Ctrl+P)"
+    IDS_TOOLTIP_SAVEAS     "Save As... (Ctrl+S)"
+END
diff --git a/reactos/dll/win32/shimgvw/res/main.ico b/reactos/dll/win32/shimgvw/res/main.ico
new file mode 100644 (file)
index 0000000..4d0d75e
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/main.ico differ
diff --git a/reactos/dll/win32/shimgvw/res/next.bmp b/reactos/dll/win32/shimgvw/res/next.bmp
new file mode 100644 (file)
index 0000000..e31ccef
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/next.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/prev.bmp b/reactos/dll/win32/shimgvw/res/prev.bmp
new file mode 100644 (file)
index 0000000..66d1bbf
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/prev.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/print.bmp b/reactos/dll/win32/shimgvw/res/print.bmp
new file mode 100644 (file)
index 0000000..93d9408
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/print.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/rot1.bmp b/reactos/dll/win32/shimgvw/res/rot1.bmp
new file mode 100644 (file)
index 0000000..851d3c9
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/rot1.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/rot2.bmp b/reactos/dll/win32/shimgvw/res/rot2.bmp
new file mode 100644 (file)
index 0000000..59a67ce
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/rot2.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/save.bmp b/reactos/dll/win32/shimgvw/res/save.bmp
new file mode 100644 (file)
index 0000000..441e702
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/save.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/zoomm.bmp b/reactos/dll/win32/shimgvw/res/zoomm.bmp
new file mode 100644 (file)
index 0000000..7d795d4
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/zoomm.bmp differ
diff --git a/reactos/dll/win32/shimgvw/res/zoomp.bmp b/reactos/dll/win32/shimgvw/res/zoomp.bmp
new file mode 100644 (file)
index 0000000..8e2e8d8
Binary files /dev/null and b/reactos/dll/win32/shimgvw/res/zoomp.bmp differ
diff --git a/reactos/dll/win32/shimgvw/resource.h b/reactos/dll/win32/shimgvw/resource.h
new file mode 100644 (file)
index 0000000..9ef15ed
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __SHIMGVW_RESOURCE_H
+#define __SHIMGVW_RESOURCE_H
+
+/* Icons */
+#define IDI_APPICON      1
+#define IDI_BMP_ICON     2
+#define IDI_GIF_ICON     3
+#define IDI_JPG_ICON     4
+#define IDI_PNG_ICON     5
+
+#define IDB_PREVICON     50
+#define IDB_NEXTICON     51
+#define IDB_ZOOMPICON    52
+#define IDB_ZOOMMICON    53
+#define IDB_SAVEICON     54
+#define IDB_PRINTICON    55
+#define IDB_ROT1ICON     56
+#define IDB_ROT2ICON     57
+
+/* ToolBar buttons */
+#define IDC_PREV         500
+#define IDC_NEXT         501
+#define IDC_ZOOMP        502
+#define IDC_ZOOMM        503
+#define IDC_SAVE         504
+#define IDC_PRINT        505
+#define IDC_ROT1         506
+#define IDC_ROT2         507
+
+#define TBICON_PREV      0
+#define TBICON_NEXT      1
+#define TBICON_ZOOMP     2
+#define TBICON_ZOOMM     3
+#define TBICON_SAVE      4
+#define TBICON_PRINT     5
+#define TBICON_ROT1      6
+#define TBICON_ROT2      7
+
+/* Strings */
+#define IDS_APPTITLE     100
+#define IDS_SETASDESKBG  101
+
+/* Tooltips strings */
+#define IDS_TOOLTIP_NEXT_PIC     300
+#define IDS_TOOLTIP_PREV_PIC     301
+#define IDS_TOOLTIP_ZOOM_IN      302
+#define IDS_TOOLTIP_ZOOM_OUT     304
+#define IDS_TOOLTIP_ROT_CLOCKW   305
+#define IDS_TOOLTIP_ROT_COUNCW   306
+#define IDS_TOOLTIP_PRINT        307
+#define IDS_TOOLTIP_SAVEAS       308
+
+#endif /* __SHIMGVW_RESOURCE_H */
diff --git a/reactos/dll/win32/shimgvw/rsrc.rc b/reactos/dll/win32/shimgvw/rsrc.rc
new file mode 100644 (file)
index 0000000..2cc4165
--- /dev/null
@@ -0,0 +1,4 @@
+#include <windows.h>
+#include "resource.h"
+
+#include "lang/en-US.rc"
diff --git a/reactos/dll/win32/shimgvw/shimgvw.c b/reactos/dll/win32/shimgvw/shimgvw.c
new file mode 100644 (file)
index 0000000..bdf0367
--- /dev/null
@@ -0,0 +1,496 @@
+/*
+ *
+ * PROJECT:         ReactOS Picture and Fax Viewer
+ * FILE:            dll/win32/shimgvw/shimgvw.c
+ * PURPOSE:         shimgvw.dll
+ * PROGRAMMER:      Dmitry Chapyshev (dmitry@reactos.org)
+ *
+ * UPDATE HISTORY:
+ *      28/05/2008  Created
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <windows.h>
+#include <commctrl.h>
+#include <gdiplus.h>
+#include <tchar.h>
+
+#include "shimgvw.h"
+
+
+HINSTANCE hInstance;
+SHIMGVW_SETTINGS shiSettings;
+WCHAR szOpenFileName[MAX_PATH];
+
+HWND hDispWnd, hToolBar;
+
+/* ToolBar Buttons */
+static const TBBUTTON Buttons [] =
+{   /* iBitmap,     idCommand,   fsState,         fsStyle,     bReserved[2], dwData, iString */
+    {TBICON_PREV,   IDC_PREV,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {TBICON_NEXT,   IDC_NEXT,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {15,            0,           TBSTATE_ENABLED, BTNS_SEP,    {0}, 0, 0},
+    {TBICON_ZOOMP,  IDC_ZOOMP,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {TBICON_ZOOMM,  IDC_ZOOMM,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {15,            0,           TBSTATE_ENABLED, BTNS_SEP,    {0}, 0, 0},
+    {TBICON_ROT1,   IDC_ROT1,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {TBICON_ROT2,   IDC_ROT2,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {15,            0,           TBSTATE_ENABLED, BTNS_SEP,    {0}, 0, 0},
+    {TBICON_SAVE,   IDC_SAVE,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+    {TBICON_PRINT,  IDC_PRINT,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
+};
+
+static VOID
+ImageView_DrawImage(HWND hwnd)
+{
+    GpGraphics *graphics;
+    GpImage *image;
+    UINT uImgWidth, uImgHeight;
+    UINT height = 0, width = 0, x = 0, y = 0;
+    PAINTSTRUCT ps;
+    RECT rect;
+    HDC hdc;
+
+    if (GetFileAttributesW(szOpenFileName) == 0xFFFFFFFF)
+        return;
+
+    hdc = BeginPaint(hwnd, &ps);
+
+    GdipCreateFromHDC(hdc, &graphics);
+    GdipLoadImageFromFile(szOpenFileName, &image);
+    GdipGetImageWidth(image, &uImgWidth);
+    GdipGetImageHeight(image, &uImgHeight);
+
+    if (GetClientRect(hwnd, &rect))
+    {
+        FillRect(hdc, &rect, (HBRUSH)COLOR_WINDOW);
+
+        if ((rect.right == uImgWidth)&&(rect.bottom == uImgHeight))
+        {
+            x = 0, y = 0, width = rect.right, height = rect.bottom;
+        }
+        else if ((rect.right >= uImgWidth)&&(rect.bottom >= uImgHeight))
+        {
+            x = (rect.right/2)-(uImgWidth/2);
+            y = (rect.bottom/2)-(uImgHeight/2);
+            width = uImgWidth;
+            height = uImgHeight;
+        }
+        else if ((rect.right < uImgWidth)||(rect.bottom < uImgHeight))
+        {
+            if (rect.bottom < uImgHeight)
+            {
+                height = rect.bottom;
+                width = uImgWidth*(UINT)rect.bottom/uImgHeight;
+                x = (rect.right/2)-(width/2);
+                y = (rect.bottom/2)-(height/2);
+            }
+            if (rect.right < uImgWidth)
+            {
+                width = rect.right;
+                height = uImgHeight*(UINT)rect.right/uImgWidth;
+                x = (rect.right/2)-(width/2);
+                y = (rect.bottom/2)-(height/2);
+            }
+            if ((height > rect.bottom)||(width > rect.right))
+            {
+                for (;;)
+                {
+                    if (((int)width - 1 < 0)||((int)height - 1 < 0)) break;
+                    width -= 1;
+                    height -= 1;
+                    y = (rect.bottom/2)-(height/2);
+                    x = (rect.right/2)-(width/2);
+                    if ((height < rect.bottom)&&(width < rect.right)) break;
+                }
+            }
+        }
+        else if ((rect.right <= uImgWidth)&&(rect.bottom <= uImgHeight))
+        {
+            height = uImgHeight*(UINT)rect.right/uImgWidth;
+            y = (rect.bottom/2)-(height/2);
+            width = rect.right;
+
+            if ((height > rect.bottom)||(width > rect.right))
+            {
+                for (;;)
+                {
+                    if (((int)width - 1 < 0)||((int)height - 1 < 0)) break;
+                    width -= 1;
+                    height -= 1;
+                    y = (rect.bottom/2)-(height/2);
+                    x = (rect.right/2)-(width/2);
+                    if ((height < rect.bottom)&&(width < rect.right)) break;
+                }
+            }
+        }
+
+        //TCHAR szBuf[MAX_PATH];
+        //wsprintf(szBuf, _T("x = %d\ny = %d\nWidth = %d\nHeight = %d\n\nrect.right = %d\nrect.bottom = %d\n\nuImgWidth = %d\nuImgHeight = %d"), x, y, width, height, rect.right, rect.bottom, uImgWidth, uImgHeight);
+        //MessageBox(0, szBuf, NULL, MB_OK);
+        GdipDrawImageRect(graphics, image, x, y, width, height);
+    }
+
+    DeleteDC(hdc);
+    EndPaint(hwnd, &ps);
+}
+
+static BOOL
+ImageView_LoadSettings()
+{
+    HKEY hKey;
+    DWORD dwSize;
+
+    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+    {
+        dwSize = sizeof(SHIMGVW_SETTINGS);
+        if (RegQueryValueEx(hKey, _T("Settings"), NULL, NULL, (LPBYTE)&shiSettings, &dwSize) == ERROR_SUCCESS)
+        {
+            RegCloseKey(hKey);
+            return TRUE;
+        }
+
+        RegCloseKey(hKey);
+    }
+
+    return FALSE;
+}
+
+static VOID
+ImageView_SaveSettings(HWND hwnd)
+{
+    WINDOWPLACEMENT wp;
+    HKEY hKey;
+
+    ShowWindow(hwnd, SW_HIDE);
+    wp.length = sizeof(WINDOWPLACEMENT);
+    GetWindowPlacement(hwnd, &wp);
+
+    shiSettings.Left = wp.rcNormalPosition.left;
+    shiSettings.Top  = wp.rcNormalPosition.top;
+    shiSettings.Right  = wp.rcNormalPosition.right;
+    shiSettings.Bottom = wp.rcNormalPosition.bottom;
+    shiSettings.Maximized = (IsZoomed(hwnd) || (wp.flags & WPF_RESTORETOMAXIMIZED));
+
+    if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0, NULL,
+        REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
+    {
+        RegSetValueEx(hKey, _T("Settings"), 0, REG_BINARY, (LPBYTE)&shiSettings, sizeof(SHIMGVW_SETTINGS));
+        RegCloseKey(hKey);
+    }
+}
+
+static BOOL
+ImageView_CreateToolBar(HWND hwnd)
+{
+    INT numButtons = sizeof(Buttons) / sizeof(Buttons[0]);
+
+    hToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
+                              WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | CCS_BOTTOM | TBSTYLE_TOOLTIPS,
+                              0, 0, 0, 0, hwnd,
+                              0, hInstance, NULL);
+    if(hToolBar != NULL)
+    {
+        HIMAGELIST hImageList;
+
+        SendMessage(hToolBar, TB_SETEXTENDEDSTYLE,
+                    0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
+
+        SendMessage(hToolBar, TB_BUTTONSTRUCTSIZE,
+                    sizeof(Buttons[0]), 0);
+
+        hImageList = ImageList_Create(TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, ILC_MASK | ILC_COLOR24, 1, 1);
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_PREVICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_NEXTICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ZOOMPICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ZOOMMICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_SAVEICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_PRINTICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ROT1ICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        ImageList_AddMasked(hImageList, LoadImage(hInstance, MAKEINTRESOURCE(IDB_ROT2ICON), IMAGE_BITMAP,
+                      TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR), RGB(255, 255, 255));
+
+        if (hImageList == NULL) return FALSE;
+
+        ImageList_Destroy((HIMAGELIST)SendMessage(hToolBar, TB_SETIMAGELIST,
+                                                  0, (LPARAM)hImageList));
+
+        SendMessage(hToolBar, TB_ADDBUTTONS,
+                    numButtons, (LPARAM)Buttons);
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static VOID
+ImageView_InitControls(HWND hwnd)
+{
+    MoveWindow(hwnd, shiSettings.Left, shiSettings.Top,
+               shiSettings.Right - shiSettings.Left,
+               shiSettings.Bottom - shiSettings.Top, TRUE);
+
+    if (shiSettings.Maximized) ShowWindow(hwnd, SW_MAXIMIZE);
+
+    hDispWnd = CreateWindowEx(WS_EX_TRANSPARENT, _T("STATIC"), _T(""),
+                              WS_CHILD | WS_VISIBLE,
+                              0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
+
+    ImageView_CreateToolBar(hwnd);
+}
+
+LRESULT CALLBACK
+ImageView_WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+    switch (Message)
+    {
+        case WM_CREATE:
+        {
+            ImageView_InitControls(hwnd);
+        }
+        break;
+
+        case WM_COMMAND:
+        {
+            switch (wParam)
+            {
+                case IDC_PREV:
+
+                break;
+                case IDC_NEXT:
+
+                break;
+                case IDC_ZOOMP:
+
+                break;
+                case IDC_ZOOMM:
+
+                break;
+                case IDC_SAVE:
+
+                break;
+                case IDC_PRINT:
+
+                break;
+                case IDC_ROT1:
+
+                break;
+                case IDC_ROT2:
+
+                break;
+            }
+        }
+        break;
+
+        case WM_NOTIFY:
+        {
+            LPNMHDR pnmhdr = (LPNMHDR)lParam;
+
+            switch (pnmhdr->code)
+            {
+                case TTN_GETDISPINFO:
+                {
+                    LPTOOLTIPTEXT lpttt;
+                    UINT idButton;
+
+                    lpttt = (LPTOOLTIPTEXT)lParam;
+                    idButton = (UINT)lpttt->hdr.idFrom;
+
+                    switch (idButton)
+                    {
+                        case IDC_PREV:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PREV_PIC);
+                        break;
+                        case IDC_NEXT:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEXT_PIC);
+                        break;
+                        case IDC_ZOOMP:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ZOOM_IN);
+                        break;
+                        case IDC_ZOOMM:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ZOOM_OUT);
+                        break;
+                        case IDC_SAVE:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SAVEAS);
+                        break;
+                        case IDC_PRINT:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINT);
+                        break;
+                        case IDC_ROT1:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ROT_COUNCW);
+                        break;
+                        case IDC_ROT2:
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_ROT_CLOCKW);
+                        break;
+                    }
+                }
+            }
+        }
+        break;
+
+        case WM_PAINT:
+        {
+            ImageView_DrawImage(hDispWnd);
+        }
+        break;
+
+        case WM_SIZING:
+        {
+            LPRECT pRect = (LPRECT)lParam;
+            if (pRect->right-pRect->left < 350)
+                pRect->right = pRect->left + 350;
+
+            if (pRect->bottom-pRect->top < 290)
+                pRect->bottom = pRect->top + 290;
+        }
+        break;
+
+        case WM_SIZE:
+        {
+            MoveWindow(hDispWnd, 1, 1, LOWORD(lParam)-1, HIWORD(lParam)-35, TRUE);
+            SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
+        }
+        break;
+
+        case WM_DESTROY:
+        {
+            ImageView_SaveSettings(hwnd);
+            PostQuitMessage(0);
+        }
+        break;
+    }
+
+    return DefWindowProc(hwnd, Message, wParam, lParam);
+}
+
+LONG
+ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
+{
+    struct GdiplusStartupInput gdiplusStartupInput;
+    ULONG_PTR gdiplusToken;
+    WNDCLASS WndClass = {0};
+    TCHAR szBuf[512];
+    HWND hMainWnd;
+    MSG msg;
+
+    wcscpy(szOpenFileName, szFileName);
+
+    if (!ImageView_LoadSettings())
+    {
+        shiSettings.Maximized = FALSE;
+        shiSettings.Left      = 0;
+        shiSettings.Top       = 0;
+        shiSettings.Right     = 520;
+        shiSettings.Bottom    = 400;
+    }
+
+    // Initialize GDI+
+    gdiplusStartupInput.GdiplusVersion              = 1;
+    gdiplusStartupInput.DebugEventCallback          = NULL;
+    gdiplusStartupInput.SuppressBackgroundThread    = 0;
+    gdiplusStartupInput.SuppressExternalCodecs      = 0;
+
+    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+    // Create the window
+    WndClass.lpszClassName  = _T("shimgvw_window");
+    WndClass.lpfnWndProc    = (WNDPROC)ImageView_WndProc;
+    WndClass.hInstance      = hInstance;
+    WndClass.style          = CS_HREDRAW | CS_VREDRAW;
+    WndClass.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
+    WndClass.hCursor        = LoadCursor(hInstance, IDC_ARROW);
+    WndClass.hbrBackground  = (HBRUSH)COLOR_WINDOW;
+
+    if (!RegisterClass(&WndClass)) return -1;
+
+    LoadString(hInstance, IDS_APPTITLE, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+    hMainWnd = CreateWindow(_T("shimgvw_window"), szBuf,
+                            WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE | WS_CAPTION,
+                            CW_USEDEFAULT, CW_USEDEFAULT,
+                            0, 0, NULL, NULL, hInstance, NULL); 
+
+    // Show it
+    ShowWindow(hMainWnd, SW_SHOW);
+    UpdateWindow(hMainWnd);
+
+    // Message Loop
+    while(GetMessage(&msg,NULL,0,0))
+    {
+        TranslateMessage(&msg);
+        DispatchMessageW(&msg);
+    }
+
+    GdiplusShutdown(gdiplusToken);
+    return -1;
+}
+
+LONG
+CALLBACK
+ImageView_FullscreenW(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
+{
+    return ImageView_CreateWindow(hwnd, (LPWSTR)lParam1);
+}
+
+LONG
+CALLBACK
+ImageView_Fullscreen(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
+{
+    WCHAR szFile[MAX_PATH];
+
+    if (MultiByteToWideChar(CP_ACP, 0, (char*)lParam1, strlen((char*)lParam1)+1, szFile, MAX_PATH))
+    {
+        return ImageView_CreateWindow(hwnd, (LPWSTR)szFile);
+    }
+
+    return -1;
+}
+
+LONG
+CALLBACK
+ImageView_FullscreenA(HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
+{
+    WCHAR szFile[MAX_PATH];
+
+    if (MultiByteToWideChar(CP_ACP, 0, (char*)lParam1, strlen((char*)lParam1)+1, szFile, MAX_PATH))
+    {
+        return ImageView_CreateWindow(hwnd, (LPWSTR)szFile);
+    }
+
+    return -1;
+}
+
+BOOL WINAPI
+DllMain(IN HINSTANCE hinstDLL,
+        IN DWORD dwReason,
+        IN LPVOID lpvReserved)
+{
+    switch (dwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+        case DLL_THREAD_ATTACH:
+            hInstance = hinstDLL;
+            break;
+    }
+
+    return TRUE;
+}
+
diff --git a/reactos/dll/win32/shimgvw/shimgvw.h b/reactos/dll/win32/shimgvw/shimgvw.h
new file mode 100644 (file)
index 0000000..90cec15
--- /dev/null
@@ -0,0 +1,17 @@
+#include <windows.h>
+
+#include "resource.h"
+
+#define TB_IMAGE_WIDTH  16
+#define TB_IMAGE_HEIGHT 16
+
+extern HINSTANCE hInstance;
+
+typedef struct
+{
+    BOOL Maximized;
+    INT Left;
+    INT Top;
+    INT Right;
+    INT Bottom;
+} SHIMGVW_SETTINGS;
diff --git a/reactos/dll/win32/shimgvw/shimgvw.rbuild b/reactos/dll/win32/shimgvw/shimgvw.rbuild
new file mode 100644 (file)
index 0000000..99e1d13
--- /dev/null
@@ -0,0 +1,15 @@
+<module name="shimgvw" type="win32dll" baseaddress="${BASEADDRESS_SHIMGVW}" installbase="system32" installname="shimgvw.dll">
+       <importlibrary definition="shimgvw.spec.def" />
+       <include base="shimgvw">.</include>
+       <define name="_DISABLE_TIDENTS" />
+       <library>kernel32</library>
+       <library>advapi32</library>
+       <library>comctl32</library>
+       <library>ntdll</library>
+       <library>user32</library>
+       <library>gdi32</library>
+       <library>gdiplus</library>
+       <file>shimgvw.c</file>
+       <file>shimgvw.rc</file>
+       <file>shimgvw.spec</file>
+</module>
diff --git a/reactos/dll/win32/shimgvw/shimgvw.rc b/reactos/dll/win32/shimgvw/shimgvw.rc
new file mode 100644 (file)
index 0000000..5b54517
--- /dev/null
@@ -0,0 +1,21 @@
+#include <windows.h>
+#include "resource.h"
+
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "ReactOS Picture and Fax Viewer\0"
+#define REACTOS_STR_INTERNAL_NAME      "shimgvw\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "shimgvw.dll\0"
+#include <reactos/version.rc>
+
+IDI_APPICON     ICON "res/main.ico"
+
+IDB_PREVICON    BITMAP "res/prev.bmp"
+IDB_NEXTICON    BITMAP "res/next.bmp"
+IDB_ZOOMPICON   BITMAP "res/zoomp.bmp"
+IDB_ZOOMMICON   BITMAP "res/zoomm.bmp"
+IDB_SAVEICON    BITMAP "res/save.bmp"
+IDB_PRINTICON   BITMAP "res/print.bmp"
+IDB_ROT1ICON    BITMAP "res/rot1.bmp"
+IDB_ROT2ICON    BITMAP "res/rot2.bmp"
+
+#include "rsrc.rc"
diff --git a/reactos/dll/win32/shimgvw/shimgvw.spec b/reactos/dll/win32/shimgvw/shimgvw.spec
new file mode 100644 (file)
index 0000000..cf99f65
--- /dev/null
@@ -0,0 +1,14 @@
+@ stub ImageView_COMServer
+@ stdcall ImageView_Fullscreen(ptr long ptr ptr)
+@ stdcall ImageView_FullscreenA(ptr long ptr ptr)
+@ stdcall ImageView_FullscreenW(ptr long ptr ptr)
+@ stub ImageView_PrintTo
+@ stub ImageView_PrintToA
+@ stub ImageView_PrintToW
+@ stub imageview_fullscreenW
+@ stub ConvertDIBSECTIONToThumbnail
+@ stub DllCanUnloadNow
+@ stub DllGetClassObject
+@ stub DllInstall
+@ stub DllRegisterServer
+@ stub DllUnregisterServer
index 712b3c8..395de4d 100644 (file)
 <directory name="shfolder">
        <xi:include href="shfolder/shfolder.rbuild" />
 </directory>
+<directory name="shimgvw">
+       <xi:include href="shimgvw/shimgvw.rbuild" />
+</directory>
 <directory name="shlwapi">
        <xi:include href="shlwapi/shlwapi.rbuild" />
 </directory>