RC / RES support?
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Stan.
programming ... ( I am stuck on a program with around 100 gadgets ).
Stan
Since I attended an MS course, my programs no longer have bugs ... just hidden "features" !! [ PB. registered user ]
I do support that proposal, ATM I spend more time designing gadgets thanIt will be easier if PB can link RC into the exe and call from it.
And there're many Resource Editors available today.
It's a pain to "magine" a gadget posistion.
Well, everyone needs to do something for living.
programming ... ( I am stuck on a program with around 100 gadgets ).
Stan
Since I attended an MS course, my programs no longer have bugs ... just hidden "features" !! [ PB. registered user ]
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> It's a pain to "magine" a gadget posistion.
If you have Visual Basic, or don't mind installing the 7 MB free version, then
you can design your gadgets with that, and then convert the form to PureBasic
code using "vis2pure": http://www.bowlay.com/vis2pure.htm
PB - Registered PureBasic Coder
Edited by - PB on 29 April 2002 12:28:10
> It's a pain to "magine" a gadget posistion.
If you have Visual Basic, or don't mind installing the 7 MB free version, then
you can design your gadgets with that, and then convert the form to PureBasic
code using "vis2pure": http://www.bowlay.com/vis2pure.htm
PB - Registered PureBasic Coder
Edited by - PB on 29 April 2002 12:28:10
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
Hi,
I used an INI file to describe my Gadget positions. I know its not a resource editor, but it's easier and more flexible than hard coding everything.
I abandoned the code (my 2nd PB project) 'cos I couldnt work out the Comms side but still, it was a good *familiarisation excercise*
I'll email the source if you want to see it (you'll enjoy laughing at my crappy code at least)...
Hi,
I used an INI file to describe my Gadget positions. I know its not a resource editor, but it's easier and more flexible than hard coding everything.
I abandoned the code (my 2nd PB project) 'cos I couldnt work out the Comms side but still, it was a good *familiarisation excercise*
I'll email the source if you want to see it (you'll enjoy laughing at my crappy code at least)...
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
Oops! seem to have deleted my INI file that describes the GUI.
The "Debug" caused a Message Requester to pop up showing the objects GID/X/Y... properties to be displayed. I'll try and rebuild it all...
It looked a bit like this, though:
[Main]
ObjectGroups=4
Debug=on
[ObjectGroup1]
Items=3
ItemType1=TextBox
ItemGID1=100
ItemValue1=
ItemXpos1=20
ItemYpos1=50
ItemWidth1=100
ItemHeight1=20
ItemType2=Text
ItemGID2=101
ItemValue2=Hello World
ItemXpos2=60
ItemYpos2=80
ItemWidth2=100
ItemHeight2=20
ItemType3=Button
ItemGID2=102
ItemValue2=Hello Again World
ItemXpos2=90
ItemYpos2=120
ItemWidth2=100
ItemHeight2=20
[ObjectGroup2]
ItemType1=....
Oops! seem to have deleted my INI file that describes the GUI.
The "Debug" caused a Message Requester to pop up showing the objects GID/X/Y... properties to be displayed. I'll try and rebuild it all...
It looked a bit like this, though:
[Main]
ObjectGroups=4
Debug=on
[ObjectGroup1]
Items=3
ItemType1=TextBox
ItemGID1=100
ItemValue1=
ItemXpos1=20
ItemYpos1=50
ItemWidth1=100
ItemHeight1=20
ItemType2=Text
ItemGID2=101
ItemValue2=Hello World
ItemXpos2=60
ItemYpos2=80
ItemWidth2=100
ItemHeight2=20
ItemType3=Button
ItemGID2=102
ItemValue2=Hello Again World
ItemXpos2=90
ItemYpos2=120
ItemWidth2=100
ItemHeight2=20
[ObjectGroup2]
ItemType1=....
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
================================================================================
Procedure BuildGUI(guifile$,objectlist$,windowid)
;
; - Nigel Wale (naw) - Registered PB User ([url]mailto:nigel.wale@ntlworld.com[/url] / [url]mailto:walen@hursley.ibm.com[/url])
;
; - There's probably a better way to do this
;
; You should "include" this PB Procedure in your main source
;
;
;
#DefaultObjectType$="TextBox"
INIFilename(guifile$)
INISection("Main")
MainIniDebug=ReadINIValue("Debug",0)
MainIniObjectLists=ReadINIValue("ObjectLists",1)
MainFontHeight=ReadINIValue("FontHeight",10)
MainFont$=ReadINIString("Font","arial")
MainXMultiplier=ReadINIValue("XMultiplier",10)
MainYMultiplier=ReadINIValue("YMultiplier",16)
INISection(objectlist$)
ObjectDebug=ReadINIValue("Debug", MainIniDebug)
Objects=ReadINIValue("Objects",1)
;MessageRequester("DBG",MainFont$,0)
ObjectCtr=1
Repeat
ObjectAll$=ReadINIString("Object"+Str(ObjectCtr),"-")
ObjectType$=ReadINIString("ObjectType"+Str(ObjectCtr),#DefaultObjectType$)
ObjectXpos=ReadINIValue("ObjectXpos"+Str(ObjectCtr),1)*MainXMultiplier-MainXMultiplier
ObjectYpos=ReadINIValue("ObjectYpos"+Str(ObjectCtr),1)*MainYMultiplier
ObjectWidth=ReadINIValue("ObjectWidth"+Str(ObjectCtr),1)*MainXMultiplier
ObjectHeight=ReadINIValue("ObjectHeight"+Str(ObjectCtr),1)*MainYMultiplier-2
ObjectValue$=ReadINIString("ObjectValue"+Str(ObjectCtr),"")
ObjectFlags$=ReadINIString("ObjectFlags"+Str(ObjectCtr),"0")
ObjectGID=ReadINIValue("ObjectGID"+Str(ObjectCtr),1)
Select ObjectType$
Case "String" : StringGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "Text" : TextGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "CheckBox" : CheckBoxGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "Button" : ButtonGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "Frame3d" : Frame3DGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$,Val(ObjectFlags$))
;
; The list goes on (and on and on....)
;
EndSelect
ObjectCtr=ObjectCtr+1
Until ObjectCtr=Objects+1
EndProcedure
;
; Here's a minimalistic Main Section
;
;
;
InitGadget(30)
OpenWindow(WINDOWID, 100, 100, 600, 600, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget, "GUI INI")
CreateGadgetList(WindowID())
buildgui("C:\Program Files\PureBasic\WIP\GUIINI\GUI.ini","ObjectList1",WINDOWID)
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Default : MessageRequester("FYI","Menu Item "+Str(EventMenuID())+" Not Implemented",0)
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case 100 :
Default : MessageRequester("FYI","Button "+Str(EventGadgetID())+" Not Implemented",0)
EndSelect
Case #WM_CLOSE : QUIT=MessageRequester("Confirm","Really Quit",1)
Case #PB_EventCloseWindow : QUIT=MessageRequester("Confirm","Really, Really Quit",1)
EndSelect
Until QUIT=1
End
Ok - here's the code (note that the path to the "GUI.ini" file is hardcoded - you'll have to change that)> I used an INI file to describe my Gadget positions.
Interesting... would you mind posting an example here for all to see?
PB - Registered PureBasic Coder
================================================================================
Procedure BuildGUI(guifile$,objectlist$,windowid)
;
; - Nigel Wale (naw) - Registered PB User ([url]mailto:nigel.wale@ntlworld.com[/url] / [url]mailto:walen@hursley.ibm.com[/url])
;
; - There's probably a better way to do this
;
; You should "include" this PB Procedure in your main source
;
;
;
#DefaultObjectType$="TextBox"
INIFilename(guifile$)
INISection("Main")
MainIniDebug=ReadINIValue("Debug",0)
MainIniObjectLists=ReadINIValue("ObjectLists",1)
MainFontHeight=ReadINIValue("FontHeight",10)
MainFont$=ReadINIString("Font","arial")
MainXMultiplier=ReadINIValue("XMultiplier",10)
MainYMultiplier=ReadINIValue("YMultiplier",16)
INISection(objectlist$)
ObjectDebug=ReadINIValue("Debug", MainIniDebug)
Objects=ReadINIValue("Objects",1)
;MessageRequester("DBG",MainFont$,0)
ObjectCtr=1
Repeat
ObjectAll$=ReadINIString("Object"+Str(ObjectCtr),"-")
ObjectType$=ReadINIString("ObjectType"+Str(ObjectCtr),#DefaultObjectType$)
ObjectXpos=ReadINIValue("ObjectXpos"+Str(ObjectCtr),1)*MainXMultiplier-MainXMultiplier
ObjectYpos=ReadINIValue("ObjectYpos"+Str(ObjectCtr),1)*MainYMultiplier
ObjectWidth=ReadINIValue("ObjectWidth"+Str(ObjectCtr),1)*MainXMultiplier
ObjectHeight=ReadINIValue("ObjectHeight"+Str(ObjectCtr),1)*MainYMultiplier-2
ObjectValue$=ReadINIString("ObjectValue"+Str(ObjectCtr),"")
ObjectFlags$=ReadINIString("ObjectFlags"+Str(ObjectCtr),"0")
ObjectGID=ReadINIValue("ObjectGID"+Str(ObjectCtr),1)
Select ObjectType$
Case "String" : StringGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "Text" : TextGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "CheckBox" : CheckBoxGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "Button" : ButtonGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$)
Case "Frame3d" : Frame3DGadget(ObjectGID,ObjectXpos,ObjectYPos,ObjectWidth,ObjectHeight,ObjectValue$,Val(ObjectFlags$))
;
; The list goes on (and on and on....)
;
EndSelect
ObjectCtr=ObjectCtr+1
Until ObjectCtr=Objects+1
EndProcedure
;
; Here's a minimalistic Main Section
;
;
;
InitGadget(30)
OpenWindow(WINDOWID, 100, 100, 600, 600, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget, "GUI INI")
CreateGadgetList(WindowID())
buildgui("C:\Program Files\PureBasic\WIP\GUIINI\GUI.ini","ObjectList1",WINDOWID)
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Default : MessageRequester("FYI","Menu Item "+Str(EventMenuID())+" Not Implemented",0)
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case 100 :
Default : MessageRequester("FYI","Button "+Str(EventGadgetID())+" Not Implemented",0)
EndSelect
Case #WM_CLOSE : QUIT=MessageRequester("Confirm","Really Quit",1)
Case #PB_EventCloseWindow : QUIT=MessageRequester("Confirm","Really, Really Quit",1)
EndSelect
Until QUIT=1
End
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
And here's a copy of an INI file:
You'll need a copy of Mr Skunks INIfile libraries - there's a copy on the PB resource site - I think that this can all be achieved directly with Win API calls, though at little extra effort...
[Main]
ObjectLists=2
Debug=1
FontHeight=10
Font=arial
XMultiplier=10
YMultiplier=20
[ObjectList1]
Debug=1
Objects=10
ObjectType1=String
ObjectGID1=1
ObjectXpos1=1
ObjectYpos1=1
ObjectWidth1=25
ObjectHeight1=1
ObjectValue1=Can Set Default Text In a Text Box
ObjectType2=Text
ObjectGID2=2
ObjectXpos2=1
ObjectYpos2=2
ObjectWidth2=10
ObjectHeight2=1
ObjectValue2=And It All Lines Up Nicely
ObjectType3=Button
ObjectGID3=3
ObjectXpos3=2
ObjectYpos3=3
ObjectWidth3=10
ObjectHeight3=1
ObjectValue3=Press Me
ObjectType4=CheckBox
ObjectGID4=4
ObjectXpos4=2
ObjectYpos4=4
ObjectWidth4=10
ObjectHeight4=1
ObjectType5=Frame3d
ObjectGID5=5
ObjectXpos5=10
ObjectYpos5=5
ObjectWidth5=20
ObjectHeight5=10
ObjectValue5="Hello World"
ObjectFlags5=2
ObjectType6=Frame3d
ObjectGID6=6
ObjectXpos6=10
ObjectYpos6=15
ObjectWidth6=10
ObjectHeight6=10
ObjectValue6="Hello Mum"
ObjectFlags6=1
ObjectType7=Frame3d
ObjectGID7=7
ObjectXpos7=30
ObjectYpos7=15
ObjectWidth7=50
ObjectHeight7=20
ObjectValue7="Hello & Goodbye"
> I used an INI file to describe my Gadget positions.
Interesting... would you mind posting an example here for all to see?
PB - Registered PureBasic Coder
And here's a copy of an INI file:
You'll need a copy of Mr Skunks INIfile libraries - there's a copy on the PB resource site - I think that this can all be achieved directly with Win API calls, though at little extra effort...
[Main]
ObjectLists=2
Debug=1
FontHeight=10
Font=arial
XMultiplier=10
YMultiplier=20
[ObjectList1]
Debug=1
Objects=10
ObjectType1=String
ObjectGID1=1
ObjectXpos1=1
ObjectYpos1=1
ObjectWidth1=25
ObjectHeight1=1
ObjectValue1=Can Set Default Text In a Text Box
ObjectType2=Text
ObjectGID2=2
ObjectXpos2=1
ObjectYpos2=2
ObjectWidth2=10
ObjectHeight2=1
ObjectValue2=And It All Lines Up Nicely
ObjectType3=Button
ObjectGID3=3
ObjectXpos3=2
ObjectYpos3=3
ObjectWidth3=10
ObjectHeight3=1
ObjectValue3=Press Me
ObjectType4=CheckBox
ObjectGID4=4
ObjectXpos4=2
ObjectYpos4=4
ObjectWidth4=10
ObjectHeight4=1
ObjectType5=Frame3d
ObjectGID5=5
ObjectXpos5=10
ObjectYpos5=5
ObjectWidth5=20
ObjectHeight5=10
ObjectValue5="Hello World"
ObjectFlags5=2
ObjectType6=Frame3d
ObjectGID6=6
ObjectXpos6=10
ObjectYpos6=15
ObjectWidth6=10
ObjectHeight6=10
ObjectValue6="Hello Mum"
ObjectFlags6=1
ObjectType7=Frame3d
ObjectGID7=7
ObjectXpos7=30
ObjectYpos7=15
ObjectWidth7=50
ObjectHeight7=20
ObjectValue7="Hello & Goodbye"
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
If people like this approach, I'll finish it and extend it. I just use it as a quick and dirty way to build GUIs without having to pay too much attention to layout. I guess some more work on a *debug* mode would be nice
1 line / gadget format would be nice as an alternative - that shouldn't be too hard to do.
It's good for internationalisation / layout customisation.
ie: you can make significant layout changes without *damaging* your code
Ta - N
If people like this approach, I'll finish it and extend it. I just use it as a quick and dirty way to build GUIs without having to pay too much attention to layout. I guess some more work on a *debug* mode would be nice

1 line / gadget format would be nice as an alternative - that shouldn't be too hard to do.
It's good for internationalisation / layout customisation.
ie: you can make significant layout changes without *damaging* your code
Ta - N
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
I like this solution, but
So the best would be to crypt the ini file in 'your way' so nobody can change that.
Another point: what if the ini file is mistakenly deleted?
I would store hardcoded gadget positions as 'PLAN B'.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
I like this solution, but
everybody can do the changes (every 'BAD GUY' can alter your layout).ie: you can make significant layout changes without *damaging* your code
So the best would be to crypt the ini file in 'your way' so nobody can change that.
Another point: what if the ini file is mistakenly deleted?
I would store hardcoded gadget positions as 'PLAN B'.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
Has anyone out there already done this sort of thing / got a nice
algorithm. I've added a check on the file size, but thats easily circumvented.
I'm not too worried about the INI file getting mistakenly deleted. If the user knows how to delete, then he should also know how to reinstall
- Dont like plan B, then I have to maintain 2 sets of screen layouts & that would be horrible. The INI 2 GUI method is supposed to circumvent that sort of thing completely.
Oh sure - it's very open. It would be easy enough to do a checksum on the INI file and disable the program if it doesn't look right with an appropriate messageI like this solution, buteverybody can do the changes (every 'BAD GUY' can alter your layout).ie: you can make significant layout changes without *damaging* your code
So the best would be to crypt the ini file in 'your way' so nobody can change that.
Another point: what if the ini file is mistakenly deleted?
I would store hardcoded gadget positions as 'PLAN B'.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.

algorithm. I've added a check on the file size, but thats easily circumvented.
I'm not too worried about the INI file getting mistakenly deleted. If the user knows how to delete, then he should also know how to reinstall

- Dont like plan B, then I have to maintain 2 sets of screen layouts & that would be horrible. The INI 2 GUI method is supposed to circumvent that sort of thing completely.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Well if the user can look into an ascii file he should be able to change it...
That's why I said 'crypt' instead of 'check the file size' or 'checksum'.
You can use the build-in PureBasic compress/uncompress functions with a 'password'.
Power users alter INI files - that's a fact!
Argh, because 1 little ascii file is missing the user has to reinstall your app?
NOPE!
Plan B is only needed if the USER layout/ini-file is missing.
So you have always ONE set of screen layout at a time.
Plan B is actually your '1st time start' setting!
You need it anyway!
Why not use this settings to 'reset' your screen layout?
Anyway, just my 2c - you can do whatever you want
But have fun!
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
It would be easy enough to do a checksum on the INI file and disable the program if it doesn't look right with an appropriate messageHas anyone out there already done this sort of thing / got a nice algorithm. I've added a check on the file size, but thats easily circumvented.
Well if the user can look into an ascii file he should be able to change it...
That's why I said 'crypt' instead of 'check the file size' or 'checksum'.
You can use the build-in PureBasic compress/uncompress functions with a 'password'.
Power users alter INI files - that's a fact!
I'm not too worried about the INI file getting mistakenly deleted. If the user knows how to delete, then he should also know how to reinstall![]()
Argh, because 1 little ascii file is missing the user has to reinstall your app?
- Dont like plan B, then I have to maintain 2 sets of screen layouts & that would be horrible.
NOPE!
Plan B is only needed if the USER layout/ini-file is missing.
So you have always ONE set of screen layout at a time.
Plan B is actually your '1st time start' setting!
You need it anyway!
Why not use this settings to 'reset' your screen layout?
Anyway, just my 2c - you can do whatever you want
But have fun!
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by naw.
It would be easy enough to do a checksum on the INI file and disable the program if it doesn't look right with an appropriate messageHas anyone out there already done this sort of thing / got a nice algorithm. I've added a check on the file size, but thats easily circumvented.
Well if the user can look into an ascii file he should be able to change it...
That's why I said 'crypt' instead of 'check the file size' or 'checksum'.
You can use the build-in PureBasic compress/uncompress functions with a 'password'.
Power users alter INI files - that's a fact!
I'm not too worried about the INI file getting mistakenly deleted. If the user knows how to delete, then he should also know how to reinstall![]()
Argh, because 1 little ascii file is missing the user has to reinstall your app?
- Dont like plan B, then I have to maintain 2 sets of screen layouts & that would be horrible.
NOPE!
Plan B is only needed if the USER layout/ini-file is missing.
So you have always ONE set of screen layout at a time.
Plan B is actually your '1st time start' setting!
You need it anyway!
Why not use this settings to 'reset' your screen layout?
Anyway, just my 2c - you can do whatever you want
But have fun!
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm