Includefile for creating real Gadgets in PB

Share your advanced PureBasic knowledge/code with the community.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update:
you can create Gadget in Unicode and/or Threadsafe-mode !

Scintilla-Example Updated
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Just a small note, i've noticed radgrid doesn't sort #TYPE_USER columns..
Bug or feature?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Num3 wrote:Just a small note, i've noticed radgrid doesn't sort #TYPE_USER columns..
Bug or feature?
It's only an example, isn't complete!
You can enhanced it. When you post the code here, i will
include it :wink:

Only scintilla and the simple controls a complete, i hope
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Resources for RaEdit and RaGrid as *.res added. So no problems with Path in RC-Skript
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks for a great lib ts-soft. :D

A question though:

If you create a new gadget and supply a pointer to a PB_GadgetVT structure, but only implement a few of the functions; what happens regarding the ones I did not define?

For example, suppose I only implement a FreeGadget() procedure, and leave all remaining pointers within the PB_GadgetVT structure null, does that mean that all the remaining functions, such as ResizeGadget(), will not function, or do they default to some pre-defined procedure?

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

All Gadget become some standard-actions from PB. FreeGadget, ResizeGadget, SetGadgetText an so on, working without any line of code, but you can overwrite this.

This is a feature bei PureBASIC, not by hallodri and me :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Great, that's what I was hoping.

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

for problems with RaGrid example read this: http://www.purebasic.fr/english/viewtop ... &start=105

This project is published in pbosl as PBOSL_CreateGadget lib
The version in pbosl has some bugfixes and support unicode.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Which field of the structure PB_GadgetVT must i use for using AddGadgetItem with a new gadget ?

???AddGadgetItem2.l???
???AddGadgetItem3.l???
???AddGadgetColumn???
??? an other ???

Code: Select all

Structure PB_GadgetVT
  GadgetType.l   
  SizeOf.l       
  GadgetCallback.l
  FreeGadget.l
  GetGadgetState.l
  SetGadgetState.l
  GetGadgetText.l
  SetGadgetText.l
  AddGadgetItem2.l
  AddGadgetItem3.l
  RemoveGadgetItem.l
  ClearGadgetItemList.l
  ResizeGadget.l
  CountGadgetItems.l
  GetGadgetItemState.l
  SetGadgetItemState.l
  GetGadgetItemText.l
  SetGadgetItemText.l
  OpenGadgetList2.l
  GadgetX.l
  GadgetY.l
  GadgetWidth.l
  GadgetHeight.l
  HideGadget.l
  AddGadgetColumn.l
  RemoveGadgetColumn.l
  GetGadgetAttribute.l
  SetGadgetAttribute.l
  GetGadgetItemAttribute2.l
  SetGadgetItemAttribute2.l
  SetGadgetColor.l
  GetGadgetColor.l
  SetGadgetItemColor2.l
  GetGadgetItemColor2.l
  SetGadgetItemData.l
  GetGadgetItemData.l
EndStructure 
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

See the PureBasic.chm: How many optional parameters are used?

Code: Select all

Result = AddGadgetItem(#Gadget, Position, Text$ [, ImageID [, Flags]])
Using all = AddGadgetItem3
Using without Flags = AddGadgetItem2
and so on
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

Post by drahneir »

Hello,

I have a group of OptionGadgets made with CreateGadgets. When I try to check an option with SetGadgetState(Gadget, 1) it doesn't work. Only when I use SendMessage_(hWndGadget, #BM_SETCHECK, 1, 0) the option is checked.
Has anyone else made the same experience?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

@drahneir

Code: Select all

Procedure MyGadgetState(Gadget, State)
  ProcedureReturn SendMessage_(Gadget, #BM_SETCHECK, 1, 0)
EndProcedure

Procedure MyGadget(...)
  Protected vt.PB_GadgetVT
  vt\SetGadgetState = @MyGadgetState()
  CreateGadget(..., @vt)
EndProcedure
Not testet

Regards
Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Hi ts-soft, a small question :

I do a gadget and use AddGadgetItem
So for AddGadgetItem2, i use this code :

Code: Select all

Procedure OB_AddGadgetItem2	(*gadget.PB_Gadget, Position, Texte.s)
  ProcedureReturn OB_AddGadgetItem3(*gadget, Position, Texte.s, -1, -1)
EndProcedure
but when i use this code :

Code: Select all

AddGadgetItem(10, 02, "Truc5")
AddGadgetItem(10, 00, "Truc00", 0, 0)
For the first addGadgetItem, i have ImageID = 0 and Flags = 0
For the second addGadgetItem, i have ImageID = 0 and Flags = 0

But if i understand, i would have to receive theses results :
For the first addGadgetItem, i have ImageID = -1 and Flags = -1
For the second addGadgetItem, i have ImageID = 0 and Flags = 0

What is my problem ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Please see in the PB SDK and in the examples, the comes with this lib.
Please, use the actuell version from PBOSL, this version is outdated and no
more supported.

I can't see a bug, should work, i think the bug isn't in the posted code
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

For infos, i use the PBOSL version ! (Good job :))

With ths structure :

Code: Select all

Structure PB_GadgetVT
  GadgetType.l
  SizeOf.l
  GadgetCallback.l
  FreeGadget.l
  GetGadgetState.l
  SetGadgetState.l
  GetGadgetText.l
  SetGadgetText.l
  AddGadgetItem2.l
  AddGadgetItem3.l
  RemoveGadgetItem.l
  ClearGadgetItemList.l
  ResizeGadget.l
  CountGadgetItems.l
  GetGadgetItemState.l
  SetGadgetItemState.l
  GetGadgetItemText.l
  SetGadgetItemText.l
  OpenGadgetList2.l
  GadgetX.l
  GadgetY.l
  GadgetWidth.l
  GadgetHeight.l
  HideGadget.l
  AddGadgetColumn.l
  RemoveGadgetColumn.l
  GetGadgetAttribute.l
  SetGadgetAttribute.l
  GetGadgetItemAttribute2.l
  SetGadgetItemAttribute2.l
  SetGadgetColor.l
  GetGadgetColor.l
  SetGadgetItemColor2.l
  GetGadgetItemColor2.l
  SetGadgetItemData.l
  GetGadgetItemData.l
EndStructure
AddGadgetItem2.l => When no flags
AddGadgetItem3.l => When all flags !

So it's why i ask me if i understand all !
Post Reply