Clarification of GadgetID()

Everything else that doesn't fall into one of the other PB categories.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Clarification of GadgetID()

Post by Polo »

Hi !
On the help I can read for this command :
"Returns the unique system identifier"
however when I do that :

Code: Select all

hwnd=ComboBoxGadget([b]0[/b],....)
id=GadgetID(0)
hwnd returns the system identifier, but id seems to return PB's handle.
I think it should be more precise, maybe two command, GadgetID and GadgetHandle, or something like that...
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Hi Polo
I dont know what you did wrong here or if i understand you wrong?
but the id should be the same as hwnd

Code: Select all

 If CreateGadgetList(WindowID())
      hwnd=ComboBoxGadget(0,10,10,250,100,#PB_ComboBox_Editable)
      Debug hwnd
      id=GadgetID(0)
      Debug id      

Well if you use a constant for pb handler
you can alwayes debug it
Debug #Container_100x

Best regrads
Henrik
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Ah, I see what I did, I took the StatusBar as a gadget.
But, now, there is no function to get the system handle of a statusbar :)
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Hi
Why not just do this ?

Code: Select all

If OpenWindow(#Window_0, 216, -7, 600, 300,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
    Shwnd=CreateStatusBar(#StatusBar_0, WindowID())
    If Shwnd 
    Debug Shwnd
    EndIf

*Edit
That should have been " Sbhwnd= StatusBarID(#Bla) " then...

best regrads
Henrik
Last edited by Henrik on Sun Oct 16, 2005 12:38 pm, edited 1 time in total.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I said there was no command to get the system handle. I didn't said it wasn't possible to get it.
But the code you showed and that I have to use is really dirty, I hate it, but well...

BTW, if I do that :
pbhandle=Statusbar(#pb_any,.....)
Then I can't get the System id of the statusbar. I don't know to what Fred was thinking when he wrote the Gadgets/Windowing stuffs :wink:
I hope there will be a complete rework of all this for PB4.
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

#Pb_Any

RIGHT you are :D
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Hi Polo your are right that pb should have it's own way of returning
the system handler for the Statusbar, "StatusbarID()"

but if you are willing to use win_api you could do this

Code: Select all

If OpenWindow(#Window_0, 216, -7, 600, 300,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
    Hwnd =WindowID()
    
    PB_Sbhwnd=CreateStatusBar(#StatusBar_0, WindowID())
    If PB_Sbhwnd 
    AddStatusBarField(90)
    StatusBarText(0, 0, "Bla")
   EndIf
   
    Debug "PB_Shwnd = "+Str(PB_Sbhwnd )


    Api_SBHWND =FindWindowEx_(Hwnd,0,"msctls_statusbar32",0)
    Debug"Api_SBHWND = "+Str(Api_SBHWND)
Best regrads
Henrik
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

if you need this now, you can make a userlib with tailbite from this:

Code: Select all

Procedure StatusbarID()
  !If ~ defined _PB_StatusBar_CurrentObject | defined @f
  !   extrn _PB_StatusBar_CurrentObject
  !   @@:
  !End If
  !If ~ defined _PB_StatusBar_ObjectsArea | defined @f
  !   extrn _PB_StatusBar_ObjectsArea
  !   @@:
  !End If
  !PUSH dword [_PB_StatusBar_CurrentObject]
  !POP eax
  !MOV eax, [eax]
  ProcedureReturn
EndProcedure

Procedure StatusbarID2(StatusBar)
  !If ~ defined _PB_StatusBar_CurrentObject | defined @f
  !   extrn _PB_StatusBar_CurrentObject
  !   @@:
  !End If
  !If ~ defined _PB_StatusBar_ObjectsArea | defined @f
  !   extrn _PB_StatusBar_ObjectsArea
  !   @@:
  !End If
  !MOV ecx, [esp]
  !PUSH dword [_PB_StatusBar_ObjectsArea]
  !POP eax
  !MOV eax, [eax+8*ecx]
  ProcedureReturn
EndProcedure

If OpenWindow(0, 100, 150, 300, 100, #PB_Window_SystemMenu | #PB_Window_SizeGadget, "PureBasic - StatusBar Example")
  hWnd = CreateStatusBar(2, WindowID())
  Debug hWnd
  If hWnd
    AddStatusBarField(100)
    AddStatusBarField(50)
    AddStatusBarField(100)
  EndIf
  
  StatusBarText(2, 0, "Area 1")
  StatusBarText(2, 1, "Area 2", #PB_StatusBar_BorderLess)
  StatusBarText(2, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised) 
  
  Debug StatusbarID()
  Debug StatusbarID2(2)
  
  Repeat
    
  Until WaitWindowEvent() = #PB_Event_CloseWindow
  
EndIf
anyway, fred should add this.
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It will be added.
Post Reply