Enumeration Name for #PB_Web_....

Just starting out? Need help? Post your questions and find answers here.
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Enumeration Name for #PB_Web_....

Post by infratec »

Maybe this is a question for Fred:

I want to implement additional features to a WebView2 Gadget.
For that I need additional constants, but I don't want to run into conflicts with already available values.

I tried somenting like:

Code: Select all

Enumeration PB_Web
  #WebView2_SystemMenue
EndEnumeration
Of course it does not work, because I don't know if there is an enumeration for all the #PB_Web_ constants
and PB_Web (my guess) does not do what it should.

But I also don't want to use values > 1000, because of unneeded size of PB internal arrays.

Any hint?
Last edited by infratec on Sat Dec 10, 2022 9:12 pm, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 6253
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Enumeration Name for #PB_Web_....

Post by mk-soft »

Arrays only exist when objects are created. Gadgets, images, etc. Not for constants for events, status, attributes.

For Eventtype there is the constant #PB_EventType_FirstCustomValue (start value 262144).
For flags, this is also not a problem, as WebGadet does not have any.
For Event (WaitWindowEvent) we have to agree somehow. (#PB_Event_FirstCustomValue)
All other constant values are also assigned to Purebasic several times depending on the use and are not always in sequence.
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
wayne-c
Enthusiast
Enthusiast
Posts: 337
Joined: Tue Jun 08, 2004 10:29 am
Location: Zurich, Switzerland

Re: Enumeration Name for #PB_Web_....

Post by wayne-c »

infratec wrote: Sat Dec 10, 2022 10:41 am I want to implement additional features to a WebView2 Gadget.
Yes please :D
As you walk on by, Will you call my name? Or will you walk away?
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Enumeration Name for #PB_Web_....

Post by infratec »

I don't want to add new EventTypes.
I need more constants like:

Code: Select all

#PB_Web_HtmlCode
#PB_Web_PageTitle
#PB_Web_StatusMessage
#PB_Web_SelectedText
I already start a WebView2Gadget based on Justins PBWebView2
viewtopic.php?p=592281#p592281
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Enumeration Name for #PB_Web_....

Post by netmaestro »

Do it like this:

Code: Select all

CompilerIf Defined(PB_Event_CloseWindow, #PB_Constant) = 0
  #PB_Event_CloseWindow = 13116
CompilerEndIf
Of course, that one is already defined so nothing will happen but if it is not, you've just defined it. Note the no hashtag for PB_Event_CloseWindow. This approach allows you to define constants which may or may not already be defined - without clashing with anything.
BERESHEIT
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Enumeration Name for #PB_Web_....

Post by infratec »

Hi netmaestro,

yes, this avoids trouble with double definions, but ... it solves the problem only by half.
I want to know the first free number which I can use.
I can start with 10000, but then the internal array is also 10000 entries in size.

The optimal case is, if I could extend the #PB_Web... enumeration in some way.

Ok, I can check all #PB_Web... constants and use the next higher value, but that's not safe for next PB versions.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Enumeration Name for #PB_Web_....

Post by netmaestro »

Did you consider #PB_Event_NextCustomValue? I know these aren't events but these are free safe numbers. You can use them for anything.
BERESHEIT
User avatar
mk-soft
Always Here
Always Here
Posts: 6253
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Enumeration Name for #PB_Web_....

Post by mk-soft »

How do you know that the constants are an array?
See Purebasic SDK Gadget.h and GadgetCommon.h.

For which function do you want the new constants? Get/SetGadgetAttribute?
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
infratec
Always Here
Always Here
Posts: 7622
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Enumeration Name for #PB_Web_....

Post by infratec »

I can implement new stuff for:

Code: Select all

SetGadgetItemText()
GetGadgetItemText()
SetGadgetAttribute()
I will take look at Gadget.h and GadgetCommon.h
User avatar
mk-soft
Always Here
Always Here
Posts: 6253
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Enumeration Name for #PB_Web_....

Post by mk-soft »

If you want to assign or redirect your own standard functions to the GadgetVT, you must look at how strings are used.
To do this, look at SDK -> VisualC -> SimpleLibray -> StringMultiply.c.

I have worked with this before (2014)

See Get/SetGadgetText Link: viewtopic.php?t=59057
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
Post Reply