WIN32 API之硬件控制

一、Beep  
  The   Beep   function   generates(产生)   simple   tones(音调)   on   the   speaker.   The   function   is   synchronous(同步的);   it   does   not   return   control   to   its   caller   until   the   sound   finishes.    
   
  BOOL   Beep(  
      DWORD   dwFreq,             //   sound   frequency  
      DWORD   dwDuration       //   sound   duration  
  );  
  Parameters  
  dwFreq    
  Windows   NT/   2000:   [in]   Specifies(指定)   the   frequency(频率),   in   hertz,   of   the   sound.   This   parameter   must   be   in   the   range   37   through   32,767   (0x25   through   0x7FFF).    
  dwDuration    
  Windows   NT/   2000:   [in]   Specifies   the   duration(持续时间),   in   milliseconds,   of   the   sound.    
  Return   Values  
  If   the   function   succeeds,   the   return   value   is   nonzero.  
   
  If   the   function   fails,   the   return   value   is   zero.   To   get   extended   error   information,   call   GetLastError.    
   
  Remarks  
  Windows   95:   The   Beep   function   ignores   the   dwFreq   and   dwDuration   parameters.   On   computers   with   a   sound   card,   the   function   plays   the   default   sound   event.   On   computers   without   a   sound   card,   the   function   plays   the   standard   system   beep

 Samples:

void CAboutDlg::OnButton1()
{
 // TODO: Add your control notification handler code here
    // Beep 用于生成简单的声音

 Beep(1000,1); // 发一次1000频率的声音

}

二、ClipCursor(CONST RECT *lpRect)、GetClipCursor(LPRECT lpRect)

设置鼠标活动范围,取得鼠标活动范围。

Samples:

void CAboutDlg::OnButton1()
{
 // TODO: Add your control notification handler code here
    // ActivateKeyboardLayout 激活一个新的键盘布局。键盘布局定义了按键在一种物理性键盘上的位置与含义
 RECT rt;
 rt.left = 30;
 rt.right = 300;
 rt.top = 20;
 rt.bottom = 200;
 ClipCursor(&rt); // 你的光标只能在固定区域啦。
    GetClipCursor(LPRECT lpRect)
}

void CAboutDlg::OnButton2()
{
 // TODO: Add your control notification handler code here
 RECT rt;
 GetClipCursor(&rt);
 CString str;
 str.Format(TEXT("Cursor is in right = %d   buttom = %d"),rt.right,rt.bottom );
 MessageBox(str);
}

建议先调用GetClipCursor()将用户默认的鼠标活动范围取出到全局变量中。之后调用ClipCursor()设置鼠标活动范围。最后再调用一次ClipCursor()恢复用户默认的鼠标活动范围。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值