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

📄 wafuncs.cpp

📁 mp3 频谱分析源码, mp3播放器开发必备源码,
💻 CPP
字号:
#include "stdafx.h"
#include "vis_spectrum.h"

extern VS_PLUGINVARS Plugin;

bool IsPlaying(HWND hWnd)
{
	HWND wa_hWnd = hWnd;
	if(!wa_hWnd) wa_hWnd = FindWindow(WINAMP_CLASS,NULL);
	if(!wa_hWnd) return false;
	// do thing
	LRESULT lResult = SendMessage(wa_hWnd,WM_USER,0,104);
	// winamp is playing
	if(lResult==PLAYING) return true;
	// winamp is not playing
	return false;
}

bool IsPaused(HWND hWnd)
{
	HWND wa_hWnd = hWnd;
	if(!wa_hWnd) wa_hWnd = FindWindow(WINAMP_CLASS,NULL);
	if(!wa_hWnd) return false;
	// do thing
	LRESULT lResult = SendMessage(wa_hWnd,WM_USER,0,104);
	// winamp is paused
	if(lResult==PAUSED) return true;
	// winamp is not paused
	return false;
}

bool KillUpdateTimers(HWND hWnd)
{
	HWND wa_hWnd = hWnd;
	if(!wa_hWnd) wa_hWnd = FindWindow(WINAMP_CLASS,NULL);
	if(!wa_hWnd) return false;
	// knock off the timers
	KillTimer(wa_hWnd,38);
	KillTimer(wa_hWnd,39);
	KillTimer(wa_hWnd,64);
	return true;
}

bool StartUpdateTimers(HWND hWnd)
{
	HWND wa_hWnd = hWnd;
	if(!wa_hWnd) wa_hWnd = FindWindow(WINAMP_CLASS,NULL);
	if(!wa_hWnd) return false;
	// start up the timers
	// start the first timer if it is playing
	if(IsPlaying()||IsPaused()) 
		SetTimer(wa_hWnd,38,100,NULL);
	// start the other timers
	SetTimer(wa_hWnd,39,200,NULL);
	SetTimer(wa_hWnd,64,1000,NULL);
	return true;
}

bool ShowVisWindow(HWND hWnd)
{
	HWND wa_hWnd = hWnd;
	HWND hWndVis = NULL;
	if(!wa_hWnd) wa_hWnd = FindWindow(WINAMP_CLASS,NULL);
	if(!wa_hWnd) return false;
	hWndVis = FindWindowEx(wa_hWnd,NULL,WINAMP_VIS_CLASS,NULL);
	if(!hWndVis) return false;
	return (ShowWindow(hWndVis,SW_SHOW)!=0);	
}

bool HideVisWindow(HWND hWnd)
{
	HWND wa_hWnd = hWnd;
	HWND hWndVis = NULL;
	if(!wa_hWnd) wa_hWnd = FindWindow(WINAMP_CLASS,NULL);
	if(!wa_hWnd) return false;
	hWndVis = FindWindowEx(wa_hWnd,NULL,WINAMP_VIS_CLASS,NULL);
	if(!hWndVis) return false;
	return (ShowWindow(hWndVis,SW_HIDE)!=0);
}


bool BitmapBlt(HDC hDCDest, HBITMAP hBit, int nLeft, int nTop)
{
	bool bRet=false;
	HBITMAP hBitOld;
	BITMAP Bit;
	HDC hDC = CreateCompatibleDC(hDCDest);
	hBitOld = (HBITMAP)SelectObject(hDC,hBit);
	
	GetObject(hBit,sizeof(BITMAP),&Bit);
	bRet = (BitBlt(hDCDest,nLeft,nTop,Bit.bmWidth,Bit.bmHeight,hDC,0,0,SRCCOPY)!=0);
	
	SelectObject(hDC,hBitOld);
	DeleteDC(hDC);


	return bRet;
}

bool BitmapBltEx(HDC hDestDC, HBITMAP hBitmap, int nLeft, int nTop, int nWidth, int nHeight, int nSrcLeft, int nSrcTop)
{
	bool bRet=false;
	HBITMAP hBitOld;
	HDC hDC = CreateCompatibleDC(hDestDC);
	hBitOld = (HBITMAP)SelectObject(hDC,hBitmap);
	
	bRet = (BitBlt(hDestDC, nLeft, nTop, nWidth, nHeight, hDC, nSrcLeft, nSrcTop, SRCCOPY)!=0);

	SelectObject(hDC,hBitOld);
	DeleteDC(hDC);

	return bRet;
}

bool BitmapResBlt(HWND hWnd, int nResID, HDC hDCDest, int nLeft, int nTop)
{
	bool bRet = false;
	HBITMAP hBit = LoadBitmap((HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),MAKEINTRESOURCE(nResID));
	bRet = BitmapBlt(hDCDest,hBit,nLeft,nTop);
	DeleteObject(hBit);
	return bRet;
}

HBITMAP MakeScreenCompatibleBitmap(HBITMAP hBit, int nWidth, int nHeight)
{
	HBITMAP hBitOld;
	HDC hDC = CreateCompatibleDC(NULL);
	hBitOld = (HBITMAP)SelectObject(hDC,hBit);
	
	HBITMAP hRet = CreateCompatibleBitmap(hDC, nWidth, nHeight);

	SelectObject(hDC,hBitOld);
	DeleteDC(hDC);

	return hRet;
}

bool WritePrivateProfileInt(LPCSTR lpszApp, LPCSTR lpszKey, int nValue, LPCSTR lpszFileName)
{
	char szVal[28];
	itoa(nValue,szVal,10);
	return WritePrivateProfileString(lpszApp,lpszKey,szVal,lpszFileName)!=0;

}

⌨️ 快捷键说明

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