Page 2 of 2

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 9:48 am
by ts-soft
You should change line 61 to:

Code: Select all

LoadImage(12, #PB_Compiler_Home + "examples/sources/Data/Geebee2.bmp")
:wink:

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 6:34 pm
by Bisonte
ts-soft wrote:You should change line 61 to:

Code: Select all

LoadImage(12, #PB_Compiler_Home + "examples/sources/Data/Geebee2.bmp")
:wink:
aaaarg these %$&§" Slashes (Done) :lol:

By the way... are there more "PB.xxx.Objects", I can put in this procedure ?

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 6:37 pm
by ts-soft
Bisonte wrote:aaaarg these %$&§" Slashes :lol:
Not only slashes, linux is casesensitiv!

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 6:38 pm
by Bisonte
ts-soft wrote:
Bisonte wrote:aaaarg these %$&§" Slashes :lol:
Not only slashes, linux is casesensitiv!
On my windows installation I copy the path from the explorer window... with the capital letters....

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 6:44 pm
by ts-soft
Don't use the Windows-Explorer, that is not quite fairly to his users :mrgreen:

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 7:29 pm
by Danilo
Bisonte wrote:By the way... are there more "PB.xxx.Objects", I can put in this procedure ?
Sound, Sprite, Library, File, etc...

Doesn't make sense to put everything into one procedure, because you need
to always include all libraries then. Try calling your procedure with an ImageID()
and without opening a window and without using any command from the window lib.
Probably leads to an linker error if PB_Window_Objects is not included.

(EDIT: Doesn't throw a linker error because all libs get integrated anyway,
because GadgetID() / ImageID() / WindowID() are used within the module)

Also note that this are PB internal commands from the PB SDK. Internals could change at any time,
although the object system has been stable over the last few years.

Re: by the handle is a gadget

Posted: Thu Feb 27, 2014 8:59 pm
by mestnyi
Why did Fred isgadget (), iswindow (), isimage () here like it would be convenient to see for yourself.

Code: Select all

    DeclareModule Get_PB_Object
      Enumeration 1
        #PB_ID_Window
        #PB_ID_Gadget
        #PB_ID_Image
      EndEnumeration
     
      CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        Import ""
      CompilerElse
        ImportC ""
      CompilerEndIf 
        PB_Object_EnumerateStart(*object)
        PB_Object_EnumerateNext(*object,*id.Integer)
        PB_Object_EnumerateAbort(*object)
        PB_Window_Objects.i
        PB_Gadget_Objects.i
        PB_Image_Objects.i
      EndImport
     
      Declare PB_ID(OS_Handle, Type = #PB_ID_Window)
    EndDeclareModule
    Module Get_PB_Object
     EnableExplicit
     Procedure PB_ID(OS_Handle, Type = #PB_ID_Window)
       Protected ID, Objects, Result = -1
        Select Type
            Case #PB_ID_Gadget :Objects = PB_Gadget_Objects
            Case #PB_ID_Image  :Objects = PB_Image_Objects
            Case #PB_ID_Window :Objects = PB_Window_Objects
          EndSelect
         
          PB_Object_EnumerateStart(Objects)
          While PB_Object_EnumerateNext(Objects, @ID)
            Select Type
              Case #PB_ID_Window :If OS_Handle = WindowID(ID) Or (IsWindow(OS_Handle) And OS_Handle = ID) :Result = ID :PB_Object_EnumerateAbort(Objects) :Break :EndIf
              Case #PB_ID_Gadget :If OS_Handle = GadgetID(ID) Or (IsGadget(OS_Handle) And OS_Handle = ID) :Result = ID :PB_Object_EnumerateAbort(Objects) :Break :EndIf
              Case #PB_ID_Image  :If OS_Handle = ImageID(ID)  Or (IsImage(OS_Handle)  And OS_Handle = ID) :Result = ID :PB_Object_EnumerateAbort(Objects) :Break :EndIf
            EndSelect
          Wend
         ProcedureReturn Result
      EndProcedure
     EndModule
    Macro Window(hWnd)
     Get_PB_Object::PB_ID(hWnd)
    EndMacro
    Macro Gadget(hWnd)
     Get_PB_Object::PB_ID(hWnd, Get_PB_Object::#PB_ID_Gadget)
    EndMacro
    Macro Image(hWnd)
     Get_PB_Object::PB_ID(hWnd, Get_PB_Object::#PB_ID_Image)
    EndMacro
    
    Procedure Is_Window(Window)
     ProcedureReturn IsWindow(Get_PB_Object::PB_ID(Window))
    EndProcedure
    Macro IsWindow(Window)
     Is_Window(Window)
    EndMacro
    
    Procedure Is_Gadget(Gadget)
     ProcedureReturn IsGadget(Get_PB_Object::PB_ID(Gadget, Get_PB_Object::#PB_ID_Gadget))
    EndProcedure
    Macro IsGadget(Gadget)
     Is_Gadget(Gadget)
    EndMacro
    
    Procedure Is_Image(Image)
     ProcedureReturn IsImage(Get_PB_Object::PB_ID(Image, Get_PB_Object::#PB_ID_Image))
    EndProcedure
    Macro IsImage(Image)
     Is_Image(Image)
    EndMacro
    
    LoadImage(10, #PB_Compiler_Home + "Examples/Sources/Data/GeeBee2.bmp")
    OpenWindow(10, 100, 100, 500, 300, "testwindow")
    ButtonGadget(10, 10, 10, 100, 20 , "test")
    
    img=10
    gad=10
    win=10
    
    
    Debug "Window = " + Str(Window(WindowID(win)))
    Debug "Gadget = " + Str(Gadget(GadgetID(gad)))
    Debug "Image  = " + Str(Image(ImageID(img))) 
    
    Debug IsWindow(win)
    Debug IsWindow(WindowID(win))

    Debug IsGadget(gad)
    Debug IsGadget(GadgetID(gad))
    
    Debug IsImage(img)
    Debug IsImage(ImageID(img))
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow