[Done] Virtual list works in 6.21 but not int 6.30beta1

Post bugreports for the Windows version here
zikitrake
Addict
Addict
Posts: 876
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

[Done] Virtual list works in 6.21 but not int 6.30beta1

Post by zikitrake »

This code of a virtual listicon works fine in PB6.21 (C Backend), but it only shows an empty list in PB6.30Beta1.

Any help is greatly appreciated!

Image

Code: Select all

#ItemCount = 350000

#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13

Global Dim Item.s(#ItemCount)

Enumeration
  #window_0
  #ListIcon_0
EndEnumeration

Procedure WinCallback(hwnd, msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_NOTIFY
      *nmh.NMHDR = lParam
      Select *nmh\code
        Case #LVN_ODCACHEHINT
          result = 0
        Case #LVN_GETDISPINFO
          *nmlvd.NMLVDISPINFO = lParam
          If *nmlvd\item\mask & #LVIF_TEXT
            *nmlvd\item\pszText = @Item(*nmlvd\item\iItem)
          EndIf
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow(#Window_0, 380, 150, 771, 336, "Putting strings in and out of a ListIcon Gadget", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
SetWindowCallback(@WinCallback())
ListIconGadget(#ListIcon_0, 10, 10, 750, 250, "", 725, #LVS_OWNERDATA)

SendMessage_(GadgetID(#ListIcon_0), #LVM_SETITEMCOUNT, #ItemCount, #LVSICF_NOINVALIDATEALL)
For i=0 To #ItemCount-1
  Item(i) = Str(i) + " PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic" + #CRLF$
Next

Repeat
  event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
[/size]

Thank you in advance!
PB 6.21 beta, PureVision User
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Fred »

Putting #LVS_OWNERDATA as flags isn't officially supported, you could try to set it with SetWindowLongPtr_() instead
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by jacdelad »

Since this is the second report of this kind (using windows flags on gadget creation) there's maybe a chance to support this?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Fred »

It hard to do because we can't add custom flags anymore as all flags values are already used by OS values. May be it could be exceptions for flags which can't be set later by SetWindowLongPtr()
User avatar
spikey
Enthusiast
Enthusiast
Posts: 771
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by spikey »

Fred wrote: Thu Sep 04, 2025 1:28 pm It hard to do because we can't add custom flags anymore as all flags values are already used by OS values.
Please pardon me if I'm showing my ignorance but couldn't you have a second optional parameter for the gadget commands? Rename the existing one 'PBFlags', call the new one 'OSFlags' and pass through the contents directly to the underlying API calls without intervention on an 'at your own risk' basis. You'd need to be able to support '#PB_Ignore' as a parameter to 'PBFlags' in the event that no PB flags require setting.
User avatar
Piero
Addict
Addict
Posts: 948
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Piero »

spikey wrote: Thu Sep 04, 2025 2:22 pmPlease pardon me if I'm showing my ignorance but couldn't you have a second optional parameter for the gadget commands? Rename the existing one 'PBFlags', call the new one 'OSFlags' and pass through the contents directly to the underlying API calls without intervention on an 'at your own risk' basis. You'd need to be able to support '#PB_Ignore' as a parameter to 'PBFlags' in the event that no PB flags require setting.
Huh? I'm often worried to get misunderstood because of my horrible english, but I always get relieved when reading windoze stuff on this forum; it always beats me by far (this was mostly a test to see how AI translators work :P )
Last edited by Piero on Thu Sep 04, 2025 3:10 pm, edited 1 time in total.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 771
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by spikey »

Piero wrote: Thu Sep 04, 2025 2:53 pm Huh?
Assuming I've understood Fred correctly, there's a space issue in the bitmask for the flag values. There's only a maximum of 32-bits available (because it's a 32-bit Windows implementation feature migrated to the 64-bit environment). There's a competition for space between flags needed by PB for creation and by the OS.

By separating out the two values into different parameters, you reduce competition problems.
User avatar
Piero
Addict
Addict
Posts: 948
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Piero »

I will be """happy""" if win ppl, because of some update """problems""", will consider to try to make more "standard" PB code in the future...
More for them than for me :)

Edit/PS: Darn Apple; a Mac VM on Win is not very easy stuff… (would help PB bug reporting)
User avatar
NicTheQuick
Addict
Addict
Posts: 1523
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by NicTheQuick »

Since Purebasic can be compiled for Linux, Windows, and Mac, I would advise against designing commands in such a way that they allow OS-specific constants. This will only lead to code that is no longer cross-platform.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Little John »

NicTheQuick wrote: Thu Sep 04, 2025 3:48 pm Since Purebasic can be compiled for Linux, Windows, and Mac, I would advise against designing commands in such a way that they allow OS-specific constants. This will only lead to code that is no longer cross-platform.
+ 1
User avatar
Piero
Addict
Addict
Posts: 948
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Piero »

To be sincere, I feel a bit sad/guilty, because I posted """great stuff""" that was (at least easily) only possible on Mac (like fuzzy autocomplete).
I SOOO hoped some win guru could EASILY replicate my sh*t… :oops: :oops: :oops:
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by jacdelad »

NicTheQuick wrote: Thu Sep 04, 2025 3:48 pm Since Purebasic can be compiled for Linux, Windows, and Mac, I would advise against designing commands in such a way that they allow OS-specific constants. This will only lead to code that is no longer cross-platform.
There are some windows specific flags which can't be set afterwards with SetWindowLongPtr. It would be great to be able to use them without having to go through the usage of APIs (which is still an option, sure).
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
zikitrake
Addict
Addict
Posts: 876
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by zikitrake »

Oh my goodness, what a mess :lol:

Thanks, Fred and company... I tried using:

Code: Select all

SetWindowLongPtr_(GadgetID(#ListIcon_0),#GWL_STYLE,GetWindowLongPtr_(GadgetID(#ListIcon_0),#GWL_STYLE) | #LVS_OWNERDATA)
But I don't think I'm doing it right, because now it doesn't work in either PB6.21 or PB6.30beta1 :oops:

Code: Select all

#ItemCount = 350000

#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13

Global Dim Item.s(#ItemCount)

Enumeration
  #window_0
  #ListIcon_0
EndEnumeration

Procedure WinCallback(hwnd, msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_NOTIFY
      *nmh.NMHDR = lParam
      Select *nmh\code
        Case #LVN_ODCACHEHINT
          result = 0
        Case #LVN_GETDISPINFO
          *nmlvd.NMLVDISPINFO = lParam
          If *nmlvd\item\mask & #LVIF_TEXT
            *nmlvd\item\pszText = @Item(*nmlvd\item\iItem)
          EndIf
      EndSelect
  EndSelect
  
  ProcedureReturn result
EndProcedure

OpenWindow(#Window_0, 380, 150, 771, 336, "Putting strings in and out of a ListIcon Gadget", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
SetWindowCallback(@WinCallback())
ListIconGadget(#ListIcon_0, 10, 10, 750, 250, "", 725)

SendMessage_(GadgetID(#ListIcon_0), #LVM_SETITEMCOUNT, #ItemCount, #LVSICF_NOINVALIDATEALL)

SetWindowLongPtr_(GadgetID(#ListIcon_0),#GWL_STYLE,GetWindowLongPtr_(GadgetID(#ListIcon_0),#GWL_STYLE) | #LVS_OWNERDATA)

For i=0 To #ItemCount-1
  Item(i) = Str(i) + " PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic PureBasic" + #CRLF$
Next

Repeat
  event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
PB 6.21 beta, PureVision User
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Virtual list works in 6.21 but not int 6.30beta1

Post by Fred »

According to MSDN, you can't set after creation. I will revert these changes for next beta.
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Done] Virtual list works in 6.21 but not int 6.30beta1

Post by Fred »

Fixed.
Post Reply