www.pudn.com > 截取程序消息的DLL和使用例子GetMSG.rar > mpeg_playDlg.cpp


// mpeg_playDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "mpeg_play.h" 
#include "mpeg_playDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
#define WM_KULER (WM_USER+1101) 
#define WM_ELSE (WM_USER+1102) 
///////////////////////////////////////////////////////////////////////////// 
// CMpeg_playDlg dialog 
 
CMpeg_playDlg::CMpeg_playDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CMpeg_playDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CMpeg_playDlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
} 
 
void CMpeg_playDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CMpeg_playDlg) 
	DDX_Control(pDX, IDL_MSG, m_listMsg); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CMpeg_playDlg, CDialog) 
	//{{AFX_MSG_MAP(CMpeg_playDlg) 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_WM_CLOSE() 
	//}}AFX_MSG_MAP 
	ON_MESSAGE(WM_KULER,OnKuler) 
	ON_MESSAGE(WM_KULER,OnElse) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CMpeg_playDlg message handlers 
typedef int (WINAPI *FUNC_InstGetMsg)(BOOL fInstall, char *pclass, char *pcaption, UINT msg, HWND hWnd); 
FUNC_InstGetMsg InstGetMsg =NULL; 
HMODULE g_hMod =NULL; 
 
BOOL CMpeg_playDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
	g_hMod =LoadLibrary("getmsg.dll"); 
	if(g_hMod ==NULL) 
	{ 
		MessageBox("LoadLibrary getmsg.dll failed"); 
		EndDialog(0); 
		return FALSE; 
	} 
	if((InstGetMsg =(FUNC_InstGetMsg)GetProcAddress(g_hMod, "InstGetMsg")) ==NULL) 
	{ 
		MessageBox("GetProcAddress InstGetMsg failed"); 
		EndDialog(0); 
		return FALSE; 
	} 
 
	(*InstGetMsg)(TRUE,/*"#32770"*/"Notepad", "", WM_COMMAND, m_hWnd); 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
	 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CMpeg_playDlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CMpeg_playDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
BOOL CMpeg_playDlg::OnCommand(WPARAM wParam, LPARAM lParam)  
{ 
	if(wParam ==ID_CLEAR) 
	{ 
		m_listMsg.ResetContent(); 
		return TRUE; 
	} 
	/* 
	if(wParam !=IDOK && wParam!=IDCANCEL) 
	{ 
		char temp[256]; 
 
		wsprintf(temp, "[%d] wParam:%d, lParam:%d", m_listMsg.GetCount(), wParam, (int)lParam); 
		m_listMsg.InsertString(0, temp); 
 
		return TRUE; 
	} 
	*/ 
	return CDialog::OnCommand(wParam, lParam); 
} 
void CMpeg_playDlg::OnElse(WPARAM wParam, LPARAM lParam) 
{ 
	char temp[256]; 
 
	wsprintf(temp, "其他类 [%d] wParam:%d, lParam:%d", m_listMsg.GetCount(), wParam, (int)lParam); 
	m_listMsg.InsertString(0, temp); 
} 
void CMpeg_playDlg::OnKuler(WPARAM wParam, LPARAM lParam) 
{ 
	char temp[256]; 
 
	wsprintf(temp, "command类 [%d] wParam:%d, lParam:%d", m_listMsg.GetCount(), wParam, (int)lParam); 
	m_listMsg.InsertString(0, temp); 
} 
void CMpeg_playDlg::OnClose()  
{ 
	if(InstGetMsg) (*InstGetMsg)(FALSE, NULL, NULL, 0, NULL); 
	if(g_hMod) FreeLibrary(g_hMod); 
	 
	CDialog::OnClose(); 
}