Look at the code below
Clicking on the button will copy the bitmap to clipboard
Then paste it into e.g. wordpad ->>> No problem -> WM_PAINT works ok
Then clicking for the second time on the button --->> Nothing on clipboard->> WM_PAINT doesn't work anymore. see if you focus to other windows and go back to this program.
Someone a solution?
Code: Select all
;
;
InitGadget(5)
If OpenWindow(0, 100, 100, 500, 300, $10CF0000, "PureBasic - Image")
If CreateGadgetList(WindowID())
ButtonGadget(0,300,20,150,24,"Copy to clipboard")
Else
MessageRequester("Info","Error creating gadgetlist",0)
EndIf
Gosub CreateImage
Procedure WindowCallback(WindowID, Message, lParam, wParam)
If Message = #WM_PAINT
StartDrawing(WindowOutput())
DrawImage(ImageID(), 20, 10)
StopDrawing()
EndIf
EndProcedure
SetWindowCallback(@WindowCallback())
Repeat
EventID = WaitWindowEvent()
If EventID=#PB_EventGadget
Select EventgadgetID
Case 0
Openclipboard_(0)
Emptyclipboard_()
setclipboarddata_(#CF_BITMAP,hIMG)
closeclipboard_()
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow ; If the user has pressed on the close button
EndIf
End ; All the opened windows are closed automatically by PureBasic
;
; Some 2D graphics functions...
;
CreateImage:
hIMG= CreateImage(0, 255, 255)
If hIMG
StartDrawing(ImageOutput())
For k=0 To 255
FrontColour(k,0, k) ; a rainbow, from black to pink
Line(0, k, 255, 0)
Next
DrawingMode(1)
Locate(40, 50)
FrontColour(255,255,255) ; print the text to white !
DrawText("An image created easely...")
StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
EndIf
Return
; ExecutableFormat=Windows
; DisableDebugger
Registered PB version : 2.90 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com