⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 catldlg.h

📁 word 插件 在word2003+ vc6.0 条件下运行 可以单击弹出atl 的窗口 简单可实现
💻 H
字号:
#ifndef CATLDLG_H
#define CATLDLG_H

#include "Resource.h"

class CAtldlg : public CDialogImpl<CAtldlg>
{
public:
	enum { IDD = IDD_DIALOG1 };

	BEGIN_MSG_MAP(CAboutDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
        COMMAND_ID_HANDLER(IDOK, OnOKCancel)
        COMMAND_ID_HANDLER(IDCANCEL, OnOKCancel)
    END_MSG_MAP()

    LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        CenterWindow();
        return TRUE;    // let the system set the focus
    }

    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        EndDialog(IDCANCEL);
        return 0;
    }

    LRESULT OnOKCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
        EndDialog(wID);
        return 0;
    }
};
//#include <swindows.h>
//#include <afxext.h>
class CMyWindow : public CWindowImpl<CMyWindow, CWindow, CFrameWinTraits>//,
                 // public CPaintBkgnd<CMyWindow, RGB(0,0,255)>
{
public:
    DECLARE_WND_CLASS(_T("My Window Class"))
 
//typedef CPaintBkgnd<CMyWindow, RGB(0,0,255)> CPaintBkgndBase;

    BEGIN_MSG_MAP(CMyWindow)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_PAINT,OnPaint)
		MESSAGE_HANDLER(WM_LBUTTONDOWN,OnLButtonDown)
		MESSAGE_HANDLER(WM_KEYDOWN,OnKeyDown)
        COMMAND_ID_HANDLER(IDC_ABOUT, OnAbout)
       // CHAIN_MSG_MAP(CPaintBkgndBase)
    END_MSG_MAP()
 
    LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
	    HMENU hm = LoadMenu ( _Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MENU1) );
        SetMenu ( hm );
		hc = ::LoadAccelerators(
			_Module.GetResourceInstance(),  // handle to application instance
			MAKEINTRESOURCE(IDR_ACCELERATOR1)   // address of table-name string
			);

	//	CreateToolbarEx();
	//	UINT hm2 = LoadBar( _Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_TOOLBAR1));
	//	SetMenu(hm2);

		xInit = 50;
        return 0;
    }

    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        DestroyWindow();
        return 0;
    }
 
    LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        PostQuitMessage(0);
        return 0;
    }
	
	LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
	/*	HDC hdc  = ::GetDC(m_hWnd);
		RECT rect;
		::GetClientRect(m_hWnd,&rect);
		int x = rand()%15;
		Ellipse(hdc,rect.left,rect.top,rect.left+x*20,rect.top+x*30);
	*/
		// the paint message can be handle
		return 0;
	}
	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		HDC hdc  = ::GetDC(m_hWnd);
		RECT rect;
		::GetClientRect(m_hWnd,&rect);
		//int x = rand()%15;
		
		POINT pt;
		
		pt.x = LOWORD(lParam);
		pt.y = HIWORD(lParam);

		Ellipse(hdc,pt.x -50,pt.y -50,pt.x+50,pt.y+50);
	
//		Create();
		//		m_spApp.get_Window();

		// the paint message can be handle
		return 0;
	}

	LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
	/*	char a[1]; 
		a[0] = (char)wParam;
		LPCSTR lpText = "(LPCTSTR)a";
		LPCTSTR lpCaption = TEXT("liaozhen");
		UINT uType = 0 ;
		MessageBox(
		//	m_hWnd,          // handle of owner window
			lpText,     // address of text in message box
			lpCaption,  // address of title of message box
			uType      // style of message box
			);*/
		
		HDC hdc  = ::GetDC(m_hWnd);
		RECT rect;
		::GetClientRect(m_hWnd,&rect);
		//int x = rand()%15;
		
		POINT pt;		
		pt.x = rect.left + 100;
		pt.y = rect.top + 150;
		
		char a[2] = "";

		switch(wParam)
		{
		case WM_KEYDOWN:
			Ellipse(hdc,pt.x -50,pt.y -50,pt.x+100,pt.y+50);
			break;
		default:
			char c = (TCHAR) wParam;
			a[0] = c;
			::TextOut(
				hdc,           // handle to device context
				xInit,       // x-coordinate of starting position
				100,       // y-coordinate of starting position
				(LPCTSTR)a,  // pointer to string
				1       // number of characters in string
				);
		}
		xInit += 10;
		return 0;
	}

	void AtlApi(MSG msg)
	{
		while ( GetMessage ( &msg, NULL, 0, 0 ) > 0 )
		{	
			if(!TranslateAccelerator(m_hWnd,hc,&msg))
			{
				TranslateMessage ( &msg );
				DispatchMessage ( &msg );
			}
		}
	}

    LRESULT OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
		HDC hdc  = ::GetDC(m_hWnd);
		RECT rect;
		::GetClientRect(m_hWnd,&rect);
		Ellipse(hdc,rect.left+10,rect.top+10,rect.left+100,rect.top+100);
	    //CAtldlg dlg;
        // dlg.DoModal();
        return 0;
    }

public:
	HACCEL hc;
	int xInit;

	CComPtr<MSWORD::_Application> m_spApp;

};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -