WinFinder.cpp
上传用户:lwzh1970
上传日期:2007-01-01
资源大小:33k
文件大小:4k
- // WinFinder.cpp : Implementation of CWinFinderApp and DLL registration.
- #include "stdafx.h"
- #include "WinFinder.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- CWinFinderApp NEAR theApp;
- const GUID CDECL BASED_CODE _tlid =
- { 0xdca2aa0, 0xc50f, 0x11d2, { 0x95, 0x80, 0x20, 0xb3, 0x4e, 0xc1, 0, 0 } };
- const WORD _wVerMajor = 1;
- const WORD _wVerMinor = 0;
- ////////////////////////////////////////////////////////////////////////////
- // CWinFinderApp::InitInstance - DLL initialization
- BOOL CWinFinderApp::InitInstance()
- {
- BOOL bInit = COleControlModule::InitInstance();
- if (bInit)
- {
- // TODO: Add your own module initialization code here.
- }
- return bInit;
- }
- ////////////////////////////////////////////////////////////////////////////
- // CWinFinderApp::ExitInstance - DLL termination
- int CWinFinderApp::ExitInstance()
- {
- // TODO: Add your own module termination code here.
- return COleControlModule::ExitInstance();
- }
- /////////////////////////////////////////////////////////////////////////////
- // DllRegisterServer - Adds entries to the system registry
- // I did not write this code
- void DrawWindowFrame (HWND hwndSubject)
- {
- HDC hdc;
- RECT rc;
- HPEN hpen;
-
- // Retrieve location of window on-screen.
- GetWindowRect(hwndSubject, &rc);
- // Get a device context that allows us to write anywhere within the window.
- // NOTE: GetDC would allow us to write only in the window's client area.
- hdc = GetWindowDC(hwndSubject);
- // Save the original device context attributes.
- SaveDC(hdc);
-
- // To guarantee that the frame will be visible, tell Windows to draw the
- // frame using the inverse screen color.
- SetROP2(hdc, R2_NOT);
- // Create a pen that is three times the width of a nonsizeable border. The
- // color will not be used to draw the frame, so its value could be
- // anything. PS_INSIDEFRAME tells windows that the entire frame should be
- // enclosed within the window.
- hpen = CreatePen(PS_INSIDEFRAME, 3 * GetSystemMetrics(SM_CXBORDER),
- RGB(0, 0, 0));
- SelectObject(hdc, hpen);
- // We must select a NULL brush so that the contents of the window will not
- // be overwritten.
- SelectObject(hdc, GetStockObject(NULL_BRUSH));
- // Draw the frame. Because the device context is relative to the window,
- // the top-left corner is (0, 0) and the lower right corner is (width of
- // window, height of window).
- Rectangle(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top);
- // Restore the original attributes and release the device context.
- RestoreDC(hdc, -1);
- ReleaseDC(hwndSubject, hdc);
- // We can destroy the pen only AFTER we have restored the DC because the DC
- // must have valid objects selected into it at all times.
- DeleteObject(hpen);
- }
- STDAPI DllRegisterServer(void)
- {
- AFX_MANAGE_STATE(_afxModuleAddrThis);
- if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
- return ResultFromScode(SELFREG_E_TYPELIB);
- if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
- return ResultFromScode(SELFREG_E_CLASS);
- return NOERROR;
- }
- /////////////////////////////////////////////////////////////////////////////
- // DllUnregisterServer - Removes entries from the system registry
- STDAPI DllUnregisterServer(void)
- {
- AFX_MANAGE_STATE(_afxModuleAddrThis);
- if (!AfxOleUnregisterTypeLib(_tlid))
- return ResultFromScode(SELFREG_E_TYPELIB);
- if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
- return ResultFromScode(SELFREG_E_CLASS);
- return NOERROR;
- }