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. Adding controls to an existing window

Adding controls to an existing window

Scheduled Pinned Locked Moved C / C++ / MFC
helpjsonquestion
4 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.
  • D Offline
    D Offline
    depsch
    wrote on last edited by
    #1

    I am writing a plugin for an existing application, which allows me to create a tool window and provides standard controls from their own SDK to use on the tool window. The problem is thier sdk is inssuficient and lacks many standard things such as a main menu and context menu etc,so I like to use Windows API controls on this tool, but I dont have access to this window's WndProc function. All the callbacks are handled internally by the main application which is seemingly hidden. I am able to find the Hwnd for this tool window using a spy tool. How would I go about adding my own Winapi controls on this window and how would I catch the messages sent by the controls without having access to the WndProc() or the Main() function of the application? If I initiate a seperate WndProc function, it will conflict with the main application and crashes it. There are several overload function for the tool window which the application provides. These inculde the OnPaint() and OnIdle() functions. I was able to do some basic things like painting a rect onto this window so I know I am accessing it correctly. Any help would be much appreciated. Frank

    G S 2 Replies Last reply
    0
    • D depsch

      I am writing a plugin for an existing application, which allows me to create a tool window and provides standard controls from their own SDK to use on the tool window. The problem is thier sdk is inssuficient and lacks many standard things such as a main menu and context menu etc,so I like to use Windows API controls on this tool, but I dont have access to this window's WndProc function. All the callbacks are handled internally by the main application which is seemingly hidden. I am able to find the Hwnd for this tool window using a spy tool. How would I go about adding my own Winapi controls on this window and how would I catch the messages sent by the controls without having access to the WndProc() or the Main() function of the application? If I initiate a seperate WndProc function, it will conflict with the main application and crashes it. There are several overload function for the tool window which the application provides. These inculde the OnPaint() and OnIdle() functions. I was able to do some basic things like painting a rect onto this window so I know I am accessing it correctly. Any help would be much appreciated. Frank

      G Offline
      G Offline
      Gwenio
      wrote on last edited by
      #2

      Well, if you are able to access the HWND, you can use GetWindowLongPtr[^], SetWindowLongPtr[^], and CallWindowProc[^]. GetWindowLongPtr will get you the address of the funcion, then you can set it to the custom procedure, which can then call the old procedure.

      D 1 Reply Last reply
      0
      • D depsch

        I am writing a plugin for an existing application, which allows me to create a tool window and provides standard controls from their own SDK to use on the tool window. The problem is thier sdk is inssuficient and lacks many standard things such as a main menu and context menu etc,so I like to use Windows API controls on this tool, but I dont have access to this window's WndProc function. All the callbacks are handled internally by the main application which is seemingly hidden. I am able to find the Hwnd for this tool window using a spy tool. How would I go about adding my own Winapi controls on this window and how would I catch the messages sent by the controls without having access to the WndProc() or the Main() function of the application? If I initiate a seperate WndProc function, it will conflict with the main application and crashes it. There are several overload function for the tool window which the application provides. These inculde the OnPaint() and OnIdle() functions. I was able to do some basic things like painting a rect onto this window so I know I am accessing it correctly. Any help would be much appreciated. Frank

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        The two main ways to do this would be:

        • Subclassing[^]
        • Window Hooks[^]

        Steve

        1 Reply Last reply
        0
        • G Gwenio

          Well, if you are able to access the HWND, you can use GetWindowLongPtr[^], SetWindowLongPtr[^], and CallWindowProc[^]. GetWindowLongPtr will get you the address of the funcion, then you can set it to the custom procedure, which can then call the old procedure.

          D Offline
          D Offline
          depsch
          wrote on last edited by
          #4

          Than you very much, after some fiddling on google regarding these functions I managed to reroute the message to my custom procedure and now life is getting better. Thanks to steve as well for pointing in the right direction

          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