Gadget order of appearence

Windows specific forum
banban73
User
User
Posts: 21
Joined: Sun Jul 18, 2004 12:03 pm
Location: Bergerac - France

Gadget order of appearence

Post by banban73 »

Hello
I am trying to make a cool window for my app, which will look like a sheet of japanese paper and in which buttons will be fully integrated and customized (i.e images without borders).
In order to achieve this gui, I tried to use imagegadget() for the background and for the "buttons" also.
My problem is that the "buttons" do not appear. It seems that the background imagegadget() displays over the buttons, even if I change the order of declaration in the gadgetlist()

Please help !!!
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

I've noticed that the order of appearance is wacky in PB, maybe fred could provide some clarification on how to set the Z order.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Without seeing any code, my best guess is to try using #WS_CLIPSIBLINGS on your image gadget.

Code: Select all

SetWindowLong_(GadgetID((#YourImageGadget), #GWL_STYLE, GetWindowLong_(GadgetID(#YourImageGagdet), #GWL_STYLE) | #WS_CLIPSIBLINGS) 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Fred
Administrator
Administrator
Posts: 18360
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Theorically gadgets overlapping is not supported in PB. But on Windows (and only on Windows) you can try to put your button directly in the ImageGadget() by using UseGadgetList(GadgetID(#YourImageGadget)).
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

oh interesting...
banban73
User
User
Posts: 21
Joined: Sun Jul 18, 2004 12:03 pm
Location: Bergerac - France

Post by banban73 »

Thanks Everybody for your replies.

After posting my message yesterday, I reorganised again the order of declaration in gadgetlist and tried changing gadgetId and it comes to work.
But thanks again, I will keep your tips in mind for the next time as I may have been lucky this time.

Regards
User avatar
Blue
Addict
Addict
Posts: 972
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Post by Blue »

Fred wrote:Theorically gadgets overlapping is not supported in PB. But on Windows (and only on Windows) you can try to put your button directly in the ImageGadget() by using UseGadgetList(GadgetID(#YourImageGadget)).
Your answer surprised me and got me all excited. I tried it immediately, and found that it works great visually, but is severely handicapped functionnally.

It seems that EventGadget() only sees the imageGadget.

Any idea on how to catch the GadgetIDs of those buttons clearly visible (and seemingly functional) on the picture ?

A solution, if it exists (!) would be much appreciated...

===================
Forget the above.
using another method, the code below now works fine:

Code: Select all


; ==============================================
;  Blue - octobre 2007
;; Window with picture as a background for controls
;;=================================================

;;#imageName = "D:\Projets\PureBasic\Marqueur\bones.jpg"
#imageNameA = "bones.jpg"   ;; picture is 344 X 341
#imageNameB = "bonesG.png"  ;; a light gray copy of above

Enumeration
  #imageFond
  #imageB
  #txtBox
  #strBox
  #bouton1
  #bouton2
  #bouton3
  #cmdImage
  #cmdQuit
EndEnumeration

Declare.L TellMe(id.L)
Declare.L ChangeImage()

;****************************************************
;- initializing pictures
; Plugins 
UseJPEGImageDecoder() 
UsePNGImageDecoder() 

Global JamesBones,JamesGhost  ;; handles for pictures

JamesBones = CatchImage(#imageFond, ?bones)
JamesGhost = CatchImage(#imageB, ?ghost)

DataSection 
bones: IncludeBinary #imageNameA
ghost: IncludeBinary #imageNameB
EndDataSection 

;****************************************************
;- creating the window
  imgW = ImageWidth(#imageFond) 
  imgH = ImageHeight(#imageFond)
  
;; #wintype = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
  #wintype =  #WS_POPUP

hWnd = OpenWindow(0, 200, 300, imgW+20, imgH+20, "ImageGadget", #winType)
If 0 = hWnd
  End
EndIf

SetWindowColor(0, $AA9900)

;- installing gadgets
If 0 = CreateGadgetList(hWnd)
  End
EndIf
;; a key to quickly close the window
AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape)

#gX = 16 : gY = imgH - 13 - 2*25 : #gW = 90

ImageGadget(#imageFond, 10, 10, 100, 83, JamesBones)
TextGadget( #txtBox,   #gX, 30, 200, 16, "Simple sample")
StringGadget(#strBox,  #gX, 50, 200, 20, "a string for the road", #PB_String_BorderLess)

ButtonGadget(#bouton1, #gX, gY   , #gW, 20, " He did",   #PB_Button_Left)
ButtonGadget(#bouton2, #gX, gY+25, #gW, 20, "Something")
ButtonGadget(#bouton3, #gX, gY+50, #gW, 20, "Right ",    #PB_Button_Right)
ButtonGadget(#cmdQuit, imgW-60, imgH - 13, 60, 20, "Quit")
ButtonGadget(#cmdImage, imgW-60-5-50, imgH - 13, 50, 20, "Ghost")

;; netMaaestro's suggestion - works perfectly
DisableGadget(#imageFond, 1)

HideGadget(#txtBox,1)   ;; force Windows to display this control
HideGadget(#txtBox,0)

;****************************************************
;-   main application loop  *************************
Repeat
  EventID = WaitWindowEvent()

  If #PB_Event_Menu = EventID
    kbd = EventMenu() 
    Select kbd
      Case #PB_Shortcut_Escape: End
      ;;Case whatever: yes, real soon now
    EndSelect
  EndIf  

  If #PB_Event_Gadget = EventID
    GadgetID = EventGadget()
    Select GadgetID
      Case #bouton1 To #bouton3 : TellMe(GadgetID)
      Case #cmdImage : ChangeImage()
      Case #cmdQuit: End
    EndSelect

  ElseIf #PB_Event_CloseWindow = EventID
    End
  EndIf
ForEver

Procedure.L ChangeImage()
  For i = #txtBox To #cmdQuit
    HideGadget(i,1)
  Next
  If GetGadgetData(#cmdImage) = 1
    SetGadgetData(#cmdImage,0)
    SetGadgetState(#imageFond,JamesBones)
    SetGadgetText(#cmdImage,"Ghost") 
  Else
    SetGadgetText(#cmdImage,"Bones") 
    SetGadgetData(#cmdImage,1)
    SetGadgetState(#imageFond, JamesGhost)
  EndIf
  For i = #txtBox To #cmdQuit
    HideGadget(i,0)
  Next
EndProcedure
Procedure TellMe(id.L)
  SetGadgetText(#txtBox, GetGadgetText(id))
;;  MessageRequester("Info", "We have a Gadget with ID #" + Str(id) +".", 0)
EndProcedure
Last edited by Blue on Tue Oct 09, 2007 9:12 am, edited 3 times in total.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
User avatar
Blue
Addict
Addict
Posts: 972
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Post by Blue »

Oops...
I just looked at the posting dates on the previous messages, and suddenly realize that I'll most likely remain very lonely here for the foreseeable future !!!

Doesn't matter. I like talking to myself.

Fred's suggestion is not the solution.
But somewhere else in this forum, NetMaestro offered that disabling the image gadget would allow the messages from the buttons to come trhrough. And he's right.

That works...

link to netmaestro's solution: http://www.purebasic.fr/english/viewtop ... 207#213207
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Post Reply