Link to home
Start Free TrialLog in
Avatar of rose3377
rose3377

asked on

TimeProc

Hi.. another multimedia time question... I have a dialog based MFC with a static control that I want to change every time the multimedia timer changes. I had this in the TimeProc

CStatic* staticctrl = (CStatic*) GetDlgItem(IDC_STATIC_TEST);
staticctrl->SetWindowText("Low");  

And I have had grief with the GetDlgItem because of some parameters.
Is there a way to fix this?
Also, If fix it by posting a message in TimeProc with PostMessage, what priority would it have because it is time critical and I want the highest accuracy?
Avatar of nietod
nietod

Your message will be given high prioroty in the message queue, but that doesn't matter because PostMessage is assynchronous so the message is not likely to be handled very quickly.  

SendMessage would be better, but the prolem is that the program could be waiting for  another sendmessage to return, in which case your sendmessage can't be processed so the message will be ignored.

If you need timely processing, then you had better forget using messages.  What are the problems you are trying to solve?
Avatar of rose3377

ASKER

I have a program generating a pulse train to my hardware. The pulse has to have an exact period. Timing is critical! How do I achieve this then? I needed the GetDlgItem so that a static control on the dialog box will alternate saying high-low-high-etc.
NT is far superior to windows 95/98 but it is not a real-time system.  Depending on how critical the timing is you may not be able produce the signal you need.   A more typical solution would be to use NT to control (turn on or off) a hardware signal generator.

You should be able to use GetDlgItem etc you haven't explained what troubles you are having with it.  However, That sort if thing is likley to be slow, how long is your timer event?  Also since the timmer procedure is called asynchronously, you do need to take procautions to syncronize access to shared data, like the dialog item etc.
The problem with GetDlgItem is that my error says that I am calling a non-static function in a static function, since the callback function of a multimedia timer is static. Is there a way around this problem?
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial