Page 1 of 1

Clarification of GadgetID()

Posted: Sun Oct 16, 2005 10:52 am
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...

Posted: Sun Oct 16, 2005 12:09 pm
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

Posted: Sun Oct 16, 2005 12:18 pm
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 :)

Posted: Sun Oct 16, 2005 12:26 pm
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

Posted: Sun Oct 16, 2005 12:35 pm
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.

Posted: Sun Oct 16, 2005 12:40 pm
by Henrik
#Pb_Any

RIGHT you are :D

Posted: Sun Oct 16, 2005 1:30 pm
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

Posted: Sun Oct 16, 2005 5:41 pm
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.

Posted: Sun Oct 16, 2005 6:23 pm
by Fred
It will be added.