by the handle get gadget ident

Just starting out? Need help? Post your questions and find answers here.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: by the handle is a gadget

Post by ts-soft »

You should change line 61 to:

Code: Select all

LoadImage(12, #PB_Compiler_Home + "examples/sources/Data/Geebee2.bmp")
:wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: by the handle is a gadget

Post 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 ?
Last edited by Bisonte on Thu Feb 27, 2014 6:37 pm, edited 1 time in total.
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: by the handle is a gadget

Post by ts-soft »

Bisonte wrote:aaaarg these %$&§" Slashes :lol:
Not only slashes, linux is casesensitiv!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: by the handle is a gadget

Post 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....
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: by the handle is a gadget

Post by ts-soft »

Don't use the Windows-Explorer, that is not quite fairly to his users :mrgreen:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: by the handle is a gadget

Post 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.
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: by the handle is a gadget

Post 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  
Post Reply