Urgent help needed - handle to application window

Posted on 1998-11-30
Last Modified: 2013-11-20

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.

Question by:jpbourne
  • 2
  • 2

Accepted Solution

plaroche earned 50 total points
ID: 1325520
This all depends on what window will handle the driver's notifications.

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


Expert Comment

ID: 1325521
Pleas take not that GetSafeHwnd will return a valid handle only after OnCreate for the base class has been called.

Author Comment

ID: 1325522
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.

Author Comment

ID: 1325523
I tried what you suggested in the CMainFrame::OnCreate and it worked!

Thanks for your help plaroche.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 55
unable to delete all specified values regedit 38 270
fizzArray  challenge 1 57
wordappend challenge 8 143
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now