Antonio Linares wrote:Hakan,
Just once at the beginning of your app.
And we should remove the hook before the app quits
How?
what about the my error result of 15.06?
Antonio Linares wrote:Hakan,
Just once at the beginning of your app.
And we should remove the hook before the app quits
static HHOOK hHook = NULL;
static void CenterWindowOnParent( HWND hChildWnd )
{
HWND hParent = GetParent( hChildWnd );
RECT rcChild, rcParent;
int cxChild, cyChild, cxParent, cyParent;
GetWindowRect( hChildWnd, &rcChild );
GetWindowRect( hParent, &rcParent );
cxChild = rcChild.right - rcChild.left;
cyChild = rcChild.bottom - rcChild.top;
cxParent = rcParent.right - rcParent.left;
cyParent = rcParent.bottom - rcParent.top;
SetWindowPos( hChildWnd, NULL,
rcParent.left + ( cxParent - cxChild ) / 2,
rcParent.top + ( cyParent - cyChild ) / 2, 0, 0, 0x15 );
}
LRESULT CALLBACK MsgBoxHookProc( int nCode, WPARAM wParam, LPARAM lParam )
{
if( nCode < 0 ) // do not process message
return CallNextHookEx( hHook, nCode, wParam, lParam );
if( nCode == HCBT_ACTIVATE )
{
HWND hWndMsgBox = ( HWND ) wParam;
char cn[ 200 ];
GetClassName( hWndMsgBox, cn, 199 );
if( cn[ 0 ] == '#' &&
cn[ 1 ] == '3' &&
cn[ 2 ] == '2' &&
cn[ 3 ] == '7' &&
cn[ 4 ] == '7' &&
cn[ 5 ] == '0' &&
cn[ 6 ] == 0 )
CenterWindowOnParent( hWndMsgBox );
}
return 0; // allow normal processing
}
HINSTANCE GetInstance( void );
HB_FUNC( CENTERMSGS )
{
hHook = SetWindowsHookEx( WH_CBT,
MsgBoxHookProc, GetInstance(),
GetCurrentThreadId() );
}
//------------------------------------------------------------------------//
HB_FUNC( UNHOOKWINDOWSHOOKEX )
{
if( hHook )
{
hb_retl( UnhookWindowsHookEx( hHook ) );
hHook = NULL;
}
else
hb_retl( 0 );
}
//------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 35 guests