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

📄 happy.cpp

📁 类似qq魔法表情的程序
💻 CPP
字号:
// happy.cpp : Defines the class behaviors for the application.
//modify  by pathfinder (冰雨) 2001年10月23日
//其中还有很多不完美,望与我联系.QQ:40871850;


#include "stdafx.h"
#include "happy.h"

#include "TransparentWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


int res2file(LPCTSTR lpName,LPCTSTR lpType,LPCTSTR filename)
{//将从资源写到文件;
	HRSRC myres=FindResource (NULL,lpName,lpType);
   HGLOBAL gl=LoadResource (NULL,myres);
   LPVOID lp=LockResource(gl);
 HANDLE fp= CreateFile(filename ,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,
	           0,NULL);
 if (!fp)return false;

 DWORD a;
 if (!WriteFile (fp,lp,SizeofResource (NULL,myres),&a,NULL))
	 return false;
 
 CloseHandle (fp);
 FreeResource (gl);
 return true;

}



/////////////////////////////////////////////////////////////////////////////
// CHappyApp

BEGIN_MESSAGE_MAP(CHappyApp, CWinApp)
	//{{AFX_MSG_MAP(CHappyApp)

		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHappyApp construction

CHappyApp::CHappyApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CHappyApp object

CHappyApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CHappyApp initialization

BOOL CHappyApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.

	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
 
	//////////////////////////////////////////////////////////////////
	res2file (MAKEINTRESOURCE(IDR_ZF),"swf","zf.swf");
	 res2file (MAKEINTRESOURCE(IDR_ZG),"swf","zg.swf");
	 res2file (MAKEINTRESOURCE(IDR_DOT),"acs","DOT.ACS");
	 res2file (MAKEINTRESOURCE(IDR_SHARE),"dll","share.dll");
	 res2file (MAKEINTRESOURCE(IDR_TALK),"dll","talk.e");
	 res2file (MAKEINTRESOURCE(IDR_SWFLASH),"ocx","swflash.ocx");
//////////////////////////////////////////////////////////////////////

	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object.
  SetDialogBkColor (RGB(0,0,200),RGB(160,32,172));
	//设置对话框背景色

	// create and load the frame with its resources

	
	////////////////////////////////////////////////////////
HMODULE	hmod=LoadLibrary ("swflash.ocx");
FARPROC  p=GetProcAddress (hmod,"DllRegisterServer");
 (*p)();
 //flash的ocx控件注册。
///////////////////////////////////////////////////////


HANDLE heven =CreateEvent(NULL,false,false,"lsbeven");
	//用于和msagent通信。动画调用share.dll进行置信号.
  
 PROCESS_INFORMATION pi;
	STARTUPINFO si={0};
	si.cb=sizeof(si);

  //si.wShowWindow=SW_SHOW;
 //	si.dwFlags=STARTF_USESHOWWINDOW;
  char *a =new char [255]; 
  char *b=new char [255];
  	GetCurrentDirectory (255,a);
      CString *str=new CString(a);
	  CString  *sou =new CString ;
	  ////////////////////////////////////////
	  (*sou)=*str+CString ("\\DOT.ACS");
 GetWindowsDirectory (b,255);
		 CString  *des =new CString(b) ;
  (*des)+=CString ("\\msagent\\chars");
		 CreateDirectory (des->GetBuffer (10),NULL);
		 *des+=CString ("\\DOT.ACS");
//AfxMessageBox (*des);
//AfxMessageBox (*sou);
CopyFile (sou->GetBuffer (10),des->GetBuffer (10),false);  
*str+=CString("\\talk.e\0"); 
   //vb制作的开场动画。
	BOOL fRet=CreateProcess(NULL,
	                 str->GetBuffer (5),
	                  NULL,
	                  NULL,
	                  FALSE,
	                  0,
	                  NULL,
	                  NULL,
	                  &si,
	                  &pi);
	CString mystr("对不起了!你的机器不支持这个动画!\n\n不过可以看下面的-:");
   if (fRet ==0)
	AfxMessageBox (mystr);
   else{

WaitForSingleObject (heven,40000);
//等待信号被置。40s超时。
CloseHandle(heven);
		 h_pro =pi.hProcess ;
   }
             
 	//////////////////////////////////////////////////////
   TransparentWnd* pFrame = new TransparentWnd;
	m_pMainWnd = pFrame;
	pFrame->CreateTransparent ("生日快乐!",CRect(0,0,100,100));
			pFrame->CenterWindow ();
	pFrame->ShowWindow(SW_SHOW);
          

	// The one and only window has been initialized, so show and update it.

	pFrame->UpdateWindow();


	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CHappyApp message handlers







/////////////////////////////////////////////////////////////////////////////
// CHappyApp message handlers


int CHappyApp::ExitInstance() 
{
DeleteFile ("zf.swf");
DeleteFile ("zg.swf");
DeleteFile ("DOT.ACS");
DeleteFile ("share.dll");
DeleteFile ("talk.e");
DeleteFile ("swflash.ocx");
if (h_pro!=NULL)
TerminateProcess (h_pro ,0);

 	return CWinApp::ExitInstance();
}

BOOL CHappyApp::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CWinApp::PreTranslateMessage(pMsg);
}


⌨️ 快捷键说明

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