Results 1 to 37 of 37

Thread: [vb6] Per-Monitor DPI Awareness Framework

Threaded View

  1. #1

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    [vb6] Per-Monitor DPI Awareness Framework

    Included project offered as a starting point to fully support per-monitor DPI awareness within VB. The "framework" consists of 3 required classes and 2 optional ones that would be added to any project that would support per-monitor DPI awareness. Documentation is provided within each enclosed class. Additional documentation provided in the zipped "Documentation" folder.

    Per-monitor DPI awareness is a completely new mindset for VBers. We are so used to VB handling nearly all the scaling of the GUI for us. We didn't have to do too much at all because many of us opted for DPI virtualization (no awareness) or system-DPI awareness via a manifest. In both of those cases, little to no effort was needed. However, with per-monitor DPI awareness, the form and nearly everything related to it must be scaled manually. The enclosed framework will help handle scaling of the form, its VB intrinsic controls, common controls, and images. The framework also handles any necessary hooking and/or subclassing and notifying you of DPI changes. When you are notified, the framework sends various events to walk you through the needed actions and optionally automates the necessary grunt work as much as possible. In the documentation, the term used is: scaling cycle.

    Anyone that is creating apps (or usercontrols) to be distributed should seriously consider per-monitor DPI awareness. If creating stuff for your own use, then per-monitor DPI awareness may not be worth it.

    Usercontrols: The framework is not designed for use inside your usercontrols -- not yet. The framework is designed for form-level and cannot easily be tweaked to support custom usercontrols. And in reality, you probably don't want to make your control per-monitor DPI aware. Why? Even if the host of your control is not DPI-aware, it is possible Windows will send your control DPI-change messages. You would then have to determine if the host was DPI aware and that is possible. However, current strategy says that the host scales its content, including controls. Instead, maybe your control should have a public method for the user to set the current DPI the control should render to. If not that option, you should expose all scalable, internal properties, like fonts and offsets so the user can scale them on demand when DPI changes.

    There is no way this framework could possibly have code to help scale every compiled ocx used by the VB community. At a minimum, the enclosed classes can be used as a template for future expansion. Maybe, you and others can design scalers for other ocxs and post them here? I do not claim these classes will handle every possible scenario for every project. There will be cases where the code isn't doing what you expect -- that's what feedback is for.

    After downloading, please read the 3 "ReadMe" files before jumping into anything. They will give you a really good idea of what you will be getting into.

    Since per-monitor DPI awareness isn't widely addressed for VB, the hope is that this project's framework can be used as a major step forward or is a catalyst for new ideas.

    There are two projects included below:

    1. Framework.zip includes a test project, the classes and documentation. The test project has just a few controls, including a couple common controls. To test it in various DPIs, either compile the project or make your IDE DPI-aware. In the documentation folder, there is information on how to make your IDE DPI-aware without actually modifying your VB6.exe directly. The documentation also includes several sample manifests. Also included is a screenshot of a form loaded @ 96 DPI and then DPI changed to 175% larger, both with/without DPI-awareness. Since the image is scaled by this site, the difference in quality can't be appreciated without viewing full-sized. That image can be found in the documentation folder.

    2. ProjectTemplate.zip includes files you can unzip into your VB's ...\Template\Projects folder. If done, there will be a new project type available to you when you create a new VB project. That new type is titled: DPI Aware EXE Wizard. If selected, it will create a new project with the framework already added. The only thing it won't create is a resource file, having a manifest. That will need to be done manually for each new project.
    Attached Files Attached Files
    Last edited by LaVolpe; Sep 9th, 2020 at 02:28 PM. Reason: justl text updates
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width