代码改变世界

Visual C++ 2011-5-19

2011-05-20 23:40  Clingingboy  阅读(352)  评论(0编辑  收藏  举报

 

一.单选框分组

用CheckRadioButton函数将一组RadioButton设定为一组,ID为连续的

CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO2);

获取选中的RadioButton

int nID = GetCheckedRadioButton(IDC_RADIO1, IDC_RADIO3);

二.for循环

写法不习惯…

int i = 10;
for (; i>0; i--)
{
    Console.WriteLine(i);
}

三.ScrollWindow(Ex)

对于窗体增加ScrollBar功能

case WM_VSCROLL:
          // Get all the vertial scroll bar information

     si.cbSize = sizeof (si) ;
     si.fMask  = SIF_ALL ;
     GetScrollInfo (hwnd, SB_VERT, &si) ;

          // Save the position for comparison later on

     iVertPos = si.nPos ;

     switch (LOWORD (wParam))
     {
     case SB_TOP:
          si.nPos = si.nMin ;
          break ;
          
     case SB_BOTTOM:
          si.nPos = si.nMax ;
          break ;
          
     case SB_LINEUP:
          si.nPos -= 1 ;
          break ;
          
     case SB_LINEDOWN:
          si.nPos += 1 ;
          break ;
          
     case SB_PAGEUP:
          si.nPos -= si.nPage ;
          break ;
          
     case SB_PAGEDOWN:
          si.nPos += si.nPage ;
          break ;
          
     case SB_THUMBTRACK:
          si.nPos = si.nTrackPos ;
          break ;
          
     default:
          break ;         
     }
          // Set the position and then retrieve it.  Due to adjustments
          //   by Windows it may not be the same as the value set.

     si.fMask = SIF_POS ;
     SetScrollInfo (hwnd, SB_VERT, &si, TRUE) ;
     GetScrollInfo (hwnd, SB_VERT, &si) ;

          // If the position has changed, scroll the window and update it

     if (si.nPos != iVertPos)
     {                    
          ScrollWindow (hwnd, 0, cyChar * (iVertPos - si.nPos), 
                              NULL, NULL) ;
          UpdateWindow (hwnd) ;
     }
     return 0 ;

参考:Windows程序设计 第四章

四.关于IsDialogMessage

http://www.cnblogs.com/Greatest/archive/2009/08/25/1553623.html
http://www.cnblogs.com/lvpengms/archive/2010/02/05/1664721.html