GetDlgCtrlID_ behaves strange (or not?)

Windows specific forum
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

Code: Select all

Global wnd,ctrl
wnd=OpenWindow(#PB_Any,0,0,400,300,"Window",#PB_Window_ScreenCentered)
ctrl=TextGadget(#PB_Any,0,0,400,300,"")
Debug ctrl
Debug GadgetID(ctrl)
Debug GetDlgCtrlID_(GadgetID(ctrl))
Shouldn't the last line return the value of ctrl?
Tested on Windows 10 x64, PB x64 6.00 Alpha 5 ASM.

Edit: Works with 32 Bit Compiler, so maybe a problem with return value (.l instead of .i)?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by BarryG »

jacdelad wrote: Wed Dec 08, 2021 4:13 amTested on Windows 10 x64, PB x64 6.00 Alpha 5 ASM
How do you select ASM for the compiler? I just did a clean install of PureBasic v6.00 Beta 1 and I only get this option:

Image
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

That is the ASM-Compiler. :lol: The C-Compiler ist marked as "C Backend".
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by BarryG »

Okay, I didn't realise. I don't get any other options though, such as the C backend. Seems a clean install doesn't include it.

Anyway, your code works fine for me with PB 6.00 Beta 1 (64-bit) on my Win 10 Pro (64-bit). Here's my debug output:

Code: Select all

36780560
198816
36780560
You said you're still using Alpha 5? Maybe time to test the Beta?
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by chi »

@jacdelad: Your code works fine here... Win7 x64 / a5 asm + c, b1 asm + c (x64 + x86)

@BarryG: Under Preferences/Compiler click on "...", select the pbcompilerc.exe and press "Add". You should now be able to switch to the C backend ;)
At the moment you have to do this with every new alpha/beta version of PB or you will use the last added C backend.
Et cetera is my worst enemy
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

Hm, that's strange. Didn't have this problem yesterday, even with the same compiler. Today TextGadget returned a large number, like a quad. But double converting it returned a smaller one, like a longint. Can't test it right now, I'm in bed and about to go to sleep (after nightshift). Will test it again in the evening.

Thanks for the replies. I don't use Beta 1 yet, I do a lot with maps and it seems to have more problems with them than Alpha 5.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by BarryG »

chi wrote: Wed Dec 08, 2021 6:52 amUnder Preferences/Compiler click on "...", select the pbcompilerc.exe and press "Add". You should now be able to switch to the C backend ;)
Ah, thanks for reminding me! I forgot about that. So this won't be necessary when v6.00 goes final, right?
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

Image
...under x64
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by ChrisR »

Strange, it works well here with PB5.73 x86 and x64 and also with PB6.00 beta 1 x64 asm and C Backend
GetDlgCtrlID_(GadgetID(ctrl)) = ctrl
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

Maybe I should switch to Beta 1. As I said, it worked before. Maybe sometimes the 64Bit-Handles are bigger than MaxLong (doesn't work), sometimes not (works)?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by mk-soft »

Fixed for Linux ...

Code: Select all

;-TOP by mk-soft

CompilerSelect #PB_Compiler_OS
    
  CompilerCase #PB_OS_Windows
    Procedure WindowPB(Handle)
      ProcedureReturn GetProp_(Handle, "pb_windowid") - 1
    EndProcedure
    
    Procedure GadgetPB(Handle)
      ProcedureReturn GetProp_(Handle, "pb_id")
    EndProcedure
    
  CompilerCase #PB_OS_Linux
    
    Procedure WindowPB(Handle)
      ProcedureReturn g_object_get_data_(Handle, "pb_id" )
    EndProcedure
    
    Procedure GadgetPB(Handle)
      ProcedureReturn g_object_get_data_(Handle, "pb_id" ) - 1 
    EndProcedure
      
  CompilerCase #PB_OS_MacOS
    
    Import ""
      PB_Window_GetID(hWnd) 
    EndImport
    
    Procedure WindowPB(Handle)
      ProcedureReturn PB_Window_GetID(Handle)
    EndProcedure
    
    Procedure GadgetPB(Handle)
      ProcedureReturn CocoaMessage(0, Handle, "tag")
    EndProcedure
    
CompilerEndSelect

; ****
  
Global wnd,ctrl
wnd=OpenWindow(#PB_Any,0,0,400,300,"Window",#PB_Window_ScreenCentered)
ctrl=TextGadget(#PB_Any,0,0,400,300,"")

;Debug DumpObjectMethods(WindowID(wnd), 1)

Debug "Window:"
Debug "wnd = " + wnd
Debug "PB_ID = " + WindowPB(WindowID(wnd))

Debug "Gadget:"
Debug "ctrl = " + ctrl
Debug "PB_ID = " + GadgetPB(GadgetID(ctrl))
Last edited by mk-soft on Fri Dec 10, 2021 3:07 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

Hello mk-soft,
thanks for sharing. This is an approach I've never seen before.

I tried my snippet with PB 5.73 x64 and got handles which are lower than MaxLong, so it worked.

Edit: It works, and I feel like I've seen this somewhere before. So I assume I can attach a number of properties to a agdget/window (and PB already does it)? I read the article about the API (https://docs.microsoft.com/en-us/window ... r-getpropa), but I can't conclude whether I'm free to use it for my own needs or not (like SetGadgetData).
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by mestnyi »

mk-soft wrote: Thu Dec 09, 2021 12:34 am Fixed for Linux ...

Code: Select all

;-TOP by mk-soft

CompilerSelect #PB_Compiler_OS
    
  CompilerCase #PB_OS_Windows
    Procedure WindowPB(Handle)
      ProcedureReturn GetProp_(Handle, "pb_windowid") - 1
    EndProcedure
    
    Procedure GadgetPB(Handle)
      ProcedureReturn GetProp_(Handle, "pb_id")
    EndProcedure
    
  CompilerCase #PB_OS_Linux
    
    Procedure WindowPB(Handle)
      ProcedureReturn g_object_get_data_(Handle, "pb_id" )
    EndProcedure
    
    Procedure GadgetPB(Handle)
      ProcedureReturn g_object_get_data_(Handle, "pb_id" ) - 1 
    EndProcedure
      
  CompilerCase #PB_OS_MacOS
    
    Import ""
      PB_Window_GetID(hWnd) 
    EndImport
    
    Procedure WindowPB(Handle)
      ProcedureReturn PB_Window_GetID(Handle)
    EndProcedure
    
    Procedure GadgetPB(Handle)
      ProcedureReturn CocoaMessage(0, Handle, "tag")
    EndProcedure
    
CompilerEndSelect

; ****
  
Global wnd,ctrl
wnd=OpenWindow(#PB_Any,0,0,400,300,"Window",#PB_Window_ScreenCentered)
ctrl=TextGadget(#PB_Any,0,0,400,300,"")

;Debug DumpObjectMethods(WindowID(wnd), 1)

Debug "Window:"
Debug "wnd = " + wnd
Debug "PB_ID = " + WindowPB(WindowID(wnd))

Debug "Gadget:"
Debug "ctrl = " + ctrl
Debug "PB_ID = " + GadgetPB(GadgetID(ctrl))
It works great on my MacBook, where did you get it? I've searched a lot for something like this.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by mk-soft »

Have a look at the 'SDK' of Purebasic from time to time and there are also some good tips in the forum.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GetDlgCtrlID_ behaves strange (or not?)

Post by jacdelad »

SDK?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply