HiddenWindow.cpp
上传用户:glass0516
上传日期:2010-01-11
资源大小:104k
文件大小:4k
- /*****************************************************************************
- * RelayFax Open Source Project
- * Copyright 1996-2004 Alt-N Technologies, Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the RelayFax Open
- * Source License. A copy of this license is available in file LICENSE
- * in the top-level directory of the distribution.
- *
- * RelayFax is a registered trademark of Alt-N Technologies, Ltd.
- *
- * Individual files and/or contributed packages may be copyright by
- * other parties and subject to additional restrictions.
- *****************************************************************************/
- #include "stdafx.h"
- #include "HiddenWindow.h"
- #include "excepthandler.h"
- ATOM CHiddenWindow::s_WindowClassAtom = 0;
- char* CHiddenWindow::s_WindowClass = "RelayFax Hidden Window";
- HINSTANCE CHiddenWindow::s_hInstance = NULL;
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CHiddenWindow::CHiddenWindow()
- {
- }
- CHiddenWindow::~CHiddenWindow()
- {
- }
- //////////////////////////////////////////////////////////////////////
- // RegisterWindowClass
- //////////////////////////////////////////////////////////////////////
- void CHiddenWindow::RegisterWindowClass( HINSTANCE hInstance )
- {
- WNDCLASS wc;
- ZeroMemory( &wc, sizeof(wc) );
-
- wc.hCursor = NULL; // this window never shown, so no
- wc.hIcon = NULL; // cursor or icon are necessary
- wc.lpszMenuName = NULL;
- wc.lpszClassName = s_WindowClass;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wc.hInstance = hInstance;
- wc.style = CS_GLOBALCLASS;
- wc.lpfnWndProc = WndProc;
- wc.cbWndExtra = sizeof(CHiddenWindow*);
- wc.cbClsExtra = 0;
- s_WindowClassAtom = RegisterClass( &wc );
- s_hInstance = hInstance;
- }
- //////////////////////////////////////////////////////////////////////
- // UnRegisterWindowClass
- //////////////////////////////////////////////////////////////////////
- void CHiddenWindow::UnRegisterWindowClass( void )
- {
- UnregisterClass( s_WindowClass, s_hInstance );
- }
- //////////////////////////////////////////////////////////////////////
- // Hidden Window Procedure
- //////////////////////////////////////////////////////////////////////
- LRESULT CALLBACK CHiddenWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
- {
- CHiddenWindow* pWnd = (CHiddenWindow*) GetWindowLong( hwnd, 0 );
- // char szMsg[80];
- // wsprintf( szMsg, "CHiddenWindow::WndProc: 0x%xn", msg );
- // OutputDebugString( szMsg );
- // __try
- {
- if( pWnd )
- {
- return pWnd->HandleMsg( msg, wParam, lParam );
- }
- }
- // __except ( ExceptionHandler( GetExceptionInformation(), "Any", "HandleMsg" ) )
- {
- //LOG( LOG_SYSTEM, "%s: Unhandled exception in OnStartup()", m_sThreadName.c_str() );
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////
- // InitWindow
- //////////////////////////////////////////////////////////////////////
- void CHiddenWindow::InitWindow(void)
- {
-
- m_hwnd = CreateWindow( s_WindowClass, s_WindowClass, 0,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, NULL, s_hInstance, NULL );
- DWORD dwError = GetLastError();
- SetWindowLong( m_hwnd, 0, (LONG)this );
- }
- //////////////////////////////////////////////////////////////////////
- // ShutdownWindow
- //////////////////////////////////////////////////////////////////////
- void CHiddenWindow::ShutdownWindow(void)
- {
- DestroyWindow( m_hwnd );
- }
- //////////////////////////////////////////////////////////////////////
- // HandleMsg
- //////////////////////////////////////////////////////////////////////
- LRESULT CHiddenWindow::HandleMsg( UINT msg, WPARAM wParam, LPARAM lParam )
- {
- return DefWindowProc( m_hwnd, msg, wParam, lParam );
- }
- void CHiddenWindow::PostMessage( UINT msg, WPARAM wParam, LPARAM lParam )
- {
- ::PostMessage( m_hwnd, msg, wParam, lParam );
- }