WinFBE and themed GUIs

Windows specific questions.
Post Reply
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

WinFBE and themed GUIs

Post by deltarho[1859] »

There appears to be a few new members getting into WinFBE and GUIs.

I am going to skip getting to the finished article and show how easy it is to theme the finished article.

Firstly, we need to create a folder called Theme. I have put mine in "E:\FreeBASIC"

From 'File>Open Templates...' load '.Manifest (both 32 and 64 bit)'.

Now save in your Theme folder as 'Theme.xml'

Create a 'New File' with this single statement:1 24 "E:\FreeBASIC\Theme\Theme.xml", using your path to "Theme.xml", and save in your Theme folder as 'MyProg.rc'.

At the top of your program's bas fle add '#Resource "E:\FreeBASIC\Theme\MyProg.rc", using your path to "MyProg.rc".

The resulting exe will now be themed.

The 'Details' tab in the Property sheet will have precious little in it, like 'File version' among others, requiring a lot more in the rc file, but that is another story when you want to publish an exe.

None of the examples in Templates are themed. They can be easily themed with the above method.

If you have a console application which uses messagebox, via #include once "windows.bi", the above will see the messagebox themed.

Here is a little GUI using only messagebox. Use your path to "MyProg.rc"

Code: Select all

''#Resource "E:\FreeBASIC\Theme\MyProg.rc"
#include once "windows.bi"
messagebox( null, "<Some statement>", "MyProg", MB_YESNOCANCEL )
sleep
If you compile and run as is, you will get this:
Image
If you uncomment, once, the first statement you will get this:
Image
Simple. :)
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE and themed GUIs

Post by deltarho[1859] »

I should have mentioned that the examples in Templates use AfxSetProcessDPIAware. We can remove that when using the above method, as it is covered in the <asmv3:application> section of Theme.xml.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: WinFBE and themed GUIs

Post by srvaldez »

thanks deltarho[1859] :)
will keep this in mind for my next project
PaulSquires
Posts: 1002
Joined: Jul 14, 2005 23:41

Re: WinFBE and themed GUIs

Post by PaulSquires »

Thanks deltarho

The other option is to create a "Project" for your visual design application. WinFBE's projects automatically add a default resource file to your project that includes the necessary code to enable Windows themes.

Paul
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE and themed GUIs

Post by deltarho[1859] »

Thanks srvaldez and Paul.

José Roca recently wrote: “So you have two choices: to code by hand using the good old SDK style or to use a visual designer.”

I am firmly in the camp of “the good old SDK style” and wild horses would not drag me to another camp. Without a WndProc I break out in a rash. :)
Josep Roca
Posts: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: WinFBE and themed GUIs

Post by Josep Roca »

But you can start a project, that will add the resource file automatically, and then code by hand. This is what I do. The benefit is that you will have a resource file automatically added without having to add any line of code by yourself. Starting a project doesn't mean that you have to use the visual designer.
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE and themed GUIs

Post by deltarho[1859] »

But then we get “resource.rc” and “manifest.xml” in every project.

With the above method, we get “MyProg.rc” and “Theme.xml” in the Theme folder and that is it.

I have now put the Theme folder in WinFBE's Tools folder.
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: WinFBE and themed GUIs

Post by deltarho[1859] »

I have created a template called 'ConsoleOn'

ConsoleOn.fbtpl

Code: Select all

2
FBGUI
.bas
ConsoleOn
'#CONSOLE ON
''#Resource "H:\WinFBE_Suite\Tools\Theme\MyProg.rc"
#ifndef Uint8
  #define Uint8 = Uinteger<8>
#endif
#ifndef Uint16
  #define Uint16 = Uinteger<16>
#endif
#ifndef Uint32
  #define Uint32 = Uinteger<32>
#endif
#ifndef Uint64
  #define Uint64 = Uinteger<64>
#endif
#define Uint3264 = Uinteger
#ifndef int8
  #define int8 = Integer<8>
#endif
#ifndef int16
  #define int16 = Integer<16>
#endif
#ifndef int32
  #define int32 = Integer<32>
#endif
#ifndef int64
  #define int64 = Integer<64>
#endif
and dropped it into WinFBE's Templates folder.

Selecting ConsoleOn in the Templates window loads line 5 to the end of the file.

If I want to theme, then I simply remove the first comment character in the Resource statement.

MyProg.rc

Code: Select all

1 24 "H:\WinFBE_Suite\Tools\Theme\Theme.xml"
Going to a lot of trouble? Not really. I am bone idle. I want to avoid doing any dirty work, that is my machine's job, not mine. :)
Post Reply