How to get hWnd to my arx application

How to get hWnd to my arx application

hericson
Advocate Advocate
1,202 Views
4 Replies
Message 1 of 5

How to get hWnd to my arx application

hericson
Advocate
Advocate
To use GetWindowPlacement I need the handle to my arx application as the first parameter. But how do get that one?

To get the handle to AutoCad I use:
acedGetAcadFrame()->m_hWnd
I need something similiar
0 Likes
1,203 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
That is a window handle -- it doesn't belong to an "application" per se.
Does your application create any windows? If yes, how does it create the
window?
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes
Message 3 of 5

hericson
Advocate
Advocate
somewhere in acrxEntryPoint.cpp I have these lines:

if( modelessMainDialog )
{
// dialog was already created, just display it
// (the dialog only gets deallocated when the arx is unloaded)
modelessMainDialog->ShowWindow( SW_SHOWNORMAL );
return;
}

if( !modelessMainDialog && !startMainDialog() )
{
ads_printf( _T("HEProfil: Failed to create modeless main dialog box.\n") );
}


modelessMainDialog is first defined as (also in acrxEntryPoint.cpp)
// the following global will point to our modeless main dialog
CDialog_Main* modelessMainDialog = NULL; // MDI Safe


the function startMainDialog is also defined in acrxEntryPoint
Adesk::Boolean startMainDialog()
{
CAcModuleResourceOverride resOverride;
HWND hwndAcad = adsw_acadMainWnd();

if ( !hwndAcad )
{
AfxMessageBox( _T("HEProfil: Unable to locate AutoCAD parent window.") );
return Adesk::kFalse;
}

CWnd *pWnd = CWnd::FromHandle ( hwndAcad );
if( modelessMainDialog == NULL )
{
if ( (modelessMainDialog = new CDialog_Main ( pWnd )) == NULL )
{
AfxMessageBox ( _T("HEProfil: Unable to allocate a CDialog_Main.") );
return Adesk::kFalse;
}

BOOL succeeded = modelessMainDialog->Create ( pWnd );
if ( !succeeded )
{
AfxMessageBox ( _T("HEProfil: Unable to create the main dialog.") );
return Adesk::kFalse;
}
}
modelessMainDialog->ShowWindow(SW_SHOWNORMAL);

return Adesk::kTrue;
}


The GetWindowPlacement call is in the Dialog_Main.cpp file
0 Likes
Message 4 of 5

hericson
Advocate
Advocate
If i run GetWindowPlacement in the BOOL CDialog_Main::OnInitDialog() function or any other function that belongs to my CDialog_Main, it only takes one parameter like GetWindowPlacement(&WP); and it works.
0 Likes
Message 5 of 5

Anonymous
Not applicable
Your CDialog_Main is derived from CWnd, which has a member m_hWnd that
stores the window handle. You can use it directly, or just call the CDialog
member functions. 🙂
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
0 Likes