Urgent help needed - handle to application window


HELP!! I am new to MFC programming and I'm really struggling with what seems like a really simple problem.

Ok, I have created an application using AppWizard. I have now started adding functionality to the application (the app will control a TWAIN complient scanner, and perform some image processing techniques). The code that is supplied with the TWAIN SDK uses the handle to window value (hwnd). The problem I have is obtaining this value when using MFC. I have tried everything I can think of, and desperately need some help.

I have tried: CWnd m_hWnd - no luck. I can't get FindWindow to work either.

Any help would be greatly appreciated.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

plarocheConnect With a Mentor Commented:
This all depends on what window will handle the driver's notifications.

From any CWnd derived class you get the handle to it with:

Pleas take not that GetSafeHwnd will return a valid handle only after OnCreate for the base class has been called.
jpbourneAuthor Commented:
I can only see the following OnCreate statement in the entire project:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

Is this the correct place to insert the GetSafeHwnd() statement?

And BTW, your help really is appreciated.
jpbourneAuthor Commented:
I tried what you suggested in the CMainFrame::OnCreate and it worked!

Thanks for your help plaroche.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.