Author: hbelusca
Date: Sat Nov 14 16:45:41 2015
New Revision: 69890
URL:
http://svn.reactos.org/svn/reactos?rev=69890&view=rev
Log:
[CLIPBRD]
- Change SetDIBitsToDeviceFromClipboard to correctly use the requested format instead of
always using CF_DIBV5
- Enable/Disable the menu point "Save as..." dynamically
- Remove unneeded import libraries
- Add WS_EX_ACCEPTFILES window style and handle WM_DROPFILES
- Add some defines and structures for handling clipboard files (work in progress)
- Add Open and Save dialogs
Patch by Ricardo Hanke. CORE-10520
Added:
trunk/reactos/base/applications/clipbrd/fileutils.c (with props)
trunk/reactos/base/applications/clipbrd/fileutils.h (with props)
Modified:
trunk/reactos/base/applications/clipbrd/CMakeLists.txt
trunk/reactos/base/applications/clipbrd/clipbrd.c
trunk/reactos/base/applications/clipbrd/lang/de-DE.rc
trunk/reactos/base/applications/clipbrd/lang/en-US.rc
trunk/reactos/base/applications/clipbrd/lang/fr-FR.rc
trunk/reactos/base/applications/clipbrd/precomp.h
trunk/reactos/base/applications/clipbrd/resources.h
trunk/reactos/base/applications/clipbrd/winutils.c
Modified: trunk/reactos/base/applications/clipbrd/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/CMakeLists.txt [iso-8859-1] Sat Nov 14
16:45:41 2015
@@ -3,10 +3,11 @@
clipbrd.c
cliputils.c
winutils.c
+ fileutils.c
precomp.h)
add_executable(clipbrd ${SOURCE} clipbrd.rc)
add_pch(clipbrd precomp.h SOURCE)
set_module_type(clipbrd win32gui UNICODE)
-add_importlibs(clipbrd hhctrl user32 gdi32 comctl32 comdlg32 advapi32 shell32 msvcrt
kernel32)
+add_importlibs(clipbrd hhctrl user32 gdi32 comdlg32 shell32 msvcrt kernel32)
add_cd_file(TARGET clipbrd DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/base/applications/clipbrd/clipbrd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -12,6 +12,103 @@
CLIPBOARD_GLOBALS Globals;
+static void SaveClipboardToFile(void)
+{
+ OPENFILENAMEW sfn;
+ WCHAR szFileName[MAX_PATH];
+ WCHAR szFilterMask[MAX_STRING_LEN + 10];
+ LPWSTR c;
+
+ ZeroMemory(&szFilterMask, sizeof(szFilterMask));
+ c = szFilterMask + LoadStringW(Globals.hInstance, STRING_FORMAT_NT, szFilterMask,
MAX_STRING_LEN) + 1;
+ wcscpy(c, L"*.clp");
+
+ ZeroMemory(&szFileName, sizeof(szFileName));
+ ZeroMemory(&sfn, sizeof(sfn));
+ sfn.lStructSize = sizeof(sfn);
+ sfn.hwndOwner = Globals.hMainWnd;
+ sfn.hInstance = Globals.hInstance;
+ sfn.lpstrFilter = szFilterMask;
+ sfn.lpstrFile = szFileName;
+ sfn.nMaxFile = ARRAYSIZE(szFileName);
+ sfn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+ sfn.lpstrDefExt = L"clp";
+
+ if (!GetSaveFileNameW(&sfn))
+ return;
+
+ if (!OpenClipboard(NULL))
+ {
+ ShowLastWin32Error(Globals.hMainWnd);
+ return;
+ }
+
+ WriteClipboardFile(szFileName);
+
+ CloseClipboard();
+}
+
+static void LoadClipboardFromFile(void)
+{
+ OPENFILENAMEW ofn;
+ WCHAR szFileName[MAX_PATH];
+ WCHAR szFilterMask[MAX_STRING_LEN + 10];
+ LPWSTR c;
+
+ ZeroMemory(&szFilterMask, sizeof(szFilterMask));
+ c = szFilterMask + LoadStringW(Globals.hInstance, STRING_FORMAT_GEN, szFilterMask,
MAX_STRING_LEN) + 1;
+ wcscpy(c, L"*.clp");
+
+ ZeroMemory(&szFileName, sizeof(szFileName));
+ ZeroMemory(&ofn, sizeof(ofn));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = Globals.hMainWnd;
+ ofn.hInstance = Globals.hInstance;
+ ofn.lpstrFilter = szFilterMask;
+ ofn.lpstrFile = szFileName;
+ ofn.nMaxFile = ARRAYSIZE(szFileName);
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
+
+ if (!GetOpenFileNameW(&ofn))
+ return;
+
+ if (!OpenClipboard(NULL))
+ {
+ ShowLastWin32Error(Globals.hMainWnd);
+ return;
+ }
+
+ if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance, STRING_DELETE_MSG,
STRING_DELETE_TITLE, MB_ICONWARNING | MB_YESNO) == IDYES)
+ {
+ EmptyClipboard();
+ ReadClipboardFile(szFileName);
+ }
+
+ CloseClipboard();
+}
+
+static void LoadClipboardFromDrop(HDROP hDrop)
+{
+ WCHAR szFileName[MAX_PATH];
+
+ DragQueryFileW(hDrop, 0, szFileName, ARRAYSIZE(szFileName));
+ DragFinish(hDrop);
+
+ if (!OpenClipboard(NULL))
+ {
+ ShowLastWin32Error(Globals.hMainWnd);
+ return;
+ }
+
+ if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance, STRING_DELETE_MSG,
STRING_DELETE_TITLE, MB_ICONWARNING | MB_YESNO) == IDYES)
+ {
+ EmptyClipboard();
+ ReadClipboardFile(szFileName);
+ }
+
+ CloseClipboard();
+}
+
static void SetDisplayFormat(UINT uFormat)
{
CheckMenuItem(Globals.hMenu, Globals.uCheckedItem, MF_BYCOMMAND | MF_UNCHECKED);
@@ -33,15 +130,17 @@
static void InitMenuPopup(HMENU hMenu, LPARAM index)
{
- if (GetMenuItemID(hMenu, 0) == CMD_DELETE)
+ if ((GetMenuItemID(hMenu, 0) == CMD_DELETE) || (GetMenuItemID(hMenu, 1) ==
CMD_SAVE_AS))
{
if (CountClipboardFormats() == 0)
{
EnableMenuItem(hMenu, CMD_DELETE, MF_GRAYED);
+ EnableMenuItem(hMenu, CMD_SAVE_AS, MF_GRAYED);
}
else
{
EnableMenuItem(hMenu, CMD_DELETE, MF_ENABLED);
+ EnableMenuItem(hMenu, CMD_SAVE_AS, MF_ENABLED);
}
}
@@ -51,7 +150,7 @@
void UpdateDisplayMenu(void)
{
UINT uFormat;
- WCHAR szFormatName[MAX_STRING_LEN];
+ WCHAR szFormatName[MAX_FMT_NAME_LEN + 1];
HMENU hMenu;
hMenu = GetSubMenu(Globals.hMenu, DISPLAY_MENU_POS);
@@ -93,6 +192,18 @@
{
switch (LOWORD(wParam))
{
+ case CMD_OPEN:
+ {
+ LoadClipboardFromFile();
+ break;
+ }
+
+ case CMD_SAVE_AS:
+ {
+ SaveClipboardToFile();
+ break;
+ }
+
case CMD_EXIT:
{
PostMessageW(Globals.hMainWnd, WM_CLOSE, 0, 0);
@@ -277,6 +388,12 @@
case WM_INITMENUPOPUP:
{
InitMenuPopup((HMENU)wParam, lParam);
+ break;
+ }
+
+ case WM_DROPFILES:
+ {
+ LoadClipboardFromDrop((HDROP)wParam);
break;
}
@@ -323,7 +440,7 @@
}
LoadStringW(hInstance, STRING_CLIPBOARD, szBuffer, ARRAYSIZE(szBuffer));
- Globals.hMainWnd = CreateWindowExW(WS_EX_CLIENTEDGE,
+ Globals.hMainWnd = CreateWindowExW(WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES,
szClassName,
szBuffer,
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
Added: trunk/reactos/base/applications/clipbrd/fileutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/fileutils.c (added)
+++ trunk/reactos/base/applications/clipbrd/fileutils.c [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -0,0 +1,21 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Clipboard Viewer
+ * FILE: base/applications/clipbrd/fileutils.c
+ * PURPOSE: Clipboard file format helper functions.
+ * PROGRAMMERS: Ricardo Hanke
+ */
+
+#include "precomp.h"
+
+void ReadClipboardFile(LPCWSTR lpFileName)
+{
+ MessageBoxW(Globals.hMainWnd, L"This function is currently not
implemented.", L"Clipboard", MB_OK | MB_ICONINFORMATION);
+ return;
+}
+
+void WriteClipboardFile(LPCWSTR lpFileName)
+{
+ MessageBoxW(Globals.hMainWnd, L"This function is currently not
implemented.", L"Clipboard", MB_OK | MB_ICONINFORMATION);
+ return;
+}
Propchange: trunk/reactos/base/applications/clipbrd/fileutils.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/applications/clipbrd/fileutils.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/fileutils.h (added)
+++ trunk/reactos/base/applications/clipbrd/fileutils.h [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -0,0 +1,29 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Clipboard Viewer
+ * FILE: base/applications/clipbrd/fileutils.c
+ * PURPOSE: Clipboard file format helper functions.
+ * PROGRAMMERS: Ricardo Hanke
+ */
+
+#define CLIPBOARD_FORMAT_31 0xC350
+#define CLIPBOARD_FORMAT_NT 0xC351
+#define CLIPBOARD_FORMAT_BK 0xC352
+#define MAX_FMT_NAME_LEN 79
+
+typedef struct _CLIPBOARDFILEHEADER
+{
+ WORD wFileIdentifier;
+ WORD wFormatCount;
+} CLIPBOARDFILEHEADER;
+
+typedef struct _CLIPBOARDFORMATHEADER
+{
+ DWORD dwFormatID;
+ DWORD dwLenData;
+ DWORD dwOffData;
+ WCHAR szName[MAX_FMT_NAME_LEN];
+} CLIPBOARDFORMATHEADER;
+
+void ReadClipboardFile(LPCWSTR lpFileName);
+void WriteClipboardFile(LPCWSTR lpFileName);
Propchange: trunk/reactos/base/applications/clipbrd/fileutils.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/applications/clipbrd/lang/de-DE.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/lang/de-DE.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/lang/de-DE.rc [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -9,8 +9,8 @@
BEGIN
POPUP "&Datei"
BEGIN
- MENUITEM "Ã&ffnen...", CMD_OPEN, GRAYED
- MENUITEM "Speichern &unter...", CMD_SAVE_AS, GRAYED
+ MENUITEM "Ã&ffnen...", CMD_OPEN
+ MENUITEM "Speichern &unter...", CMD_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Beenden", CMD_EXIT
END
@@ -35,6 +35,8 @@
STRING_CLIPBOARD "Zwischenablage"
STRING_DELETE_MSG "Soll der Inhalt der Zwischenablage gelöscht werden?"
STRING_DELETE_TITLE "Zwischenablage löschen"
+ STRING_FORMAT_NT "Zwischenablagedateien für ReactOS (*.clp)"
+ STRING_FORMAT_GEN "Zwischenablagedateien (*.clp)"
END
STRINGTABLE
Modified: trunk/reactos/base/applications/clipbrd/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/lang/en-US.rc [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -9,8 +9,8 @@
BEGIN
POPUP "&File"
BEGIN
- MENUITEM "&Open...", CMD_OPEN, GRAYED
- MENUITEM "Save &as...", CMD_SAVE_AS, GRAYED
+ MENUITEM "&Open...", CMD_OPEN
+ MENUITEM "Save &as...", CMD_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "E&xit", CMD_EXIT
END
@@ -35,6 +35,8 @@
STRING_CLIPBOARD "Clipboard"
STRING_DELETE_MSG "Clear contents of the Clipboard?"
STRING_DELETE_TITLE "Clear Clipboard"
+ STRING_FORMAT_NT "Clipboard files for ReactOS (*.clp)"
+ STRING_FORMAT_GEN "Clipboard files (*.clp)"
END
STRINGTABLE
@@ -57,5 +59,5 @@
STRINGTABLE
BEGIN
- ERROR_UNSUPPORTED_FORMAT "The clipboard contains data in a format, that cannot
be displayed."
+ ERROR_UNSUPPORTED_FORMAT "The Clipboard contains data in a format, that cannot
be displayed."
END
Modified: trunk/reactos/base/applications/clipbrd/lang/fr-FR.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/lang/fr-FR.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/lang/fr-FR.rc [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -9,8 +9,8 @@
BEGIN
POPUP "&Fichier"
BEGIN
- MENUITEM "&Ouvrir...", CMD_OPEN, GRAYED
- MENUITEM "&Enregistrer sous...", CMD_SAVE_AS, GRAYED
+ MENUITEM "&Ouvrir...", CMD_OPEN
+ MENUITEM "&Enregistrer sous...", CMD_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Quitter", CMD_EXIT
END
@@ -35,6 +35,8 @@
STRING_CLIPBOARD "Presse-papiers"
STRING_DELETE_MSG "Voulez-vous effacer le contenu du Presse-papiers ?"
STRING_DELETE_TITLE "Effacer le Presse-papiers"
+ STRING_FORMAT_NT "Fichiers du Presse-papiers ReactOS (*.clp)"
+ STRING_FORMAT_GEN "Fichiers du Presse-papiers (*.clp)"
END
STRINGTABLE
@@ -57,5 +59,5 @@
STRINGTABLE
BEGIN
- ERROR_UNSUPPORTED_FORMAT "Le Presse-Papiers contient des données dans un format
qui ne peut être affiché."
+ ERROR_UNSUPPORTED_FORMAT "Le Presse-papiers contient des données dans un format
qui ne peut être affiché."
END
Modified: trunk/reactos/base/applications/clipbrd/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/precomp.h [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -9,9 +9,11 @@
#include <wingdi.h>
#include <shellapi.h>
#include <htmlhelp.h>
+#include <commdlg.h>
#include "resources.h"
#include "cliputils.h"
+#include "fileutils.h"
#include "winutils.h"
#define MAX_STRING_LEN 255
Modified: trunk/reactos/base/applications/clipbrd/resources.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/resources.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/resources.h [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -16,6 +16,8 @@
#define STRING_CLIPBOARD 100
#define STRING_DELETE_MSG 101
#define STRING_DELETE_TITLE 102
+#define STRING_FORMAT_NT 103
+#define STRING_FORMAT_GEN 104
#define STRING_CF_UNKNOWN 200
#define STRING_CF_TEXT 201
Modified: trunk/reactos/base/applications/clipbrd/winutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/winutils.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/winutils.c [iso-8859-1] Sat Nov 14 16:45:41
2015
@@ -118,7 +118,7 @@
if (!OpenClipboard(NULL))
return;
- hGlobal = GetClipboardData(CF_DIBV5);
+ hGlobal = GetClipboardData(uFormat);
if (!hGlobal)
return;