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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to change menu font?

how to change menu font?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionhelp
6 Posts 3 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.
  • T Offline
    T Offline
    tataxin
    wrote on last edited by
    #1

    What is the simplest way to change font of MDI? For example I want a menu with bold, Arial, size 10 font. Create a menu and use SetFont() function seem to be a official way, but actually it doesn't work. I found some articles by Google but not help much. ??

    H I 2 Replies Last reply
    0
    • T tataxin

      What is the simplest way to change font of MDI? For example I want a menu with bold, Arial, size 10 font. Create a menu and use SetFont() function seem to be a official way, but actually it doesn't work. I found some articles by Google but not help much. ??

      H Offline
      H Offline
      halibobo
      wrote on last edited by
      #2

      Setting Fonts for Menu-Item Text Strings This topic contains an example from an application that uses owner-drawn menu items in a menu. The menu contains items that set the attributes of the current font, and the items are displayed using the appropriate font attribute. Here is how the menu is defined in the resource-definition file. Note that the strings for the Regular, Bold, Italic, and Underline menu items are assigned at run time, so their strings are empty in the resource-definition file. MainMenu MENU BEGIN POPUP "&Character" BEGIN MENUITEM "", IDM_REGULAR MENUITEM SEPARATOR MENUITEM "", IDM_BOLD MENUITEM "", IDM_ITALIC MENUITEM "", IDM_ULINE END END The application's window procedure processes the messages involved in using owner-drawn menu items. The application uses the WM_CREATE message to do the following: Set the MF_OWNERDRAW flag for the menu items. Set the text strings for the menu items. Obtain handles of the fonts used to draw the items. Obtain the text and background color values for selected menu items. The text strings and font handles are stored in an array of application-defined MYITEM structures. The application-defined GetAFont function creates a font that corresponds to the specified font attribute and returns a handle to the font. The handles are destroyed during the processing of the WM_DESTROY message. During the processing of the WM_MEASUREITEM message, the example gets the width and height of a menu-item string and copies these values into the MEASUREITEMSTRUCT structure. The system uses the width and height values to calculate the size of the menu. During the processing of the WM_DRAWITEM message, the menu item's string is drawn with room left next to

      T 1 Reply Last reply
      0
      • H halibobo

        Setting Fonts for Menu-Item Text Strings This topic contains an example from an application that uses owner-drawn menu items in a menu. The menu contains items that set the attributes of the current font, and the items are displayed using the appropriate font attribute. Here is how the menu is defined in the resource-definition file. Note that the strings for the Regular, Bold, Italic, and Underline menu items are assigned at run time, so their strings are empty in the resource-definition file. MainMenu MENU BEGIN POPUP "&Character" BEGIN MENUITEM "", IDM_REGULAR MENUITEM SEPARATOR MENUITEM "", IDM_BOLD MENUITEM "", IDM_ITALIC MENUITEM "", IDM_ULINE END END The application's window procedure processes the messages involved in using owner-drawn menu items. The application uses the WM_CREATE message to do the following: Set the MF_OWNERDRAW flag for the menu items. Set the text strings for the menu items. Obtain handles of the fonts used to draw the items. Obtain the text and background color values for selected menu items. The text strings and font handles are stored in an array of application-defined MYITEM structures. The application-defined GetAFont function creates a font that corresponds to the specified font attribute and returns a handle to the font. The handles are destroyed during the processing of the WM_DESTROY message. During the processing of the WM_MEASUREITEM message, the example gets the width and height of a menu-item string and copies these values into the MEASUREITEMSTRUCT structure. The system uses the width and height values to calculate the size of the menu. During the processing of the WM_DRAWITEM message, the menu item's string is drawn with room left next to

        T Offline
        T Offline
        tataxin
        wrote on last edited by
        #3

        It seem to be not very easy. I'll try it later. Thank you very much, halibobo.

        H 1 Reply Last reply
        0
        • T tataxin

          What is the simplest way to change font of MDI? For example I want a menu with bold, Arial, size 10 font. Create a menu and use SetFont() function seem to be a official way, but actually it doesn't work. I found some articles by Google but not help much. ??

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          There is no easy way. The menu is part of the non-client area, and windows is kindly handling for you. The idea is that a user can pick a font / size she likes, and all her software will use it. You'd better have a damn good reason to override her preferences, so it's fine for it to be hard for you. There are several good owner drawn menu articles here on codeproject for you to dig through, or look at halibobo's reply. Iain.

          Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.

          T 1 Reply Last reply
          0
          • T tataxin

            It seem to be not very easy. I'll try it later. Thank you very much, halibobo.

            H Offline
            H Offline
            halibobo
            wrote on last edited by
            #5

            I am a Chinese girl.My English is not very good. I wish we can advance together.

            1 Reply Last reply
            0
            • I Iain Clarke Warrior Programmer

              There is no easy way. The menu is part of the non-client area, and windows is kindly handling for you. The idea is that a user can pick a font / size she likes, and all her software will use it. You'd better have a damn good reason to override her preferences, so it's fine for it to be hard for you. There are several good owner drawn menu articles here on codeproject for you to dig through, or look at halibobo's reply. Iain.

              Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.

              T Offline
              T Offline
              tataxin
              wrote on last edited by
              #6

              sorry all, I tried to use another solution: codejock software. it's ok now, thank you friends!

              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