16,472
社区成员
发帖
与我相关
我的任务
分享
/////////////////////////////////////////////////////////////////////////////
// CPlayerIIIApp:
// See playerIII.cpp for the implementation of this class
//playerIII.h文件中定义的
#define SHOWLIST (WM_USER+140)
#define HIDEMP3 (WM_USER + 141)
#define HIDEOPENMP3 (WM_USER + 142)
#define SHOWMP3WINDOW (WM_USER + 143)
#define VOLMUTE (WM_USER + 144)
BOOL CPlayerIIIApp::InitInstance()
{
// 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.
HWND hWnd;
hWnd = ::FindWindow(TEXT("PLAYER"),NULL);
if(hWnd != NULL)
{
//显示窗口。
::SendMessage (hWnd,ShowWindow(hWnd,SW_SHOW),0,0);//显示窗口
::SendMessage(hWnd,SHOWMP3WINDOW,0,0);//向MP3窗口发消息,让歌曲名,歌曲时控件显示。
::SetWindowPos(hWnd, HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);//顶层
::SendMessage(hWnd,VOLMUTE,0,0);//发送静音控制,得到当前声音
return true;
}
HWND hWnd1;
hWnd1 = ::FindWindow(TEXT("OPENPLAYER"),NULL);
if(hWnd1 != NULL)
{
//显示窗口。
::SendMessage (hWnd1,ShowWindow(hWnd1,SW_SHOW),0,0);//显示窗口
::SetWindowPos(hWnd1, HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);//顶层
return true;
}
CPlayerIIIDlg dlg;
m_pMainWnd = &dlg;
WNDCLASS wc = {0}; //注册类名为PLAY
::GetClassInfo(AfxGetInstanceHandle(),L"Dialog",&wc);
wc.lpszClassName=L"PLAYER";
AfxRegisterClass(&wc);
WNDCLASS wc1 = {0}; //OPENPLAY
::GetClassInfo(AfxGetInstanceHandle(),L"Dialog",&wc1);
wc1.lpszClassName=L"OPENPLAYER";
AfxRegisterClass(&wc1);
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
BOOL CPlayerIIIDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
RegOpenKeyEx(HKEY_CURRENT_USER, gszBaseInstance, 0, 0, &g_hkVolume);
CoInitialize(NULL); //自己加的控制初始化,调用了winx.h文件
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CPlayerIIIDlg::OnHide()
{
// TODO: Add your control notification handler code here
m_test.SetWindowText(_T("hide first!"));
// m_test.ShowWindow(false);
RegCloseKey(g_hkVolume);
this->ShowWindow(SW_HIDE);//隐藏
}
LRESULT CPlayerIIIDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (message == HIDEMP3) //预处理隐藏部分
{
RegCloseKey(g_hkVolume);
this->ShowWindow(SW_HIDE);
}
if (message == SHOWMP3WINDOW)//显示歌曲信息控件。预处理显示
{
m_test.ShowWindow(true);
}
return CDialog::WindowProc(message, wParam, lParam);
}