Restored from previous forum. Originally posted by LJ.
Something is wrong with the follow code:
hWnd = OpenWindow(0, 0, 0, 796, 550, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
LoadImage(0,"test.bmp")
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 20, 10)
StopDrawing()
ButtonGadget(15, 300, 335, 80, 24, "Quit")
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
End
You must create a test.bmp to test this. If the ButtonGadget line is ; (rem'd) out, then the test.bmp image is displayed. But not the button. If the the LoadImage, StartDrawing, DrawImage, StopDrawing lines are ; (rem'd) out, then the button Quit is displayed but not the image. It's an either or situation. I can get either one to display on the window, but not both at the same time. Does anyone know what I'm doing wrong?
Display Image on Screen with Button at same Time?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by LJ.
Alright, I solved my problem by switching two lines to this:
hWnd = OpenWindow(0, 0, 0, 796, 550, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
ButtonGadget(15, 300, 335, 80, 24, "Quit")
LoadImage(0,"test.bmp")
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 20, 10)
StopDrawing()
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
End
Notice the button is created first, then the image created second. By simply putting things in this order, it works! For some reason the image must be drawn after the buttons.
Alright, I solved my problem by switching two lines to this:
hWnd = OpenWindow(0, 0, 0, 796, 550, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
ButtonGadget(15, 300, 335, 80, 24, "Quit")
LoadImage(0,"test.bmp")
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 20, 10)
StopDrawing()
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
End
Notice the button is created first, then the image created second. By simply putting things in this order, it works! For some reason the image must be drawn after the buttons.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by LJ.
For example, this code below doesn't work:
hWnd = OpenWindow(0, 0, 0, 796, 550, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
ButtonGadget(1, 315, 160, 102, 29, "Option1")
ButtonGadget(2, 315, 200, 102, 29, "Option2")
LoadImage(0,"test.bmp")
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 0, 0)
StopDrawing()
ImageGadget(3, 10,10,150,150,0)
ClosePanelGadget()
SetWinBackgroundColor(hWnd, RGB( 34, 85, 136))
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 1 ; Quit...
FreeGadget (1)
Case 2 ;
FreeGadget (2)
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
For example, this code below doesn't work:
hWnd = OpenWindow(0, 0, 0, 796, 550, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
ButtonGadget(1, 315, 160, 102, 29, "Option1")
ButtonGadget(2, 315, 200, 102, 29, "Option2")
LoadImage(0,"test.bmp")
StartDrawing(WindowOutput())
DrawImage(UseImage(0), 0, 0)
StopDrawing()
ImageGadget(3, 10,10,150,150,0)
ClosePanelGadget()
SetWinBackgroundColor(hWnd, RGB( 34, 85, 136))
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 1 ; Quit...
FreeGadget (1)
Case 2 ;
FreeGadget (2)
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm