Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Menu item font resizing

Menu item font resizing

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3776112
    wrote on last edited by
    #1

    Hi, My application menu items which are created dynamically. When window DPI settings gets changed and set to 'Larger (150%)', menu item text is not visible as it is very big and hiding behind the toolbar. How can we set menu item font size or complete menu pane itself using VC++ by code so that it will be visible in all the DPI settings? Regards, Aniket

    enhzflepE 1 Reply Last reply
    0
    • U User 3776112

      Hi, My application menu items which are created dynamically. When window DPI settings gets changed and set to 'Larger (150%)', menu item text is not visible as it is very big and hiding behind the toolbar. How can we set menu item font size or complete menu pane itself using VC++ by code so that it will be visible in all the DPI settings? Regards, Aniket

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      Have you looked at the GetMenuBarInfo function? You can get the RECT of the menu-bar with this function. I.e

      MENUBARINFO mbi;
      mbi.cbSize = sizeof(mbi);
      GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
      printf("menuBar rect (screen) = %d,%d,%d,%d\n", mbi.rcBar.left, mbi.rcBar.top, mbi.rcBar.right, mbi.rcBar.bottom);

      MapWindowPoints(HWND_DESKTOP, hwnd, (LPPOINT)&mbi.rcBar, 2);
      printf("menuBar rect (client) = %d,%d,%d,%d\n", mbi.rcBar.left, mbi.rcBar.top, mbi.rcBar.right, mbi.rcBar.bottom);

      Notes: 1. All of the members are 0 during the WM_CREATE message handler 2. The dimensions returned are in screen-coords. Example output:

      menuBar rect (screen) = 108,130,636,149
      menuBar rect (client) = 0,-20,528,-1

      When I tried to change the DPI setting with the program running, I was told I'd have to logoff and then login again. Am I correct in assuming that you change the DPI and _then_ open the program? Also, is this a standard menubar, or is it an instance of a toolbar that's been added to a rebar control? The difference being that a standard one should be a part of the non-client area, and therefore the toolbar you have should be automatically moved down to accomodate the menubar having larger text. If however, you have a toolbar inside a rebar control as your menu, the rebar container is a part of your client area, and you need to manually position the toolbar below it. Different DPI settings will change the required height that you need to offset the toolbar by. Can you upload a screen shot somewhere and post a link to it?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups