Skip to content

Commit d76f08e

Browse files
authored
Merge pull request #19 from Trapov/feature-20-clipboard-functions-added
Clipboard functions were added #15
2 parents f018a55 + 074941a commit d76f08e

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

WinApi/User32/Constants.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,5 +5230,28 @@ public enum WM
52305230
USER = 0x0400
52315231
}
52325232

5233+
public enum ClipboardFormat : uint
5234+
{
5235+
/// <summary>
5236+
/// A handle to a bitmap (HBITMAP)
5237+
/// </summary>
5238+
CF_BITMAP = 2u,
5239+
5240+
/// <summary>
5241+
/// Flag for text-format
5242+
/// </summary>
5243+
CF_TEXT = 1u,
5244+
5245+
/// <summary>
5246+
/// Flag for unicode-text-format
5247+
/// </summary>
5248+
CF_UNICODETEXT = 13u,
5249+
5250+
/// <summary>
5251+
/// no format
5252+
/// </summary>
5253+
CF_ZERO = 0u
5254+
}
5255+
52335256
#endregion
52345257
}

WinApi/User32/Methods.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,5 +820,61 @@ public static extern int GetMessage(out Message lpMsg, IntPtr hwnd, uint wMsgFil
820820
public static extern bool PostThreadMessage(uint threadId, uint msg, IntPtr wParam, IntPtr lParam);
821821

822822
#endregion
823+
824+
#region Clipboard Functions
825+
826+
/// <summary>
827+
/// Opens the clipboard for examination and prevents other applications from modifying the clipboard content.
828+
/// </summary>
829+
/// <param name="hWndNewOwner">A handle to the window to be associated with the open clipboard. If this parameter is NULL, the open clipboard is associated with the current task.</param>
830+
/// <returns>If the function succeeds, the return value is nonzero.</returns>
831+
[DllImport(LibraryName, ExactSpelling = true)]
832+
public static extern bool OpenClipboard(IntPtr hWndNewOwner);
833+
/// <summary>
834+
/// Closes the clipboard.
835+
/// </summary>
836+
/// <returns>If the function succeeds, the return value is nonzero.</returns>
837+
[DllImport(LibraryName, ExactSpelling = true)]
838+
public static extern bool CloseClipboard();
839+
/// <summary>
840+
/// Retrieves data from the clipboard in a specified format. The clipboard must have been opened previously.
841+
/// </summary>
842+
/// <param name="uFormat">A clipboard format.</param>
843+
/// <returns>If the function succeeds, the return value is the handle to a clipboard object in the specified format.</returns>
844+
[DllImport(LibraryName, ExactSpelling = true)]
845+
public static extern IntPtr GetClipboardData(uint uFormat);
846+
847+
/// <summary>
848+
/// Places data on the clipboard in a specified clipboard format. The window must be the current clipboard owner, and the application must have called the OpenClipboard function
849+
/// </summary>
850+
/// <param name="uFormat">The clipboard format</param>
851+
/// <param name="handle">A handle to the data in the specified format</param>
852+
/// <returns>If the function succeeds, the return value is the handle to the data.</returns>
853+
[DllImport(LibraryName, ExactSpelling = true)]
854+
public static extern IntPtr SetClipboardData(uint uFormat, IntPtr handle);
855+
856+
/// <summary>
857+
/// Empties the clipboard and frees handles to data in the clipboard. The function then assigns ownership of the clipboard to the window that currently has the clipboard open.
858+
/// </summary>
859+
/// <returns></returns>
860+
[DllImport(LibraryName, ExactSpelling = true)]
861+
public static extern bool EmptyClipboard();
862+
863+
[DllImport(LibraryName, ExactSpelling = true)]
864+
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
865+
866+
[DllImport(LibraryName, ExactSpelling = true)]
867+
public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
868+
869+
[DllImport(LibraryName, ExactSpelling = true)]
870+
public static extern bool AddClipboardFormatListener(IntPtr hwnd);
871+
872+
[DllImport(LibraryName, ExactSpelling = true)]
873+
public static extern int GetPriorityClipboardFormat(IntPtr paFormatPriorityList, int cFormats);
874+
875+
[DllImport(LibraryName, ExactSpelling = true)]
876+
public static extern uint EnumClipboardFormats(uint format);
877+
878+
#endregion
823879
}
824880
}

0 commit comments

Comments
 (0)