Timer with Windowless Control
-
: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...
-
: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...
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[^] -
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[^] -
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
You're most welcome, and I'm glad that it worked out for you. :) Good music: In my rosary[^]