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. Creating Custom Controls in MFC

Creating Custom Controls in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlearning
4 Posts 4 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.
  • B Offline
    B Offline
    Bram van Kampen
    wrote on last edited by
    #1

    Hi, How do I create a totally new MFC Control type? I take it that I have to create and register a new Window Class, with it's own Message Procedure, and thereafter write my own MFC/CPP around it as a Husk. Is there any way of deriving my own custom controls from CWnd directly and using the message map Macro's? As a new type of control it will need a resource to display it on screen, etc. How do I tie all this together. Regards, :)

    Bram van Kampen

    R L J 3 Replies Last reply
    0
    • B Bram van Kampen

      Hi, How do I create a totally new MFC Control type? I take it that I have to create and register a new Window Class, with it's own Message Procedure, and thereafter write my own MFC/CPP around it as a Husk. Is there any way of deriving my own custom controls from CWnd directly and using the message map Macro's? As a new type of control it will need a resource to display it on screen, etc. How do I tie all this together. Regards, :)

      Bram van Kampen

      R Offline
      R Offline
      Rick York
      wrote on last edited by
      #2

      Start by reading a few of the many articles at this site on custom controls. You can't expect someone to explain all of that in a few forum posts.

      1 Reply Last reply
      0
      • B Bram van Kampen

        Hi, How do I create a totally new MFC Control type? I take it that I have to create and register a new Window Class, with it's own Message Procedure, and thereafter write my own MFC/CPP around it as a Husk. Is there any way of deriving my own custom controls from CWnd directly and using the message map Macro's? As a new type of control it will need a resource to display it on screen, etc. How do I tie all this together. Regards, :)

        Bram van Kampen

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        It depends what you want your class to do. Take a look at the Hierarchy Chart | Microsoft Docs[^] and see if there is an existing control that you can derive from (even if it is CWnd), since the base class will provide lots of functionality.

        1 Reply Last reply
        0
        • B Bram van Kampen

          Hi, How do I create a totally new MFC Control type? I take it that I have to create and register a new Window Class, with it's own Message Procedure, and thereafter write my own MFC/CPP around it as a Husk. Is there any way of deriving my own custom controls from CWnd directly and using the message map Macro's? As a new type of control it will need a resource to display it on screen, etc. How do I tie all this together. Regards, :)

          Bram van Kampen

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          Because all MFC controls are CWnd based you should use that as base class too. Then add the painting (OnPaint, OnEraseBackground), register the window class and add control specific message handlers as necessary. An old but good article by Chris: Creating Custom Controls[^]

          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