Help on what to do AFTER Visual Designer
Re: Help on what to do AFTER Visual Designer
These issues with PureArea are common, but easy to fix. The most common edits I have found with old code are:
A warning from using a depreciated command: CreateGadgetList(). Fix: Simply delete it.
Changed: CountList() to ListSize() (and a few other simple commands like this)
Somewhere along the line, the order of some gadget commands was changed.
When you encounter an error or warning with old code, put the cursor on the offending command and hit f1; usually the edits are obvious. You can also look at the History in the help file for the error command, and it will tell you what was changed.
A warning from using a depreciated command: CreateGadgetList(). Fix: Simply delete it.
Changed: CountList() to ListSize() (and a few other simple commands like this)
Somewhere along the line, the order of some gadget commands was changed.
When you encounter an error or warning with old code, put the cursor on the offending command and hit f1; usually the edits are obvious. You can also look at the History in the help file for the error command, and it will tell you what was changed.
Re: Help on what to do AFTER Visual Designer
I found the examples above....RobKiwi wrote:Many, many thanks TI-994A. I just can't keep away from it so:
1) The examples I found and was unable to run were at http://www.purearea.net/pb/english/index.htm then "Input & Output".
Rob
Quite a few things have changed since then.
Here's example 1...
Code: Select all
;Declare constants
#MyStringGadget = 1
#MyButton = 2
If OpenWindow(0,100,150,450,200,"Test",#PB_Window_SystemMenu) ;<<< "Test" string is now before the Windows Flags
; CreateGadgetList(WindowID()) ;<<< CreateGadgetList() is now automatically done in OpenWindow()
StringGadget(#MyStringGadget,50,50,350,20,"")
ButtonGadget(#MyButton,200,100,50,25,"Test")
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget ;<<< PureBasic Constants were re-adjusted for clarity and consistency
Select EventGadget()
Case #MyButton
MessageRequester("button clicked","hello world",0)
SetGadgetText(#MyStringGadget,"clicked!!")
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow ;<<< PureBasic Constants were re-adjusted for clarity and consistency
EndIf
End
;<<<< Use the Help File 'History' Tab
;<<<< and look for the 'Structure Viewer' on the PureBasic Tools menu
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
-
- User
- Posts: 19
- Joined: Tue Oct 23, 2012 5:47 am
- Location: Rawene, Hokianga, New Zealand
- Contact:
Re: Help on what to do AFTER Visual Designer
Very briefly: hooray! The image viewer works! Ka pai!
I am most grateful. I think I am over the hump now. But I look forward to more of the updates examples I mentioned.
NB: a useful bit of housework for some glutton for punishment with nothing else to do: go looking for examples and tutorials which are out of date and let the website owners know... examples which don't work will not encourage people to adopt Pure Basic.
Robin
I am most grateful. I think I am over the hump now. But I look forward to more of the updates examples I mentioned.
NB: a useful bit of housework for some glutton for punishment with nothing else to do: go looking for examples and tutorials which are out of date and let the website owners know... examples which don't work will not encourage people to adopt Pure Basic.
Robin
It's good to travel hopefully, but nice to arrive sometimes
Re: Help on what to do AFTER Visual Designer
Hello Robin. Being a new user to PureBasic myself, I agree with you. But still, these guys have taken a lot of trouble to create, post, and maintain those examples all these years, at their own expense no less. Think of them as a good source to test our later familiarity with PureBasic. For now, it'd be better if you referred to the examples in the PureBasic help documentation.RobKiwi wrote:...examples which don't work will not encourage people to adopt Pure Basic.
Press F1 from the PureBasic IDE to launch the Help, then select the CONTENTS tab from the left panel; from there, click on REFERENCE MANUAL. You will then be able to see a listing of the GENERAL LIBRARIES on the right. Each index entry in this section comes with updated and detailed easy-to-follow working examples for their corresponding functions. Personally, I believe that they're a great start to coding in PureBasic. Here are some of the web links, but the same are available in the help documentation:
- Gadgets
- File System
- Database
- Images
- Printers
- Requesters
...and many, many more. Good Luck!
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- User
- Posts: 19
- Joined: Tue Oct 23, 2012 5:47 am
- Location: Rawene, Hokianga, New Zealand
- Contact:
Re: Help on what to do AFTER Visual Designer
I am now getting quite well with coding and some things are working well. I've now got the paid-for version of PB.
But I have some difficulty in understanding just what is going on when loading an image into an existing imagebox or imagebutton, created with PureVision, which I tried and liked.
The following lines work but I don't know why:
If LoadImage(0, picture.jpg) ; this does return an image
SetGadgetState(1, ImageID(0))
EndIf
That is for an image box at the top of the enumeration list , #1. But why is the SetGadgetState needed? It doesn't work without it. I have looked at all the help files I can, downloaded and printed the book, but all the examples deal with MAKING the image box, not using an existing one. I do not understand what the "0", "1" and again "0" refer to.
Even worse with imagebuttons. I can't make them work at all. I have 6 of them to be loaded from an array so simplifying the code a bit
For N = 0 to 5
If LoadImage(N+3,picarray(N))
SetGadgetState(N+3, 0)
EndIf
Next
You will see that I am floundering badly. (3 is the enumeration number of the first button hence N+3)
Any help will be much appreciated!
Robin
But I have some difficulty in understanding just what is going on when loading an image into an existing imagebox or imagebutton, created with PureVision, which I tried and liked.
The following lines work but I don't know why:
If LoadImage(0, picture.jpg) ; this does return an image
SetGadgetState(1, ImageID(0))
EndIf
That is for an image box at the top of the enumeration list , #1. But why is the SetGadgetState needed? It doesn't work without it. I have looked at all the help files I can, downloaded and printed the book, but all the examples deal with MAKING the image box, not using an existing one. I do not understand what the "0", "1" and again "0" refer to.
Even worse with imagebuttons. I can't make them work at all. I have 6 of them to be loaded from an array so simplifying the code a bit
For N = 0 to 5
If LoadImage(N+3,picarray(N))
SetGadgetState(N+3, 0)
EndIf
Next
You will see that I am floundering badly. (3 is the enumeration number of the first button hence N+3)
Any help will be much appreciated!
Robin
It's good to travel hopefully, but nice to arrive sometimes
Re: Help on what to do AFTER Visual Designer
LoadImage() just loads the image into memory. In this case, it loads the image into the slot 0.RobKiwi wrote:The following lines work but I don't know why:
That is for an image box at the top of the enumeration list , #1. But why is the SetGadgetState needed? It doesn't work without it.Code: Select all
If LoadImage(0, "picture.jpg") ; this does return an image SetGadgetState(1, ImageID(0)) EndIf
The image is now in memory, but it is "standalone". It is not assigned to some gadget or something.
SetGadgetState() for ImageGadgets sets a new image.
In your code, SetGadgetState() sets the image for gadget 1, and it uses the ImageId() of the image in slot 0.
SetGadgetState() for ButtonImageGadget() does not set the image. It sets the toggle state of the button.RobKiwi wrote:Even worse with imagebuttons. I can't make them work at all. I have 6 of them to be loaded from an array so simplifying the code a bit
You will see that I am floundering badly. (3 is the enumeration number of the first button hence N+3)Code: Select all
For N = 0 to 5 If LoadImage(N+3,picarray(N)) SetGadgetState(N+3, 0) EndIf Next
Any help will be much appreciated!
If you look in the help for ButtonImageGadget(), you see:
Code: Select all
- SetGadgetAttribute() with the following values:
#PB_Button_Image : Set the displayed image.
#PB_Button_PressedImage: Set the image displayed when the button is pressed.
So it should look like this for the ButtonImageGadget's:
Code: Select all
For N = 0 to 5
If LoadImage(N+3,picarray(N))
SetGadgetAttribute(N+3, #PB_Button_Image, ImageId(N+3))
EndIf
Next
Re: Help on what to do AFTER Visual Designer
Hello Robin. Congratulations on your purchase of PureBasic, and great to hear that you're getting on well with it.
The sixth parameter of the ImageGadget() function should contain the ImageID() of the picture to be displayed. Since no picture was selected in the above line, the following code uses the SetGadgetState() function to place a picture into the ImageGadget():However, this approach of using SetGadgetState() to change the picture will only work with ImageGadget(). For ButtonImageGadget() you'd have to use the SetGadgetAttribute() function with the #PB_Button_Image flag. Any one of these formats is valid:
An image "c:\picture1.bmp" is loaded and assigned the number 123, and used in two gadgets:
Two images "c:\picture1.bmp" & "C:\picture2.bmp" are loaded and assigned the numbers 123 & 456 respectively, and used interchangeably between two gadgets:
The image "c:\apicture.bmp" is loaded directly into the ImageGadget() by using the #PB_Any constant:
As far as the numbers are concerned, they are referring to gadget and image numbers. PureBasic uses a numbering system to handle the windows, gadgets and other resources. So, in this example of yours:the function LoadImage() loads picture.jpg into memory and assigns it the resource number 0. Then, the SetGadgetState() function places this newly loaded resource into a previously created gadget number 1, which is the ImageGadget(). But, as you can see, the resource has to be passed to the gadget using its ID, so it is passed as ImageID(0). The same system and syntax is adopted throughout PureBasic, with every created gadget and resource assigned a unique number, and used in conjunction with their corresponding functions, WindowID(), GadgetID(), FontID(), etc. (you can assign same numbers to different resources, which means that you can, for example, have a window, a gadget, and an image all with the number 0)
I hope it answers your questions.
I can't really comment on PureVision simply because I haven't personally used it, but I'm assuming that you'd find something similar to the following line in your code, where the code for the ImageGadget() was generated with a null value for the picture:RobKiwi wrote:The following lines work but I don't know why:That is for an image box at the top of the enumeration list , #1. But why is the SetGadgetState needed? It doesn't work without it.Code: Select all
If LoadImage(0, picture.jpg) ; this does return an image SetGadgetState(1, ImageID(0)) EndIf
Code: Select all
ImageGadget(1, 10, 10, 50, 50, 0) ;<-- zero value sets no picture!
Code: Select all
If LoadImage(0, "picture.jpg") ;<-- loads picture.jpg and assigns it the number 0
SetGadgetState(1, ImageID(0)) ;<-- places image number 0 (which is picture.jpg) into gadget number 1
EndIf
An image "c:\picture1.bmp" is loaded and assigned the number 123, and used in two gadgets:
Code: Select all
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 200, 200, "Load Image:", wFlags)
LoadImage(123, "c:\picture1.bmp")
ImageGadget(1, 10, 70, 50, 50, ImageID(123))
ButtonImageGadget(2, 10, 10, 50, 50, ImageID(123))
EndIf
While WaitWindowEvent() ! #PB_Event_CloseWindow : CloseWindow : Wend
Code: Select all
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 200, 200, "Load Image:", wFlags)
LoadImage(123, "c:\picture1.bmp")
LoadImage(456, "c:\picture2.bmp")
ImageGadget(1, 10, 70, 50, 50, ImageID(123))
ButtonImageGadget(2, 10, 10, 50, 50, ImageID(456))
MessageRequester("Changing Gadget Images:", "Click OK to switch the pictures...")
SetGadgetState(1, ImageID(456))
SetGadgetAttribute(2, #PB_Button_Image, ImageID(123))
While WaitWindowEvent() ! #PB_Event_CloseWindow : CloseWindow : Wend
EndIf
Code: Select all
ImageGadget(1, 10, 70, 50, 50, ImageID(LoadImage(#PB_Any, "c:\picture1.bmp")))
Basically, even PureVision is making the image box, but the automation leads it to create an empty one first, then setting the picture using the SetGadgetState() function when one is selected. That way, if no picture is selected, the generated code will not raise any errors.RobKiwi wrote:...all the examples deal with MAKING the image box, not using an existing one. I do not understand what the "0", "1" and again "0" refer to...
As far as the numbers are concerned, they are referring to gadget and image numbers. PureBasic uses a numbering system to handle the windows, gadgets and other resources. So, in this example of yours:
Code: Select all
If LoadImage(0, picture.jpg) ;should be in quotes - "picture.jpg"
SetGadgetState(1, ImageID(0))
EndIf
I hope it answers your questions.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- User
- Posts: 19
- Joined: Tue Oct 23, 2012 5:47 am
- Location: Rawene, Hokianga, New Zealand
- Contact:
Re: Help on what to do AFTER Visual Designer
My sincere thanks to you, Danilo and TI, for explaining so clearly something that puzzled me, and which I do think could be made more clear in the literature. Most versions of Basic have something simple like " LoadImage (Control, "Picture.jpg") " and PureBasic's double-shuffle takes a time to understand.
Anyway I amended my procedure according to your advice and it was a good moment when all the small button pictures loaded as desired!
What I would do without this forum I don't know.

Anyway I amended my procedure according to your advice and it was a good moment when all the small button pictures loaded as desired!
What I would do without this forum I don't know.

It's good to travel hopefully, but nice to arrive sometimes
Re: Help on what to do AFTER Visual Designer
Hello again, Robin. It's always great when code falls into place and starts to work!RobKiwi wrote:...Most versions of Basic have something simple like " LoadImage (Control, "Picture.jpg") " and PureBasic's double-shuffle takes a time to understand...
In reference to your comment about loading images directly into controls, it is true that PureBasic takes a two-pronged approach, but as a result, once the image is loaded into memory, it can be reused and assigned to multiple controls, saving the time it takes to repeatedly reload it from disk. But still, if you prefer a direct load, the following method, as mentioned earlier, will accomplish the same result:
Code: Select all
ImageGadget(1, 10, 70, 50, 50, ImageID(LoadImage(#PB_Any, "c:\picture1.bmp")))
Happy coding!
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- User
- Posts: 19
- Joined: Tue Oct 23, 2012 5:47 am
- Location: Rawene, Hokianga, New Zealand
- Contact:
Re: Help on what to do AFTER Visual Designer
I've now got most of my program running, thanks to the help I have received, and will soon have to figure out some sort of an installation program. Any suggestions? Or is one necessary, considering that there are no dlls to bother with?
It's good to travel hopefully, but nice to arrive sometimes
Re: Help on what to do AFTER Visual Designer
Hello Robin. A question I too am grappling with. Back in my VB6 days, the built-in Package and Deployment utility did the job, but with PureBasic, you'd either have to handle the packaging and installation yourself, or opt for a third party utility.RobKiwi wrote:...will soon have to figure out some sort of an installation program. Any suggestions? Or is one necessary, considering that there are no dlls to bother with?
Even if you may have an independent standalone application that can be run from any location, an installer will copy your files to a Program Files folder, register your application with the Add/Remove Programs manager, register unique file associations (if any), create Start Menu folders, and Desktop and Quick Launch shortcuts, and also include an uninstaller to undo all these entries. All doable through code.
Alternatively, there are plenty of commercial and free installers available that can automate this process for you. The PureBasic team uses and recommends InnoSetup, while a homegrown option would be EasySetup, which is developed with PureBasic itself. And they're both free.
Ultimately, it's absolutely your choice whether or not to use an installer. If you feel that a simple, portable .EXE file is good enough, you can just do away with all these formalities. However, if you require a more professional approach for commercial software, then an installer would be the way to go.
Waimarie!
edit: corrected the link to the EasySetup website
Last edited by TI-994A on Thu Nov 15, 2012 3:32 am, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- User
- Posts: 19
- Joined: Tue Oct 23, 2012 5:47 am
- Location: Rawene, Hokianga, New Zealand
- Contact:
Re: Help on what to do AFTER Visual Designer
Thanks for that. As I have a number of .JPG files in directories to accompany the .EXE I will use one of the installation programs you suggest. Not quite time for that yet, though, but I like to know these things in advance!
It's good to travel hopefully, but nice to arrive sometimes
-
- User
- Posts: 19
- Joined: Tue Oct 23, 2012 5:47 am
- Location: Rawene, Hokianga, New Zealand
- Contact:
Re: Help on what to do AFTER Visual Designer
One small point: there was an error in the URL for EasySetup given, but I chased it to earth and it should be
http://www.thprogs.de/EasySetup/eng/
Robin
http://www.thprogs.de/EasySetup/eng/
Robin
It's good to travel hopefully, but nice to arrive sometimes
Re: Help on what to do AFTER Visual Designer
kia ora Rob
You could also try BytesSense Install maker
http://www.purebasic.fr/english/viewtop ... 27&t=30175
You could also try BytesSense Install maker
http://www.purebasic.fr/english/viewtop ... 27&t=30175
Windows 11, Manjaro, Raspberry Pi OS


Re: Help on what to do AFTER Visual Designer
Hi Robin, and sorry about that. I did actually track the proper URLs down for you, but there must have been an error while copying & pasting them in my reply. Thanks for pointing that out.RobKiwi wrote:...there was an error in the URL for EasySetup given...it should be http://www.thprogs.de/EasySetup/eng/
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
