Easy DPI Awareness and Darkmode libraries

Started by MrBcx, October 26, 2025, 08:02:36 PM

Previous topic - Next topic

MrBcx

If you like Dark Mode, you'll like the following tip.

If you have an app that uses Popup menus or perhaps you have a Tray app with its
own tray menu, the Darkmode.inc file makes it simple to display your menus in Darkmode.

There's nothing difficult about it.  $INCLUDE "Darkmode.inc" in your project and call
the initialization, like described earlier.

$IFDEF USEDARKMODE       ' DEFINED in DARKMODE.inc
     DarkMode_Setup(Form)
$ENDIF

That's all there is to it.

I did that to my Screen Shot Grabber and now its Tray app and my desktop screen clips all have Darkmode menus.




MrBcx

These are the latest efforts of Jeff Shollenberger and MrBcx to create an "EASY" way to give
your existing or new desktop (GUI) apps DPI awareness and optionally a DarkMode theme.  These
libraries are written in BCX BASIC and can be $INCLUDED when you want their capabilities.

Each library works its magic by subclassing your main form.  When you use both libraries,
a proper subclass chain is formed.  You do not need to add anything to your EVENTS LOOP.
Everything is handled by the subclassing modules.  EASY!

The only code that you need to add to your apps are the $INCLUDE statements and a simple
initialization in your SUB FORMLOAD shown below in the HOW TO section.

     
There is more work to be done on both libraries but we wanted to share what we've
already accomplished with the BCX community, so you can start enjoying the benefits
and hopefully provide helpful feedback, so that the libraries can be improved.

These do not work on the BCX DIALOG or BCX MODAL DIALOG at this time but we hope and
expect to overcome that in the future. 

I will be providing an updated version of my Fast File Scan app that Jeff and I used
for developing and testing these libraries.  That app should give you a good idea of
what to expect, if you choose to start using the libraries in your own apps.



HOW TO USE THE LIBRARIES
                 
                 *******************************************
                 Typical setup to use DarkMode and DPI_Aware
                 *******************************************


$INCLUDE "DPI_Aware.inc"
$INCLUDE "Darkmode.inc"



SUB Form1
 
          ---[  your desktop app setup can go here ]---
                         followed by ...
                         

  '========== D A R K  M O D E   AND   D P I  A W A R E   ============
    $IFDEF USEDPI           ' Defined in DPI_AWARE.inc
        DPI_Setup(Form1)
    $ENDIF

    $IFDEF USEDARKMODE       ' DEFINED in DARKMODE.inc
        DarkMode_Setup(Form1)
    $ENDIF
  '========== D A R K  M O D E   AND   D P I  A W A R E   ============
 
                        [ followed by ...  ]
                       

    CALL Setup_Menu                               ' <<--  if you have one ELSE delete this
    StatBar =   BCX_STATUS  ("Ready", Form1)      ' <<--             Ditto
    SetStatusText (StatBar,  "Ready")             ' <<--             Ditto
   
    SHOW Form1
END SUB



That's all there is to it!  EASY!