#include <windows.h>#include <windowsx.h>#include "launcherconfig.h"#include "persistent.h"#include "clipboard.h"#include "resource.h"#include "utils.h"Go to the source code of this file.
Defines | |
| #define | strict |
Functions | |
| void | OnCopyToClipboard (HWND hListbox) |
| void | OnPasteFromClipboard (HWND hListBox) |
| void | OnDuplicateLaunchConfiguration (HWND hListBox) |
|
|
Definition at line 11 of file clipboard.c. |
|
|
Definition at line 22 of file clipboard.c. References copyLauncherConfigToMemoryBlock(), getCurrentSelection(), and getLauncherConfig().
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 // Empty the Clipboard. This also has the effect
00042 // of allowing Windows to free the memory associated
00043 // with any data that is in the Clipboard
00044 EmptyClipboard();
00045
00046 // Here I'm simply using the GlobalAlloc function to
00047 // allocate a block of data equal to the size of the
00048 // CCustomer object.
00049 hClipboardData = GlobalAlloc(GMEM_DDESHARE, sizeof(LCONFIG));
00050
00051 // Calling GlobalLock returns to me a pointer to the
00052 // data associated with the handle returned from GlobalAlloc
00053 clipboardData = (LPLAUNCHERCONFIG)GlobalLock(hClipboardData);
00054
00055 copyLauncherConfigToMemoryBlock(clipboardData, launcherConfig);
00056
00057 // Once done, I unlock the memory - remember you don't call
00058 // GlobalFree because Windows will free the memory
00059 // automatically when EmptyClipboard is next called.
00060 GlobalUnlock(hClipboardData);
00061
00062 // Now, set the Clipboard data by specifying that
00063 // ANSI text is being used and passing the handle to
00064 // the global memory. Notice that the value returned
00065 // from the RegisterClipboardData is used.
00066 SetClipboardData(uiCustomerDataFormat, hClipboardData);
00067
00068 // Finally, when finished I simply close the Clipboard
00069 // which has the effect of unlocking it so that other
00070 // applications can examine or modify its contents.
00071 CloseClipboard();
00072 }
00073 }
00074 }
|
|
|
Definition at line 123 of file clipboard.c. References addLauchnerConfigToList(), createLauncherConfigCopy(), getCurrentSelection(), getLauncherConfig(), getName(), LocString(), saveConfiguration(), and setName(). Referenced by OnCommandHelper().
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 }
|
|
|
Definition at line 76 of file clipboard.c. References addLauchnerConfigToList(), createLauncherConfigCopy(), and saveConfiguration().
00077 {
00078 UINT uiCustomerDataFormat = RegisterClipboardFormat("LAUNCHERCONFIG");
00079 LPLAUNCHERCONFIG launcherConfig = NULL;
00080
00081 // Test to see if we can open the clipboard first.
00082 if (OpenClipboard(NULL))
00083 {
00084 // Determine if the data on the Clipboard is in the
00085 // format of the Customer custom data.
00086 if (IsClipboardFormatAvailable(uiCustomerDataFormat))
00087 {
00088 TCHAR buffer[MAX_STRING_LENGTH] = {0};
00089
00090 // Retrieve a handle to the customer data from the Clipbaord.
00091 HANDLE hData = GetClipboardData(uiCustomerDataFormat);
00092
00093 // Call GlobalLock so that to retrieve a pointer
00094 // to the data associated with the handle returned
00095 // from GetClipboardData and cast that pointer to
00096 // a CCustomer pointer.
00097 LPLAUNCHERCONFIG launcherConfigCopy = (LPLAUNCHERCONFIG)GlobalLock(hData);
00098
00099 // Instantiate a local copy of the CCustomer object
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 // Unlock the global memory.
00109 GlobalUnlock( hData );
00110
00111 // Finally, when finished I simply close the Clipboard
00112 // which has the effect of unlocking it so that other
00113 // applications can examine or modify its contents.
00114 CloseClipboard();
00115 }
00116 }
00117 }
|
1.2.17