1 PlaySound 播放WAV格式的音乐
This function plays a sound specified by a file name, resource, or system event.
<strong>BOOL WINAPI PlaySound(
LPCSTR</strong> <em><a target=_blank class="synParam" href="http://write.blog.csdn.net/postedit" style="color: rgb(255, 153, 0); text-decoration: none;">pszSound</a></em><strong>,
HMODULE</strong> <em><a target=_blank class="synParam" href="http://write.blog.csdn.net/postedit" style="color: rgb(255, 153, 0); text-decoration: none;">hmod</a></em><strong>,
DWORD</strong> <em><a target=_blank class="synParam" href="http://write.blog.csdn.net/postedit" style="color: rgb(255, 153, 0); text-decoration: none;">fdwSound</a> </em>
<strong>)</strong>;
头文件
播放音乐
-
PlaySound(L"1.wav", NULL, SND_ASYNC | SND_FILENAME );
// SND_ASYNC 异步播放 即: 运行完这一句。直接运行下一条语句 ,播放交由播放器播放着
// SND_SYNC 同步播放 即: 运行这一语句后。先不运行下一条语句。而是等播放器播放完这段音乐后。再运行下一条语句
循环播放
-
PlaySound(currentDirectory, NULL, SND_ASYNC | SND_FILENAME |SND_LOOP);
停止播放
-
PlaySound(NULL, NULL, SND_ASYNC | SND_FILENAME );
2 对话框初始化后立即进行的操作
假设把诸多操作都放在初始化中,那么,对话框须要非常长时间才完毕初始化。 因此。对话框会延迟出现。不能及时蹦出。
方法一 : 设置定时器
方法二:PostMessage() 发送消息 通知初始化完毕
3 更新对话框上 某几个控件的值
-
void UPDATE(){
-
-
UpdateData(FALSE);
-
-
GetDlgItem(IDC_COMBO2)->RedrawWindow();
-
GetDlgItem(IDC_EDIT2)->RedrawWindow();
-
GetDlgItem(IDC_EDIT3)->RedrawWindow();
-
GetDlgItem(IDC_EDIT4)->RedrawWindow();
-
};
4 在屏幕上画图
-
Bitmap bmp(400,100);
-
Graphics grp(&bmp);
-
-
CWindowDC dc(CWnd::GetDesktopWindow());
-
Graphics gDeskTop(dc.GetSafeHdc());
-
grp.FillRectangle(&backBrush,0,0,400,100);
-
-
grp.DrawString(
-
string.GetBuffer(),
-
string.GetLength(),
-
&myFont,
-
rect,
-
&format,
-
&brush );
-
-
-
-
gDeskTop.FillRectangle(&backBrush,0,0,400,100);
-
-
gDeskTop.DrawImage(&bmp,0,0,400,100);
5 check box control 设置选中状态。并将其默认 不能再选择
-
m_CheckButton.SetCheck(1);
-
m_CheckButton.EnableWindow(FALSE);
6 CFileDialog显示两种扩展名
-
CFileDialog dlg(TRUE,NULL,NULL,0,"图片文件(*.jpg;*.bmp)|*.jpg;*.bmp||",this);
7 去掉标题栏的语句
-
-
SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE)&(~(WS_CAPTION | WS_BORDER)));
-
-
::SetWindowPos(m_hWnd, HWND_TOPMOST, -(GetSystemMetrics(SM_CXBORDER)+1),
-
-(GetSystemMetrics(SM_CYBORDER)+1), cx+1,cy+1, SWP_NOZORDER);
-
-
还原标题栏和边框
-
SetWindowLong(this-> GetSafeHwnd(), GWL_STYLE, GetWindowLong(m_hWnd,GWL_STYLE) + (WS_CAPTION|WS_BORDER) );
-
::SetWindowPos(m_hWnd, HWND_TOPMOST, 500, 300, 600,500, SWP_SHOWWINDOW);
8 推断按下CTL+V组合键
-
BOOL CRichEditDlg::PreTranslateMessage(MSG* pMsg)
-
{
-
-
-
if (pMsg->message==WM_KEYDOWN)
-
{
-
if (pMsg->wParam==‘V‘&&(GetKeyState(VK_CONTROL)<0))
-
{
-
OnPaste();
-
return TRUE;
-
}
-
}
-
-
}
转自:http://blog.csdn.net/shuilan0066/article/details/8727113