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. COM
  4. Timer with Windowless Control

Timer with Windowless Control

Scheduled Pinned Locked Moved COM
c++helpquestion
4 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.
  • S Offline
    S Offline
    Shraddhan
    wrote on last edited by
    #1

    :sigh:I have a windowless control for which I need a timer to reset an internal state after a short delay, for highlighting purposes. I have been led to believe that all I need to do is to use a hidden window to handle SetTimer and KillTimer. Yet all my attempts to create a hidden window have failed. It seems that I can't register my own window class, because Create fails. (This approach worked fine until I specified a variable to refer to the control in C++ code.) So I tried using a predefined class, CButton. This can't be created when the control is used from VBasic, as CWin::Create needs to know have an application instance, but VBasic supplies this as NULL. I have found code using ATL which would seem to work, but I am using MFC and can't figure out how the ATL code can be translated. Is there any practical way to use a timer in a windowless control? Or do I really have to specify a window for the control just for the sake of a timer? Shraddhan Tearing my hair out does not help me write better code, but it does ease the pain...

    J 1 Reply Last reply
    0
    • S Shraddhan

      :sigh:I have a windowless control for which I need a timer to reset an internal state after a short delay, for highlighting purposes. I have been led to believe that all I need to do is to use a hidden window to handle SetTimer and KillTimer. Yet all my attempts to create a hidden window have failed. It seems that I can't register my own window class, because Create fails. (This approach worked fine until I specified a variable to refer to the control in C++ code.) So I tried using a predefined class, CButton. This can't be created when the control is used from VBasic, as CWin::Create needs to know have an application instance, but VBasic supplies this as NULL. I have found code using ATL which would seem to work, but I am using MFC and can't figure out how the ATL code can be translated. Is there any practical way to use a timer in a windowless control? Or do I really have to specify a window for the control just for the sake of a timer? Shraddhan Tearing my hair out does not help me write better code, but it does ease the pain...

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      Did you try RegisterClass()/RegisterClassEx()? If your target platform is windows 2000 and later, you can create message only windows. They work like windows, except they have no graphical representations. They're just "identities" (HWND). Good music: In my rosary[^]

      S 1 Reply Last reply
      0
      • J Jorgen Sigvardsson

        Did you try RegisterClass()/RegisterClassEx()? If your target platform is windows 2000 and later, you can create message only windows. They work like windows, except they have no graphical representations. They're just "identities" (HWND). Good music: In my rosary[^]

        S Offline
        S Offline
        Shraddhan
        wrote on last edited by
        #3

        I was using AfxRegisterClass() and CWnd::CreateEx():cool: After changing the code to use RegisterClassEx( ) and CreateWindowEx(), everything now seems to work. What the difference might be, I have no idea. Thanks for the clue. Shraddhan

        J 1 Reply Last reply
        0
        • S Shraddhan

          I was using AfxRegisterClass() and CWnd::CreateEx():cool: After changing the code to use RegisterClassEx( ) and CreateWindowEx(), everything now seems to work. What the difference might be, I have no idea. Thanks for the clue. Shraddhan

          J Offline
          J Offline
          Jorgen Sigvardsson
          wrote on last edited by
          #4

          You're most welcome, and I'm glad that it worked out for you. :) Good music: In my rosary[^]

          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