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. strange question

strange question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
2 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.
  • W Offline
    W Offline
    will1383
    wrote on last edited by
    #1

    I have a dll with a dialog box that gets run when the function is called. This uses MFC. I want to spawn a new thread that the dialog box runs in. Here's the exported function: extern "C" __declspec(dllexport) void XducerSpecDialog(int px, int patxrx, int cred, int tfmid, void (*TimerCallBack)(), int (*callbackFunc)(int tfmid)) I thought I could just use _beginthread, but I'm not quite sure what to do becuase I'm using MFC and I have an instance of the class object that I use to call: theApp.RunDialog Can I just call the _beginthread(theApp.RunDialog,0,my_arguements)??? Thanks!

    E 1 Reply Last reply
    0
    • W will1383

      I have a dll with a dialog box that gets run when the function is called. This uses MFC. I want to spawn a new thread that the dialog box runs in. Here's the exported function: extern "C" __declspec(dllexport) void XducerSpecDialog(int px, int patxrx, int cred, int tfmid, void (*TimerCallBack)(), int (*callbackFunc)(int tfmid)) I thought I could just use _beginthread, but I'm not quite sure what to do becuase I'm using MFC and I have an instance of the class object that I use to call: theApp.RunDialog Can I just call the _beginthread(theApp.RunDialog,0,my_arguements)??? Thanks!

      E Offline
      E Offline
      Erik Juhl
      wrote on last edited by
      #2

      I think you need to use the MFC thread functions within MFC, AfxBeginThread(). Unless theApp.RunDialog has a function signature of a worker thread, you might want to take a different approach. Define a worker thread with a signature like UINT MyControllingFunction( LPVOID pParam ); and use that as the first parameter to AfxBeginThread. Pass theApp as a second parameter and from inside your worker thread, call RunDialog. Here's a sample from MSDN using a CMyObject instead of theApp... UINT MyThreadProc( LPVOID pParam ) { CMyObject* pObject = (CMyObject*)pParam; if (pObject == NULL || !pObject->IsKindOf(RUNTIME_CLASS(CMyObject))) return 1; // if pObject is not valid // do something with 'pObject' return 0; // thread completed successfully } // inside a different function in the program . . . pNewObject = new CMyObject; AfxBeginThread(MyThreadProc, pNewObject); . . .

      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