CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    1

    Question Timers, Multithreading and annoying programming problems!

    Hi everyone,

    I have an MFC Dialog-Based application with an OpenGL class showing in a static text window and working fine with mouse interaction. I am also trying to capture live feed from a webcam in the same application, same dialog, and display it in a bitmap window. I was able to capture the way i want it without the OpenGL class in the application, using a timer, but once I added it, it didn't work anymore, probably because the OpenGL function takes over. I figured I probably need to add multithreading to the capture, but this isn't working properly either, I keep getting problems with GetDlgItem not being a static function, and I'm not very familiar with multithreading. I'm not sure how to solve this problem, I have a couple of questions about things I tried to do:

    1) Is it possible to set a timer in a class and have the callback function of the timer in another? The class I'm trying to set it in is a CWin Thread class.

    2) Is it possible to have both webcam and OpenGL working without using multithreading using only the timer? If so where should I call the OpenGL class?


    I'm calling the OpenGL function and create a new thread or call the timer in the OnDialog function. I tried to call the OpenGL class in the timer callback function, the camera captured and displayed 1 image but then stopped.

    I don't know if this is a bit vague, I can give more details if necessary. I would appreciate any help, thanks!

    Sabine

  2. #2
    Join Date
    Mar 2005
    Location
    On the Dark Side of Moon
    Posts
    86

    Re: Timers, Multithreading and annoying programming problems!

    Try hooking the with the Operaton System Message Q.
    x8086

    Problem Is An Opportunity To Do Your Best.

    All Code Guru Member's
    Poll : -Please Vote For Code Guru Forum Programming competition


  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Timers, Multithreading and annoying programming problems!

    You cannot use a class member function for a timer callback. You can create a static function in your class and use that as a timer callback.

    Or you can create a timer with SetTimer and don't use a timer callback but assign it to a window. That way, WM_TIMER messages will be posted to the target window.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured