Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function that returns a handle to the main window 1

Status
Not open for further replies.

bio4ema

Programmer
Mar 13, 2005
11
AT
hello.

is there a (simple) function that returns a handle to the main window (of type HWND) of a c++/mfc program ?

i tried using the Process.MainWindowHandle property and the IConsole2::GetMainWindow() method but couldn't quite get either of them to work...

thanks, b.
 
Use AfxGetMainWnd(). This probably won't return the handle to the window directly, but you can work with this and get it somehow.

Code:
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();

You can use AfxGetMainWnd() virtually anywhere in an MFC project.



-Bones
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top