How to set a background image for a window?
Ah yes, sorry!!! The api is needed only because I have placed buttons inside the image gadget. If the buttons remained outside of the image gadget then we wouldn't need the subclassing.
The following only places the listview inside the imagegadget and is thus crossplatform :
The following only places the listview inside the imagegadget and is thus crossplatform :
Code: Select all
CreateImage(1,300,300)
StartDrawing(ImageOutput(1))
DrawingMode(#PB_2DDrawing_Default)
Box(0,0,300,300,RGB(111,111,222))
StopDrawing()
LoadImage(2,"test.bmp")
StartDrawing(ImageOutput(1))
DrawImage(ImageID(2),0,0,300,300)
StopDrawing()
Flag = #PB_Window_ScreenCentered|#PB_Window_BorderLess
WindowHandler = OpenWindow(#PB_Any,0,0,300,300,"ImageGadgetTest",Flag)
If WindowHandler <> 0
If CreateGadgetList(WindowID(WindowHandler))
ImageGadget(3,0,0,300,300,ImageID(1))
DisableGadget(3,1)
ButtonGadget(4,10,10,280,20,"new item")
ButtonGadget(6,10,270,280,20,"quit")
UseGadgetList(GadgetID(3))
Flag = #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection
ListViewGadget(5,10,40,280,210,Flag)
EndIf
EndIf
number = 1
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow : Break
Case #PB_Event_Gadget
Select EventGadget()
Case 4 : AddGadgetItem(5,-1," a new item - "+Str(number)) : number + 1
Case 6 : Break
EndSelect
EndSelect
ForEverI may look like a mule, but I'm not a complete ass.
srod, I've seen you use the UseGadgetList(GadgetID) trick before so I'm guessing it's safe to use.
If that is the case, maybe the PB help file should mention the fact that UseGadgetList() can be used with a WindowID as well as a GadgetID.
If that is the case, maybe the PB help file should mention the fact that UseGadgetList() can be used with a WindowID as well as a GadgetID.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
Hi srod. When using UseGadgetList() then all following defines of gadgets go to that UseGadgetList() defined gadget? How to stop that? Only if defining bevor? But why i can add an item to that enclosed gadget 5 and get no event if i set the buttons after that UseGadgetList() and they are allthough enclosed? Maybe i'm a little silly but i do not understand what that UseGadgetList() should do and how i can use that. And i have a lot of buttons "on" my image gadget so i can't use that anymore. Hope i thought correctly. ;)
Sparkie it is completely safe - I use it in various projects. Whether it has the same kind of effect (from a parent/child point of view) on Linux I do not know? However, I will add that PB isn't really set up (event wise) for us resetting parent controls etc. This is one reason why I very rarely use a PB event loop.
@MyTrial : certain gadgets (on Windows at least) send certain notifications to their parent control. For example, a button will send it's #BN_CLICKED notification to it's parent to inform it's parent that the user has clicked the button etc. Now, ordinarily, PB is on the look out for these notifications by examining all messages sent to the parent Window. By moving the button to be a child of an image gadget, it's #BN_CLICKED notifications are no longer being sent to the main window, but to the image gadget and Purebasic is now looking for these notifications in the wrong place. In the first code I posted, I took steps to circumvent this by manually forwarding these notofications back to the main window. (Incidentally my second code is useless because of having to disable the image gadget.) Personally, I regard PB's inability to pick up these events not so much as a bug, but an omission certainly!
As for your specific problem, there is nothing stopping you using UseGadgetList() again to reset the current gadget list. I accept, however, that this approach is probably not suitable for your requirements.
@MyTrial : certain gadgets (on Windows at least) send certain notifications to their parent control. For example, a button will send it's #BN_CLICKED notification to it's parent to inform it's parent that the user has clicked the button etc. Now, ordinarily, PB is on the look out for these notifications by examining all messages sent to the parent Window. By moving the button to be a child of an image gadget, it's #BN_CLICKED notifications are no longer being sent to the main window, but to the image gadget and Purebasic is now looking for these notifications in the wrong place. In the first code I posted, I took steps to circumvent this by manually forwarding these notofications back to the main window. (Incidentally my second code is useless because of having to disable the image gadget.) Personally, I regard PB's inability to pick up these events not so much as a bug, but an omission certainly!
As for your specific problem, there is nothing stopping you using UseGadgetList() again to reset the current gadget list. I accept, however, that this approach is probably not suitable for your requirements.
I may look like a mule, but I'm not a complete ass.
Re: How to set a background image for a window?
Hi
here comes a very last information on parts of this: Sparkie gave me a answer for refreshing which worked fine on windows os, but not on linux. I found in the past an other solution which works on windows and linux if i use a background image in a window. By start and by every action which changes the background image or some other parts of the gadgets, i use the following to refresh.
#GUI_BACK is the handle of the imagegadget of the background image.
Thanks for all your help
and hopefully this helps some other
Sigi
here comes a very last information on parts of this: Sparkie gave me a answer for refreshing which worked fine on windows os, but not on linux. I found in the past an other solution which works on windows and linux if i use a background image in a window. By start and by every action which changes the background image or some other parts of the gadgets, i use the following to refresh.
Code: Select all
HideGadget(#GUI_BACK,1)
HideGadget(#GUI_BACK,0)Thanks for all your help
and hopefully this helps some other
Sigi

