"No Return value" and use of "PB_Any"

Just starting out? Need help? Post your questions and find answers here.
Little_man
Enthusiast
Enthusiast
Posts: 152
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

"No Return value" and use of "PB_Any"

Post by Little_man »

How to do this without "Return value" and using "#PB_Any" ?

Select Event
     Case ???
     FreeGadget(???)

Code: Select all

EnableExplicit

;Opsommingen.
Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
  #ScrlArea_1
EndEnumeration

;Afbeeldingen laden.
UsePNGImageDecoder()    ;Enables the PNG (Portable Network Graphic) image support
UseJPEGImageDecoder()   ;Enables the JPEG (Joint Picture Expert Group) image support

Global.i I01, I02, I03
Global.i Event

Global.s Source_Directory = "C:\Merging Images XXXX\Images\"

I01                       = LoadImage(#PB_Any, Source_Directory + "T_01.png")
Global.d Rows             = 2     ;Colomna.
Global.d Columns          = 3     ;Rows.
Global.d S                = 10   ;Seperator.
;Global.d Dim File(3)
Global.d W                = ImageWidth(I01)
Global.d H                = ImageHeight(I01)
Global.d Scale            = H / 110

ResizeImage(I01, ImageWidth(I01) / Scale, ImageHeight(I01) / Scale)
I02 = LoadImage(#PB_Any, Source_Directory + "T_02.png"): ResizeImage(I02, ImageWidth(I02) / Scale, ImageHeight(I02) / Scale)
I03 = LoadImage(#PB_Any, Source_Directory + "T_03.png"): ResizeImage(I03, ImageWidth(I03) / Scale, ImageHeight(I03) / Scale)

Procedure Open_Window_0()
  OpenWindow(#Window_0, 0, 0, 1000, 400, "Merging Photos", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
  ScrollAreaGadget(#ScrlArea_1, 20, 20, 960, 145, (11 * S) + (10 * W / Scale), (3 * S) + (2 * H / Scale), 249, #PB_ScrollArea_Flat)
    ;File(1) = ImageGadget(#PB_Any,   10,  10, 165, 110, ImageID(I01))
    ImageGadget(#PB_Any,   10,  10, 165, 110, ImageID(I01))
    ;File(2) = ImageGadget(#PB_Any,  185,  10, 165, 110, ImageID(I02))
    ImageGadget(#PB_Any,  185,  10, 165, 110, ImageID(I02))
    ;File(3) = ImageGadget(#PB_Any,   10, 132, 165, 110, ImageID(I03))
    ImageGadget(#PB_Any,   10, 132, 165, 110, ImageID(I03))
  CloseGadgetList()
EndProcedure

Open_Window_0()

Repeat
  Event = WaitWindowEvent()

  Select Event
      Case #PB_Event_CloseWindow
      Break

      ;-> Event Gadget
    Case #PB_Event_Gadget

      Select EventGadget()
        Case ???          ;Case Gadget Name, Was File(1).

        Case ???          ;Case Gadget Name, was File(2).
          FreeGadget(???)
          
        Case ???          ;Case Gadget Name, was File(3).
      EndSelect

  EndSelect
ForEver
Little_man
User avatar
Erlend
Enthusiast
Enthusiast
Posts: 114
Joined: Mon Apr 19, 2004 8:22 pm
Location: NORWAY

Re: "No Return value" and use of "PB_Any"

Post by Erlend »

Hello Little_man

Code: Select all

EnableExplicit

;Opsommingen.
Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
  #ScrlArea_1
EndEnumeration

;Afbeeldingen laden.
UsePNGImageDecoder()    ;Enables the PNG (Portable Network Graphic) image support
UseJPEGImageDecoder()   ;Enables the JPEG (Joint Picture Expert Group) image support

Global.i I01, I02, I03
Global.i HI01, HI02, HI03
Global.i Event

Global.s Source_Directory = "C:\Merging Images XXXX\Images\"

I01                       = LoadImage(#PB_Any, Source_Directory + "T_01.png")
Global.d Rows             = 2     ;Colomna.
Global.d Columns          = 3     ;Rows.
Global.d S                = 10   ;Seperator.
;Global.d Dim File(3)
Global.d W                ;= ImageWidth(I01)
Global.d H                ;= ImageHeight(I01)
Global.d Scale            ;= H / 110

ResizeImage(I01, ImageWidth(I01) / Scale, ImageHeight(I01) / Scale)
I02 = LoadImage(#PB_Any, Source_Directory + "T_02.png"): ResizeImage(I02, ImageWidth(I02) / Scale, ImageHeight(I02) / Scale)
I03 = LoadImage(#PB_Any, Source_Directory + "T_03.png"): ResizeImage(I03, ImageWidth(I03) / Scale, ImageHeight(I03) / Scale)


W=ImageWidth(I01)
H=ImageHeight(I01)
Scale= H/110

Procedure Open_Window_0()
  OpenWindow(#Window_0, 0, 0, 1000, 400, "Merging Photos", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
  ScrollAreaGadget(#ScrlArea_1, 20, 20, 960, 145, (11 * S) + (10 * W / Scale), (3 * S) + (2 * H / Scale), 249, #PB_ScrollArea_Flat)
    ;File(1) = ImageGadget(#PB_Any,   10,  10, 165, 110, ImageID(I01))
    HI01=ImageGadget(#PB_Any,   10,  10, 165, 110, ImageID(I01))
    ;File(2) = ImageGadget(#PB_Any,  185,  10, 165, 110, ImageID(I02))
    HI02=ImageGadget(#PB_Any,  185,  10, 165, 110, ImageID(I02))
    ;File(3) = ImageGadget(#PB_Any,   10, 132, 165, 110, ImageID(I03))
    HI03=ImageGadget(#PB_Any,   10, 132, 165, 110, ImageID(I03))
  CloseGadgetList()
EndProcedure

Open_Window_0()

Repeat
  Event = WaitWindowEvent()

  Select Event
      Case #PB_Event_CloseWindow
      Break

      ;-> Event Gadget
    Case #PB_Event_Gadget

      Select EventGadget()
        Case HI01         ;Case Gadget Name, Was File(1).

        Case HI02         ;Case Gadget Name, was File(2).
          FreeGadget(HI01)
          
        Case HI03         ;Case Gadget Name, was File(3).
      EndSelect

  EndSelect
ForEver
Short answer is you dont. Above I modified your code to show how it should be done, probably not working as I do not have PB on current device. And also why not just use fixed number for what you are doing??

BR
Erlend 'Preacher' Rovik
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: "No Return value" and use of "PB_Any"

Post by jacdelad »

Creating a Gadget/Window/Image/other stuff when using #PB_Any returns the handle to the object. Store that handle in an .i-variable to use it later.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Little_man
Enthusiast
Enthusiast
Posts: 152
Joined: Fri Mar 29, 2013 4:55 pm
Location: The Netherland

Re: "No Return value" and use of "PB_Any"

Post by Little_man »

"THANKS" Erlend for your info !!...

The solution you suggested was after the ";" character in the specified code
Post Reply