Page 1 of 1

Enumeration Name for #PB_Web_....

Posted: Sat Dec 10, 2022 10:41 am
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?

Re: Enumeration Name for #PB_Web_....

Posted: Sat Dec 10, 2022 12:50 pm
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.

Re: Enumeration Name for #PB_Web_....

Posted: Sat Dec 10, 2022 7:55 pm
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

Re: Enumeration Name for #PB_Web_....

Posted: Sat Dec 10, 2022 9:15 pm
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

Re: Enumeration Name for #PB_Web_....

Posted: Mon Dec 12, 2022 2:14 am
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.

Re: Enumeration Name for #PB_Web_....

Posted: Mon Dec 12, 2022 9:55 am
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.

Re: Enumeration Name for #PB_Web_....

Posted: Mon Dec 12, 2022 10:09 am
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.

Re: Enumeration Name for #PB_Web_....

Posted: Mon Dec 12, 2022 12:24 pm
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?

Re: Enumeration Name for #PB_Web_....

Posted: Mon Dec 12, 2022 4:23 pm
by infratec
I can implement new stuff for:

Code: Select all

SetGadgetItemText()
GetGadgetItemText()
SetGadgetAttribute()
I will take look at Gadget.h and GadgetCommon.h

Re: Enumeration Name for #PB_Web_....

Posted: Mon Dec 12, 2022 6:41 pm
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