Restored from previous forum. Originally posted by cor.
Thanks for your quick reply.
You can also use the following command to test if the copy was successfull.
If IsClipboardFormatAvailable_(#CF_BITMAP) = 0
MessageRequester("","Fault copy",#PB_MessageRequester_Ok)
EndIf
There is only one problem:
When I close the program it give the following code:
Stack fault in 'kernel32.dll'
Just test the code by yourself
Code: Select all
Gosub createimage
wndpl.WINDOWPLACEMENT
wndpl\Length = SizeOf(WINDOWPLACEMENT)
wndpl\showCmd = #SW_SHOWMAXIMIZED
wndpl\flags = 0;
If OpenWindow(0, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget, "PureBasic Demo")
SetWindowPlacement_(WindowID(), @wndpl)
Gosub createimage
Procedure WindowCallback(WindowID, Message, lParam, wParam)
If Message = #WM_PAINT
StartDrawing(WindowOutput())
DrawImage(ImageID(), 100, 10)
StopDrawing()
EndIf
EndProcedure
SetWindowCallback(@WindowCallback())
OpenClipboard_(0)
EmptyClipboard_()
SetClipboardData_(#CF_BITMAP,hnd)
CloseClipboard_()
If IsClipboardFormatAvailable_(#CF_BITMAP) = 0
MessageRequester("","Fault copy",#PB_MessageRequester_Ok)
EndIf
; Wait for UserInput
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Case #PB_EventRepaint
Case #WM_CLOSE ; #PB_EventCloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
createimage:
hnd=CreateImage(0,250,200)
StartDrawing(ImageOutput())
; DrawingMode(1)
FrontColour(255,255,255)
Box(0,0,250,200)
FrontColour(0,0,0)
xpos=50
xwidth=100
yheight=100
; draw guitar box
For y= 35 To 37
Line(50,y,xwidth,0)
Next
For y= 40 To 40
Line(50,y,xwidth,0)
Line(50,y+20,xwidth,0)
Line(50,y+40,xwidth,0)
Line(50,y+60,xwidth,0)
Line(50,y+80,xwidth,0)
Line(50,y+100,xwidth,0)
Next
For x = 50 To 50
Line(x,40,0,yheight)
Line(x+20,40,0,yheight)
Line(x+40,40,0,yheight)
Line(x+60,40,0,yheight)
Line(x+80,40,0,yheight)
Line(x+100,40,0,yheight)
Next
StopDrawing()
Return
End
Registered user of PB
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com