00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #define strict
00012
00013 #include <windows.h>
00014 #include <windowsx.h>
00015
00016 #include "launcherconfig.h"
00017 #include "persistent.h"
00018 #include "clipboard.h"
00019 #include "resource.h"
00020 #include "utils.h"
00021
00022 void OnCopyToClipboard(HWND hListbox)
00023 {
00024 UINT uiCustomerDataFormat = RegisterClipboardFormat("LAUNCHERCONFIG");
00025
00026 if(OpenClipboard(NULL))
00027 {
00028 LPLAUNCHERCONFIG launcherConfig = NULL;
00029 LPLAUNCHERCONFIG launcherConfigCopy = NULL;
00030 GLOBALHANDLE hClipboardData = NULL;
00031 LPLAUNCHERCONFIG clipboardData = NULL;
00032
00033 int currentSelection = getCurrentSelection(hListbox);
00034 if(currentSelection != LB_ERR)
00035 {
00036 launcherConfig = getLauncherConfig(hListbox, currentSelection);
00037 }
00038
00039 if(launcherConfig != NULL)
00040 {
00041
00042
00043
00044 EmptyClipboard();
00045
00046
00047
00048
00049 hClipboardData = GlobalAlloc(GMEM_DDESHARE, sizeof(LCONFIG));
00050
00051
00052
00053 clipboardData = (LPLAUNCHERCONFIG)GlobalLock(hClipboardData);
00054
00055 copyLauncherConfigToMemoryBlock(clipboardData, launcherConfig);
00056
00057
00058
00059
00060 GlobalUnlock(hClipboardData);
00061
00062
00063
00064
00065
00066 SetClipboardData(uiCustomerDataFormat, hClipboardData);
00067
00068
00069
00070
00071 CloseClipboard();
00072 }
00073 }
00074 }
00075
00076 void OnPasteFromClipboard(HWND hListBox)
00077 {
00078 UINT uiCustomerDataFormat = RegisterClipboardFormat("LAUNCHERCONFIG");
00079 LPLAUNCHERCONFIG launcherConfig = NULL;
00080
00081
00082 if (OpenClipboard(NULL))
00083 {
00084
00085
00086 if (IsClipboardFormatAvailable(uiCustomerDataFormat))
00087 {
00088 TCHAR buffer[MAX_STRING_LENGTH] = {0};
00089
00090
00091 HANDLE hData = GetClipboardData(uiCustomerDataFormat);
00092
00093
00094
00095
00096
00097 LPLAUNCHERCONFIG launcherConfigCopy = (LPLAUNCHERCONFIG)GlobalLock(hData);
00098
00099
00100 launcherConfig = createLauncherConfigCopy(launcherConfigCopy);
00101
00102 wsprintf(buffer, "Copy of %s", launcherConfig->name);
00103 lstrcpyn(launcherConfig->name, buffer, MAX_STRING_LENGTH);
00104
00105 addLauchnerConfigToList(hListBox, launcherConfig, (-1));
00106 saveConfiguration(hListBox);
00107
00108
00109 GlobalUnlock( hData );
00110
00111
00112
00113
00114 CloseClipboard();
00115 }
00116 }
00117 }
00118
00123 void OnDuplicateLaunchConfiguration(HWND hListBox)
00124 {
00125 LPLAUNCHERCONFIG launcherConfig = NULL;
00126 LPLAUNCHERCONFIG launcherConfigCopy = NULL;
00127
00128 int currentSelection = getCurrentSelection(hListBox);
00129 if(currentSelection != LB_ERR)
00130 {
00131 launcherConfig = getLauncherConfig(hListBox, currentSelection);
00132 }
00133
00134 if(launcherConfig != NULL)
00135 {
00136 TCHAR buffer[MAX_STRING_LENGTH] = {0};
00137 TCHAR* locStringBuffer = (TCHAR*) malloc(128);
00138
00139 launcherConfigCopy = createLauncherConfigCopy(launcherConfig);
00140
00141 wsprintf(buffer, LocString(IDS_PREFIX_DUPLICATE_CONFIGURATION, locStringBuffer),
00142 getName(launcherConfig));
00143 setName(launcherConfigCopy, buffer, MAX_STRING_LENGTH);
00144
00145 addLauchnerConfigToList(hListBox, launcherConfigCopy, NEW_POSITION);
00146 saveConfiguration(hListBox);
00147
00148 free(locStringBuffer);
00149 }
00150 }