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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
twoTwo  challenge 35 101
abstract class with all non abstract mentods 6 76
EvenOdd challenge 10 105
Problem to App source 6 33
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

813 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

13 Experts available now in Live!

Get 1:1 Help Now