I'm getting a bitmap from the clipboard and displaying it in a GUI.
Here is some sample code:
Code: Select all
; Open the ClipBoard
While (! DllCall("OpenClipboard", "UInt", 0))
Sleep, 10
Critical, On
; Get Bitmap data
If (Handle := DllCall("GetClipboardData", "UInt", 17))
{
Size := DllCall("GlobalSize", "UInt", Handle)
Pointer := DllCall("GlobalLock", "UInt", Handle)
VarSetCapacity(Data, Size)
DllCall("RtlMoveMemory", "UInt", &Data, "UInt", Pointer, "UInt", Size)
DllCall("GlobalUnlock", "UInt", Handle)
}
; Close Clipboard
DllCall("CloseClipboard")
Critical, Off
; Quit if no bitmap
If (! Handle)
{
MsgBox, No bitmap on clipboard.
ExitApp
}
; Write file.
VarSetCapacity(Header, 14, 0)
NumPut(Ord("B"), Header, 0, "Char")
NumPut(Ord("M"), Header, 1, "Char")
FileDescriptor := FileOpen("clip.bmp", "w")
FileDescriptor.RawWrite(Header, 14)
FileDescriptor.RawWrite(Data, Size)
FileDescriptor.Close()
; Show the picture.
Pic := LoadPicture("clip.bmp")
Gui, Add, Pic, w600 h-1 vPic +Border, % "HBITMAP:*" Pic
Gui, Show
Return
GuiClose:
ExitApp
Is there a way to get an HBITMAP handle directly from the clipboard data?
Thanks,
Steve