当前位置: 首页>>代码示例>>C++>>正文


C++ SetScrollRange函数代码示例

本文整理汇总了C++中SetScrollRange函数的典型用法代码示例。如果您正苦于以下问题:C++ SetScrollRange函数的具体用法?C++ SetScrollRange怎么用?C++ SetScrollRange使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetScrollRange函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BeepDiaProc

/*********************************************************************************************
 *
 * This is the dialog procedure for the beep dialog.
 *
 *      Message:                Action:
 *      ========                =======
 *      WM_INITDIALOG           initialize beep duration and frequency
 *      WM_CLOSE                end this dialog
 *      WM_PAINT                display text strings under each scroll bar to represent
 *                              the value of the slider
 *      WM_HSCROLL              adjust scroll bars and duration/frequency values
 *      WM_COMMAND              ID_BEEPNOW:  beep with the specified frequency/duration
 *                              ID_DONE: dismiss dialog box
 *
 *********************************************************************************************/
BOOL WINAPI BeepDiaProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{

        char lpstrOutString[256];        // string used to display text in dialog box
    RECT rect;
    HDC hdc;                                         // device context for painting
    PAINTSTRUCT ps;                          // paint structure for painting
    SIZE mySize;                 // used to place text in dialog box
    ULONG ulDlgUnitsToPixels;        // used to place text in dialog box
    static LONG ulBeepDuration; // beep duration - selected by slider
    static LONG ulBeepFreq;     // beep frequency - selected by slider
    LONG *pscrollpos;           // current slider value
    int id;                      // determines which slider
    char *templateStringMS = "Selected Value: %5d ms   ";
    char *templateStringHZ = "Selected Value: %5d hz   ";

    switch (messg) {
        /*
         * WM_INITDIALOG: initialize duration and frequency variables
         */
        case WM_INITDIALOG:
            ulBeepDuration = MINDURATION;
            ulBeepFreq = MINFREQ;
            break;
        /*
         * WM_CLOSE: Dismiss this dialog
         */
        case WM_CLOSE:
            EndDialog(hDlg,FALSE);
            break;
        /*
         * WM_PAINT: Determine position in dialog box for text output and
                 *           put the text strings there
         */
        case WM_PAINT:
            hdc = BeginPaint(hDlg,&ps);
            ulDlgUnitsToPixels = GetDialogBaseUnits();
            sprintf(lpstrOutString,templateStringHZ,ulBeepFreq*FREQSTEP);
            TextOut(hdc,(40*LOWORD(ulDlgUnitsToPixels))/4,(40*HIWORD(ulDlgUnitsToPixels))/8,lpstrOutString,strlen(lpstrOutString));
            sprintf(lpstrOutString,templateStringMS,ulBeepDuration*DURATIONSTEP);
            TextOut(hdc,(40*LOWORD(ulDlgUnitsToPixels))/4,(100*HIWORD(ulDlgUnitsToPixels))/8,lpstrOutString,strlen(lpstrOutString));
            EndPaint(hDlg,&ps);
            break;
        /*
         * WM_HSCROLL: handle horizontal scrolling.  For all scroll
         *             messages, determine which scroll bar this is (via GetDlgCtrlId)
         *             and set a pointer to the scroll value (pscrollpos).
         */
        case WM_HSCROLL:
            ulDlgUnitsToPixels = GetDialogBaseUnits();
            id = GetDlgCtrlID((HWND)lParam);
            hdc = GetDC(hDlg);
            GetTextExtentPoint(hdc,templateStringHZ,strlen(templateStringHZ),&mySize);
            DeleteDC(hdc);
            if (id==ID_FREQBAR) {
                SetScrollRange((HWND)lParam,SB_CTL,MINFREQ,MAXFREQ,TRUE);
                pscrollpos = &ulBeepFreq;
                rect.top = (40*HIWORD(ulDlgUnitsToPixels))/8;
                rect.bottom = rect.top + mySize.cy;
                rect.left = (40*LOWORD(ulDlgUnitsToPixels))/4;
                rect.right = rect.left + mySize.cx;
            } else {
                SetScrollRange((HWND)lParam,SB_CTL,MINDURATION,MAXDURATION,TRUE);
                pscrollpos = &ulBeepDuration;
                rect.top = (100*HIWORD(ulDlgUnitsToPixels))/8;
                rect.bottom = rect.top + mySize.cy;
                rect.left = (40*LOWORD(ulDlgUnitsToPixels))/4;
                rect.right = rect.left + mySize.cx;
            }
            switch(LOWORD(wParam)) {
                /*
                 * SB_LINERIGHT: user incremented by 1.  Update scroll
                 *               position and redraw.
                 */
                case SB_LINERIGHT:
                    (*pscrollpos)++;
                    if ((id==ID_FREQBAR) && (*pscrollpos > MAXFREQ)) {
                       *pscrollpos = MAXFREQ;
                    } else if ((id==ID_DURBAR) && (*pscrollpos > MAXDURATION)){
                       *pscrollpos = MAXDURATION;
                    }
                    SetScrollPos((HWND)lParam,SB_CTL,*pscrollpos,TRUE);
                    break;
                /*
                 * SB_LINELEFT: user decremented by 1.  Update scroll
//.........这里部分代码省略.........
开发者ID:MbqIIB,项目名称:DEV-SAMPLES-IBM_Dev_Toolkit_Samples,代码行数:101,代码来源:hiworld.c

示例2: SetScrollRange

void TScrollBar::set_range(int rmin, int rmax, bool repaint/*=false*/)
{
  SetScrollRange(m_hwnd,m_type,rmin,rmax,repaint);
}
开发者ID:Artorios,项目名称:rootkit.com,代码行数:4,代码来源:twl.cpp

示例3: WndProc

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static int          nLineCount,lineNo;
    static int          cyClient, cxChar, cyChar;
    static int          xScroll;
    static HGLOBAL      hResource;
    static HWND         hwndScroll;
    static HWND         hScroll;

    CHAR        *szText;
    HINSTANCE   hInstance;
    HDC         hdc;
    PAINTSTRUCT ps;
    RECT        clientRect;
    int         i;

    switch(msg)
    {
    case WM_CREATE:
        hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
        lineNo = 0;
        //Load Text resource
        hResource = LoadResource(hInstance, FindResource(hInstance, TEXT("ANNABELLEE"), TEXT("TEXT")));
        szText = (CHAR *)LockResource(hResource);

        //Create Scrollbar
        hScroll = CreateWindow(TEXT("scrollbar"), NULL, SB_VERT | WS_CHILD | WS_VISIBLE, 
                    0, 0, 0, 0,
                    hwnd, (HMENU)1, hInstance, NULL);
        //calculate line count
        while(*szText != '\0' && *szText != '\\')
        {
            if (*szText == '\n')
                ++nLineCount;
            szText = AnsiNext(szText);
        }
        *szText == '\0';

        //Get char size
        cxChar = LOWORD(GetDialogBaseUnits());
        cyChar = HIWORD(GetDialogBaseUnits());
        xScroll = GetSystemMetrics(SM_CXVSCROLL);

        //Setup scroll 
        SetScrollRange(hScroll, SB_CTL, 0, nLineCount, TRUE);
        SetScrollPos(hScroll, SB_CTL, 0, TRUE);
        break;
    case WM_SIZE:
        {
            MoveWindow(hScroll, LOWORD(lParam) - xScroll, 0, xScroll, HIWORD(lParam), TRUE); 
            cyClient = HIWORD(lParam);
            SetFocus(hScroll);
            break;
        }
    case WM_SETFOCUS:
        {
            SetFocus(hScroll);
            break;
        }
    case WM_VSCROLL:
        {
            switch(wParam)
            {
                case SB_TOP:
                    lineNo = 0;
                    break;
                case SB_BOTTOM:
                    lineNo = nLineCount;
                    break;
                case SB_LINEDOWN:
                    lineNo++;
                    break;
                case SB_LINEUP:
                    lineNo--;
                    break;
                case SB_PAGEDOWN:
                    lineNo += cyClient / cyChar;
                    break;
                case SB_PAGEUP:
                    lineNo -= cyClient / cyChar;
                    break;
                default:
                    break;
            }
            lineNo = max(0, lineNo);
            lineNo = min(lineNo, nLineCount);
            SetScrollPos(hScroll, SB_CTL, lineNo, TRUE);
            InvalidateRect(hwnd, NULL, TRUE);
            break;
        }
    case WM_PAINT:
        {
            hdc = BeginPaint(hwnd, &ps);
            GetClientRect(hwnd, &clientRect);
            clientRect.left += cxChar;
            clientRect.top += cyChar*(1 - lineNo);
            szText = (CHAR *)LockResource(hResource);
            DrawTextA(hdc, szText, -1, &clientRect, DT_TOP); 
            EndPaint(hwnd, &ps);
            break;
//.........这里部分代码省略.........
开发者ID:CharlesGeng,项目名称:study-c,代码行数:101,代码来源:POEPOEM.c

示例4: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static int  cxChar, cxCaps, cyChar, cyClient, iVscrollPos ;
     HDC         hdc ;
     int         i, y ;
     PAINTSTRUCT ps ;
     TCHAR       szBuffer[10] ;
     TEXTMETRIC  tm ;

     switch (message)
     {
     case WM_CREATE:
          hdc = GetDC (hwnd) ;

          GetTextMetrics (hdc, &tm) ;
          cxChar = tm.tmAveCharWidth ;
          cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
          cyChar = tm.tmHeight + tm.tmExternalLeading ;

          ReleaseDC (hwnd, hdc) ;

          SetScrollRange (hwnd, SB_VERT, 0, NUMLINES - 1, FALSE) ;
          SetScrollPos   (hwnd, SB_VERT, iVscrollPos, TRUE) ;
          return 0 ;

     case WM_SIZE:
          cyClient = HIWORD (lParam) ;
          return 0 ;

     case WM_VSCROLL:
          switch (LOWORD (wParam))
          {
          case SB_LINEUP:
               iVscrollPos -= 1 ;
               break ;
     
          case SB_LINEDOWN:
               iVscrollPos += 1 ;
               break ;
     
          case SB_PAGEUP:
               iVscrollPos -= cyClient / cyChar ;
               break ;
     
          case SB_PAGEDOWN:
               iVscrollPos += cyClient / cyChar ;
               break ;
     
          case SB_THUMBPOSITION:
               iVscrollPos = HIWORD (wParam) ;
               break ;
     
          default :
               break ;
          }

          iVscrollPos = max (0, min (iVscrollPos, NUMLINES - 1)) ;

          if (iVscrollPos != GetScrollPos (hwnd, SB_VERT))
          {
               SetScrollPos (hwnd, SB_VERT, iVscrollPos, TRUE) ;
               InvalidateRect (hwnd, NULL, TRUE) ;
          }
          return 0 ;

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
     
          for (i = 0 ; i < NUMLINES ; i++)
          {
               y = cyChar * (i - iVscrollPos) ;
     
               TextOut (hdc, 0, y,
                        sysmetrics[i].szLabel,
                        lstrlen (sysmetrics[i].szLabel)) ;
     
               TextOut (hdc, 22 * cxCaps, y,
                        sysmetrics[i].szDesc,
                        lstrlen (sysmetrics[i].szDesc)) ;
     
               SetTextAlign (hdc, TA_RIGHT | TA_TOP) ;
     
               TextOut (hdc, 22 * cxCaps + 40 * cxChar, y, szBuffer,
                        wsprintf (szBuffer, TEXT ("%5d"),
                             GetSystemMetrics (sysmetrics[i].iIndex))) ;
     
               SetTextAlign (hdc, TA_LEFT | TA_TOP) ;
          }
          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
开发者ID:joway,项目名称:WindowsProgrammingNotes,代码行数:97,代码来源:SysMets2.c

示例5: WinProc

LRESULT CALLBACK WinProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) {
    PAINTSTRUCT Ps;
    static HWND hWndList;
    static HWND hWndScroll, hWndWidthScroll, hWndHeightScroll;
    static RECT rcScroll, rcTODOList, rcInputTODO, rcQuantity;
    HBRUSH hBrushStatic;



    SetRect(&rcScroll, 315, 40, 25, 150);
    SetRect(&rcTODOList, 10, 10, 100, 40);
    SetRect(&rcInputTODO, 120, 150, 190, 25);
    SetRect(&rcQuantity, 210, 10, 300, 30);


    switch(msg) {
    case WM_CREATE: {

                //Create Scrolls
                hWndScroll = CreateWindowEx((DWORD)NULL,
                    TEXT("scrollbar"),
                    NULL,
                    WS_CHILD | WS_VISIBLE | SBS_VERT,
                    315, 40, 25, 150,
                    hWnd,
                    (HMENU) ID_SCROLL_BAR,
                    hInstance,
                    NULL);
                SetScrollRange(hWndScroll,SB_CTL, 0, 255, FALSE);
                SetScrollPos(hWndScroll, SB_CTL, 0, TRUE);

                hWndWidthScroll = CreateWindowEx((DWORD)NULL,
                    TEXT("scrollbar"),
                    NULL,
                    WS_CHILD | WS_VISIBLE | SBS_HORZ,
                    10, 230, 300, 20,
                    hWnd,
                    (HMENU)ID_WIDTH_SCROLL,
                    hInstance,
                    NULL);
                SetScrollRange(hWndWidthScroll, SB_CTL, 0, 100, TRUE);
                SetScrollPos(hWndWidthScroll, SB_CTL, 0, TRUE);

                hWndHeightScroll = CreateWindowEx((DWORD)NULL,
                    TEXT("scrollbar"),
                    NULL,
                    WS_CHILD | WS_VISIBLE | SBS_HORZ,
                    10, 260, 300, 20,
                    hWnd,
                    (HMENU)ID_HEIGHT_SCROLL,
                    hInstance,
                    NULL);
                SetScrollRange(hWndHeightScroll, SB_CTL, 0, 100, TRUE);
                SetScrollPos(hWndHeightScroll, SB_CTL, 45, TRUE);

                /**
                * Create ListBox
                */

                hWndList = CreateWindowEx((DWORD)NULL,
                    TEXT("listbox"),
                    "",
                    WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | LBS_STANDARD | WS_BORDER,
                    10, 40,
                    300, 100,
                    hWnd,
                    (HMENU) IDC_TODO_LIST,
                    hInstance,
                    NULL);


                /**
                * Create AddTODO Button
                */
                HFONT hFont = CreateFont(30,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                    CLIP_DEFAULT_PRECIS,NULL, VARIABLE_PITCH,TEXT("Impact"));

                HWND hButtonAddTODO = CreateWindowEx(NULL,
                    "BUTTON",
                    "Add a task",
                    WS_TABSTOP|WS_VISIBLE|
                    WS_CHILD|BS_DEFPUSHBUTTON|BS_TOP,
                    10,
                    150,
                    100,
                    25,
                    hWnd,
                    (HMENU)BUTTON_ADD_TODO,
                    GetModuleHandle(NULL),
                    NULL);

                /**
                * Create button ShowTODONumber
                */
                HWND hShowTODONumber = CreateWindowEx(NULL,
                    "BUTTON",
                    "Display a message",
                    WS_TABSTOP|WS_VISIBLE|
                    WS_CHILD|BS_DEFPUSHBUTTON|BS_TOP,
                    10,
//.........这里部分代码省略.........
开发者ID:TUM-FAF,项目名称:FAF-121-Macrinici-Daniel,代码行数:101,代码来源:main.cpp

示例6: WinMain

int WINAPI WinMain(	HINSTANCE hinstance,
					HINSTANCE hprevinstance,
					LPSTR lpcmdline,
					int ncmdshow)
{

WNDCLASS winclass;	// this will hold the class we create
HWND	 hwnd;		// generic window handle
MSG		 msg;		// generic message
HDC      hdc;       // generic dc
PAINTSTRUCT ps;     // generic paintstruct

// first fill in the window class stucture
winclass.style			= CS_DBLCLKS | CS_OWNDC | 
                          CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc	= WindowProc;
winclass.cbClsExtra		= 0;
winclass.cbWndExtra		= 0;
winclass.hInstance		= hinstance;
winclass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor		= LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName	= NULL; 
winclass.lpszClassName	= WINDOW_CLASS_NAME;

// register the window class
if (!RegisterClass(&winclass))
	return(0);

// create the window, note the use of WS_POPUP
if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class
						  "DirectSound WAV File Loading DEMO",	 // title
						  WS_OVERLAPPEDWINDOW | WS_VISIBLE,
					 	  0,0,	   // x,y
						  WINDOW_WIDTH,  // width
                          WINDOW_HEIGHT, // height
						  NULL,	   // handle to parent 
						  NULL,	   // handle to menu
						  hinstance,// instance
						  NULL)))	// creation parms
return(0);

// save the window handle and instance in a global
main_window_handle = hwnd;
main_instance      = hinstance;

// create some scroll controls to change volume, frequency
// and panning

// create the volume control scroller
volume_hwnd = CreateWindow("SCROLLBAR", // class
						  "",	    // title
						  WS_CHILD | WS_VISIBLE,
					 	  80,40,	    // x,y
						  160,       // width
                          16,      // height
						  hwnd,	    // handle to parent 
						  NULL,	    // handle to menu
						  hinstance,// instance
						  NULL);    // creation parms

// create the frequency control scroller
freq_hwnd = CreateWindow("SCROLLBAR", // class
						  "",	    // title
						  WS_CHILD | WS_VISIBLE,
					 	  80,100,	    // x,y
						  160,       // width
                          16,      // height
						  hwnd,	    // handle to parent 
						  NULL,	    // handle to menu
						  hinstance,// instance
						  NULL);    // creation parms

// create the stereo panning control scroller
pan_hwnd = CreateWindow("SCROLLBAR", // class
						  "",	    // title
						  WS_CHILD | WS_VISIBLE,
					 	  80,160,	// x,y
						  160,      // width
                          16,       // height
						  hwnd,	    // handle to parent 
						  NULL,	    // handle to menu
						  hinstance,// instance
						  NULL);    // creation parms


// set range and value of each scroll bar
SetScrollRange(volume_hwnd, SB_CTL, 0, 4000,TRUE);
SetScrollPos(volume_hwnd, SB_CTL,0,TRUE);

SetScrollRange(freq_hwnd, SB_CTL, 0, 50000,TRUE);
SetScrollPos(freq_hwnd, SB_CTL,11000,TRUE);

SetScrollRange(pan_hwnd, SB_CTL, 0, 20000,TRUE);
SetScrollPos(pan_hwnd, SB_CTL,10000,TRUE);

// perform all game console specific initialization
// start up the directsound sound
Game_Init();

//.........这里部分代码省略.........
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:101,代码来源:demo10_3.cpp

示例7: SetIcon

BOOL CScreenSpyDlg::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
	
	SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_NO));
	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		pSysMenu->AppendMenu(MF_SEPARATOR);
		pSysMenu->AppendMenu(MF_STRING, IDM_CONTROL, "控制屏幕(&Y)");
		pSysMenu->AppendMenu(MF_STRING, IDM_SEND_CTRL_ALT_DEL, "发送Ctrl-Alt-Del(&K)");
		pSysMenu->AppendMenu(MF_STRING, IDM_TRACE_CURSOR, "跟踪服务端鼠标(&T)");
		pSysMenu->AppendMenu(MF_STRING, IDM_BLOCK_INPUT, "锁定服务端鼠标和键盘(&L)");
		pSysMenu->AppendMenu(MF_STRING, IDM_BLANK_SCREEN, "服务端黑屏(&B)");
		pSysMenu->AppendMenu(MF_STRING, IDM_CAPTURE_LAYER, "捕捉层(导致鼠标闪烁)(&L)");
		pSysMenu->AppendMenu(MF_STRING, IDM_SAVEDIB, "保存快照(&S)");
		pSysMenu->AppendMenu(MF_SEPARATOR);
		pSysMenu->AppendMenu(MF_STRING, IDM_GET_CLIPBOARD, "获取剪贴板(&R)");
		pSysMenu->AppendMenu(MF_STRING, IDM_SET_CLIPBOARD, "设置剪贴板(&L)");
		pSysMenu->AppendMenu(MF_SEPARATOR);
		pSysMenu->AppendMenu(MF_STRING, IDM_ALGORITHM_SCAN, "隔行扫描算法(&S)");
		pSysMenu->AppendMenu(MF_STRING, IDM_ALGORITHM_DIFF, "差异比较算法(&X)");
		pSysMenu->AppendMenu(MF_SEPARATOR);
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_1, "1 位黑白(&A)");
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_4_GRAY, "4 位灰度(&B)");
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_4_COLOR, "4 位彩色(&C)");
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_8_GRAY,  "8 位灰度(&D)");
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_8_COLOR, "8 位彩色(&E)");
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_16, "16位高彩(&F)");
		pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_32, "32位真彩(&G)");		
		
		pSysMenu->CheckMenuRadioItem(IDM_ALGORITHM_SCAN, IDM_ALGORITHM_DIFF, IDM_ALGORITHM_SCAN, MF_BYCOMMAND);
		pSysMenu->CheckMenuRadioItem(IDM_DEEP_4_GRAY, IDM_DEEP_32, IDM_DEEP_8_COLOR, MF_BYCOMMAND);
	}
	
	// TODO: Add extra initialization here
	CString str;
	str.Format("\\\\%s %d * %d", m_IPAddress, m_lpbmi->bmiHeader.biWidth, m_lpbmi->bmiHeader.biHeight);
	SetWindowText(str);

	m_HScrollPos = 0;
	m_VScrollPos = 0;
	m_hRemoteCursor = LoadCursor(NULL, IDC_ARROW);

	ICONINFO CursorInfo;
	::GetIconInfo(m_hRemoteCursor, &CursorInfo);
	if (CursorInfo.hbmMask != NULL)
		::DeleteObject(CursorInfo.hbmMask);
	if (CursorInfo.hbmColor != NULL)
		::DeleteObject(CursorInfo.hbmColor);
	m_dwCursor_xHotspot = CursorInfo.xHotspot;
	m_dwCursor_yHotspot = CursorInfo.yHotspot;

	m_RemoteCursorPos.x = 0;
	m_RemoteCursorPos.x = 0;
	m_bIsTraceCursor = false;

	// 初始化窗口大小结构
	m_hDC = ::GetDC(m_hWnd);
	m_hMemDC = CreateCompatibleDC(m_hDC);
	m_hFullBitmap = CreateDIBSection(m_hDC, m_lpbmi, DIB_RGB_COLORS, &m_lpScreenDIB, NULL, NULL);
	SelectObject(m_hMemDC, m_hFullBitmap);
	SetScrollRange(SB_HORZ, 0, m_lpbmi->bmiHeader.biWidth);  
	SetScrollRange(SB_VERT, 0, m_lpbmi->bmiHeader.biHeight);

	InitMMI();
	SendNext();
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
开发者ID:52piaoyu,项目名称:gh0st,代码行数:75,代码来源:ScreenSpyDlg.cpp

示例8: DoWindowMessage

long FAR PASCAL DoWindowMessage ( 
   HWND hMain,
   unsigned message,
   WPARAM wParam,
   LONG lParam)

{  switch ( message )
   {  case WM_CREATE:
	 return (StartUpDDE());

      case WM_KEYDOWN:
		{  if ( LOWORD(wParam) == VK_SHIFT )
	 {  extern int ShiftKeyDown;
	    ShiftKeyDown = TRUE;
	 }
	 break;
      }

      case WM_KEYUP:
      {  if ( LOWORD(wParam) == VK_SHIFT )
	 {  extern int ShiftKeyDown;
	    ShiftKeyDown = FALSE;
	 }
	 break;
      }

      case WM_CHAR:
      {  GetUserCmd ( LOWORD(wParam), FALSE, 0 );
	 break;
      }

      case WM_ACTIVATEAPP:
		{   extern int ApplicationFocus;
	  ApplicationFocus = (int) LOWORD(wParam);
	  if (!ApplicationFocus )
		  UpdateCursor( ARROW_CURSOR );
	  break;
      }

      case WM_TIMER:
      {  static int value = 0;
	 extern HCURSOR NowCursor, WAIT[];
	 extern int ApplicationFocus;
	 value ++;
	 NowCursor = WAIT[value];
	 if (ApplicationFocus )
	    SetCursor ( NowCursor );
	 if (value > 7 )
	   value = 0;
	 break;
      }

      case WM_SETCURSOR:
      {  extern HCURSOR NowCursor;
	 SetCursor ( NowCursor );
	 break;
		}

      case WM_SETFOCUS:
		{  extern SCREEN WinDialog;
	 CreateCaret ( hMain, NULL, 1, WinDialog.LineSize);
	 ShowCaret ( hMain );
	 break;
      }

      case WM_KILLFOCUS:
      {  HideCaret ( hMain );
	 DestroyCaret();
	 break;
      }

		case WM_PAINT:
      {  PAINTSTRUCT ps;
	 HDC  hDC;
 
	 BeginPaint (hMain, (LPPAINTSTRUCT)&ps);
	    hDC = ps.hdc;
	    SetMapMode (hDC, MM_TEXT);
	    RedrawTerminal(hDC);
	    ValidateRect (hMain, (LPRECT)NULL);
	 EndPaint (hMain, (LPPAINTSTRUCT)&ps);
	 break;
      }

      case WM_SIZE:
      {  extern SCREEN WinDialog;
	 int min, max;

	 GetScrollRange (hMain,SB_VERT,&min, &max);
	 WinDialog.NoLines = (HIWORD (lParam) / WinDialog.LineSize) - 1;
	 SetScrollRange (hMain, SB_VERT, WinDialog.NoLines, max, TRUE );

	 InvalidateRect ( hMain, NULL, TRUE );
	 switch ( LOWORD(wParam) )
	 {  case SIZE_MINIMIZED:
			 PostMessage ( hMain, WM_COMMAND, IDC_WIN_MINIMIZE, 0);
	       break;

	    case SIZE_RESTORED:
	       PostMessage ( hMain, WM_COMMAND, IDC_WIN_MAXIMIZE, 0);
//.........这里部分代码省略.........
开发者ID:ahmed-masud,项目名称:FuzzyCLIPS,代码行数:101,代码来源:diag_win.c

示例9: RedrawTerminal

void RedrawTerminal ( 
	HDC hDC)

{  extern SCREEN WinDialog;
	int x, max, min, pos, start, sbmax = 0;
	RECT Rect;
	char *buffer;
   
   /*----------------------------------------------+
   | Get current value of the vertical scroll bar. |
   +----------------------------------------------*/
   GetScrollRange ( WinDialog.hWnd, SB_VERT, &min, &max);
	pos = GetScrollPos (WinDialog.hWnd, SB_VERT );

   /*-----------------------------------------+
	| Locate the first visible line to display |
   +-----------------------------------------*/
   start = WinDialog.LastLine - ( max - pos ) - WinDialog.NoLines;

   if ( start == WinDialog.LastLine )
      start ++;

   /*----------------------------------------------+
   | If the start value is negative then check if  |
	| at a 'hard' top or if a wrap around is needed |
   +----------------------------------------------*/
   if ( start < 0 )
	{  if ( max == DIALOG_SIZE )
	 start = max + start + 1;
      else
	 start = 0;
   }

   /*------------------------------------------+
   | Get Position of the horizontal scroll bar |
   +------------------------------------------*/
	pos = GetScrollPos ( WinDialog.hWnd, SB_HORZ);

   /*----------------------------------------------------------+
	| Loop to display text in the visible portion of the screen |
   +----------------------------------------------------------*/
   for ( x = 0; x<= WinDialog.NoLines && Terminal[start] != NULL; x++ )
	{
	 int bufsize;

      GetClientRect (WinDialog.hWnd, &Rect);
      Rect.top = x * WinDialog.LineSize;

      /*------------------------------------+
      | Calculate Horizontal Scroll bar Max | 
		| based on what is displayed.         |
      +------------------------------------*/
      
		if (Terminal[start] != NULL)
	{ bufsize = strlen(Terminal[start]); }
      else
	{ bufsize = 0; }

      if ( bufsize > sbmax )  sbmax = bufsize;

      /*-----------------------------------+
      | Display each line of text adjusted |
		| for the horizontal scroll bar.     |
      +-----------------------------------*/
      buffer = NULL;
		if (( pos <= bufsize ) && (Terminal[start] != NULL))
      {  buffer = Terminal[start]+pos;
	 DrawText ( hDC, buffer, -1, &Rect, DT_LEFT|DT_NOCLIP | DT_NOPREFIX );
      }

      /*-------------------------------+
      | Check if wrap around is needed |
      +-------------------------------*/
      start ++;
		if ( start > DIALOG_SIZE )
	 start = 0;
   }
	/*-------------------------------------+
   | Calculate and display caret adjusted |
   |    for horizontal scroll bar.        |
   +-------------------------------------*/
   if ( buffer == NULL )
      buffer = "";
	DrawText ( hDC, buffer, -1, &Rect,
	          DT_LEFT|DT_NOCLIP|DT_CALCRECT );
	SetCaretPos (Rect.right, Rect.top);
	SetScrollRange ( WinDialog.hWnd, SB_HORZ, 0, sbmax-1, TRUE );
}
开发者ID:ahmed-masud,项目名称:FuzzyCLIPS,代码行数:88,代码来源:diag_win.c

示例10: TrebuchetFormBuilder


//.........这里部分代码省略.........
	g_nSBy = (UserSettings.ClientHeight - nPadding) - DEFBUT_HEIGHT - TAB_CHAT_HEIGHT;

	// Duration timer position
	nTDBx = nPadding;
	nTDBy = (UserSettings.ClientHeight - nPadding) - abs(nPadding / 2) - TAB_CHAT_HEIGHT;
	nTDBwidth = UserSettings.ClientWidth - (nPadding * 2) - DEFBUT_WIDTH;
	nTDBheight = nPadding;

	// Minimum range edit box
	memset(buffer, 0, sizeof(buffer));
	_snprintf(buffer, sizeof(buffer)-1, "%lu", UserSettings.TrebMin);
	GlobalSettings.hTrebMinEdit = CreateWindow(
		TEXT("edit"), NULL,
		WS_CHILDWINDOW | WS_VISIBLE | ES_RIGHT | WS_BORDER | ES_AUTOHSCROLL,
		nMinX, nRangeY, nRangeWidth, nRangeHeight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	hMinStatic = CreateWindow(
		TEXT("static"), "Minimum",
		WS_CHILD | SS_EDITCONTROL,
		nSMinX, nRangeStaticY, nRangeStaticWidth, nRangeHeight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	SendMessage(GlobalSettings.hTrebMinEdit, EM_SETLIMITTEXT, (WPARAM)MAXRNG, 0);
	SendMessage(GlobalSettings.hTrebMinEdit, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);
	SendMessage(GlobalSettings.hTrebMinEdit, WM_SETTEXT, 0, (LPARAM)buffer);
	SendMessage(hMinStatic, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);

	// Maximum range edit box
	memset(buffer, 0, sizeof(buffer));
	_snprintf(buffer, sizeof(buffer)-1, "%lu", UserSettings.TrebMax);
	GlobalSettings.hTrebMaxEdit = CreateWindow(
		TEXT("edit"), NULL,
		WS_CHILDWINDOW | ES_RIGHT | WS_BORDER | ES_AUTOHSCROLL,
		nMaxX, nRangeY, nRangeWidth, nRangeHeight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	hMaxStatic = CreateWindow(
		TEXT("static"), "Maximum",
		WS_CHILD | SS_EDITCONTROL,
		nSMaxX, nRangeStaticY, nRangeStaticWidth, nRangeHeight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	SendMessage(GlobalSettings.hTrebMaxEdit, EM_SETLIMITTEXT, (WPARAM)MAXRNG, 0);
	SendMessage(GlobalSettings.hTrebMaxEdit, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);
	SendMessage(GlobalSettings.hTrebMaxEdit, WM_SETTEXT, 0, (LPARAM)buffer);
	SendMessage(hMaxStatic, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);

	// Scroll bar
	GlobalSettings.hTrebSliderBar = CreateWindow(
		TEXT("scrollbar"), NULL,
		WS_CHILD | WS_VISIBLE | SBS_HORZ,
		nTSCBx, nTSCBy, nTSCBwidth, nTSCBheight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	SetScrollRange(GlobalSettings.hTrebSliderBar, SB_CTL, UserSettings.TrebMin, UserSettings.TrebMax, FALSE);
	SetScrollPos(GlobalSettings.hTrebSliderBar, SB_CTL, UserSettings.TrebRange, FALSE);

	// Value readout
	GlobalSettings.hTrebSliderValue = CreateWindow(
		TEXT("static"), "Range: 0.00",
		WS_CHILD | WS_VISIBLE | SS_EDITCONTROL,
		nTVRx, nTVRy, nTVRwidth, nTVRheight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	memset(buffer, 0, sizeof(buffer));
	_snprintf(buffer, sizeof(buffer)-1, "Range: %.2f", (((float)(UserSettings.TrebRange - UserSettings.TrebMin) / (float)(UserSettings.TrebMax - UserSettings.TrebMin)) * 100) );
	SendMessage(GlobalSettings.hTrebSliderValue, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);
	SendMessage(GlobalSettings.hTrebSliderValue, WM_SETTEXT, 0, (LPARAM)buffer);

	// Recharge edit box
	memset(buffer, 0, sizeof(buffer));
	_snprintf(buffer, sizeof(buffer)-1, "%lu", UserSettings.TrebRecharge);
	GlobalSettings.hTrebRecharge = CreateWindow(
		TEXT("edit"), NULL,
		WS_CHILDWINDOW | ES_RIGHT | WS_BORDER | ES_AUTOHSCROLL,
		nPadding, nRechargeY, nRechargeWidth, nRechargeHeight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	hRechargeStatic = CreateWindow(
		TEXT("static"), "Recharge",
		WS_CHILD | SS_EDITCONTROL,
		nRechargeStaticX, nRechargeStaticY, nRechargeStaticWidth, nRangeHeight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	SendMessage(GlobalSettings.hTrebRecharge, EM_SETLIMITTEXT, (WPARAM)MAXRNG, 0);
	SendMessage(GlobalSettings.hTrebRecharge, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);
	SendMessage(GlobalSettings.hTrebRecharge, WM_SETTEXT, 0, (LPARAM)buffer);
	SendMessage(hRechargeStatic, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);

	// Start button
	GlobalSettings.hTrebStartButton = CreateWindow(
		TEXT("button"), "Start",
		WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
		nTSBx, g_nSBy, nTSBwidth, nTSBheight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	SendMessage(GlobalSettings.hTrebStartButton, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);

	// Duration box
	GlobalSettings.hTrebDurationBox = CreateWindow(
		TEXT("static"), "Runtime: 0.00s",
		WS_CHILD | WS_VISIBLE | SS_EDITCONTROL,
		nTDBx, nTDBy, nTDBwidth, nTDBheight,
		GlobalSettings.hMainWindow, NULL, GlobalSettings.hInstance, NULL);
	SendMessage(GlobalSettings.hTrebDurationBox, WM_SETFONT, (WPARAM)GlobalSettings.hFont, 0);

	return 1;
}
开发者ID:hippiechic,项目名称:GSiege,代码行数:101,代码来源:Trebuchet.c

示例11: GetUserCmd

void GetUserCmd ( 
  WORD wParam,      /* Key Code */
  BOOL ScreenOnly,  /* Send to Screen and or Command Buffer */
  int  InputSize)   /* Number of characters send to screen only */

  {
	extern int HorizScroll; /* Automatic Scrolling Enabled/Disabled */

	switch (wParam)
	  {
		extern SCREEN WinDialog;
		extern int UserInput;

		/*------------------+
		| Handle Back Space |
		+------------------*/

		case VK_BACK:
		  {
			/*-----------------------------------------------+
			| Init Values when sending to the command buffer |
			+-----------------------------------------------*/
			if (! ScreenOnly)
			  {
				HorizScroll = 1;
				if (GetCommandString() != NULL)
				  { InputSize = strlen(GetCommandString()); }
				else
				  { InputSize = 0; }
			  }

	 if (InputSize > 0 )
	 {
		 int size;

		 if (Terminal[WinDialog.LastLine] != NULL)
			{ size = strlen(Terminal[WinDialog.LastLine]); }
		 else
			{ size = 0; }

		 if (!ScreenOnly)
			 ExpandCommandString ('\b');

		 if (size > 0)
			 Terminal[WinDialog.LastLine][size - 1] = '\0';
		 else
		 {  int min, max;
			 extern int OldLine;

			 if ( Terminal[WinDialog.LastLine] != NULL )
			 {
		free(Terminal[WinDialog.LastLine]);
		Terminal[WinDialog.LastLine] = NULL;
	       }

			 WinDialog.LastLine --;
	       OldLine --;

	       if ( WinDialog.LastLine < 0 )
		  WinDialog.LastLine = DIALOG_SIZE;

	       GetScrollRange (WinDialog.hWnd, SB_VERT, &min, &max);
	       if ( WinDialog.NoLines < max && max < DIALOG_SIZE )
	       {  SetScrollRange ( WinDialog.hWnd, SB_VERT, WinDialog.NoLines, max-1, FALSE );
		  SetScrollPos   ( WinDialog.hWnd, SB_VERT, max-1, FALSE );
	       }
	       InvalidateRect ( WinDialog.hWnd, NULL, TRUE );
		 }
		 SendToScreen();
	 }
	 break;
      }

      /*--------------------------+
      | Remove Special Keys (ALT) |
      +--------------------------*/
      case '\f':
      case VK_MENU:
	 break;


      /*----------------+
      | Handle Tab Keys |
      +----------------*/
      case '\t':
		{  if ( !ScreenOnly)
	 {  if ( GetCommandString() == NULL)
	       SetCommandString("   ");
	    else
	       AppendCommandString("   ");
	 }
	 PrintCLIPS ("stdout", "   " );
	 break;
      }


      /*---------------------+
      | Return / Newline Key |
      +---------------------*/
      case '\r':
//.........这里部分代码省略.........
开发者ID:ahmed-masud,项目名称:FuzzyCLIPS,代码行数:101,代码来源:diag_win.c

示例12: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static CHOOSEFONT cf ;
     static int        iPage ;
     static LOGFONT    lf ;
     HDC               hdc ;
     int               cxChar, cyChar, x, y, i, cxLabels ;
     PAINTSTRUCT       ps ;
     SIZE              size ;
     TCHAR             szBuffer [8] ;
     TEXTMETRIC        tm ;
     WCHAR             ch ;

     switch (message)
     {
     case WM_CREATE:
          hdc = GetDC (hwnd) ;
          lf.lfHeight = - GetDeviceCaps (hdc, LOGPIXELSY) / 6 ;  // 12 points
          lstrcpy (lf.lfFaceName, TEXT ("Lucida Sans Unicode")) ;
          ReleaseDC (hwnd, hdc) ;

          cf.lStructSize = sizeof (CHOOSEFONT) ;
          cf.hwndOwner   = hwnd ;
          cf.lpLogFont   = &lf ;
          cf.Flags       = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS ;

          SetScrollRange (hwnd, SB_VERT, 0, 255, FALSE) ;
          SetScrollPos   (hwnd, SB_VERT, iPage,  TRUE ) ;
          return 0 ;

     case WM_COMMAND:
          switch (LOWORD (wParam))
          {
          case IDM_FONT:
               if (ChooseFont (&cf))
                    InvalidateRect (hwnd, NULL, TRUE) ;
               return 0 ;
          }
          return 0 ;

     case WM_VSCROLL:
          switch (LOWORD (wParam))
               {
               case SB_LINEUP:         iPage -=  1 ;  break ;
               case SB_LINEDOWN:       iPage +=  1 ;  break ;
               case SB_PAGEUP:         iPage -= 16 ;  break ;
               case SB_PAGEDOWN:       iPage += 16 ;  break ;
               case SB_THUMBPOSITION:  iPage = HIWORD (wParam) ;  break ;

               default:
                    return 0 ;
               }

          iPage = max (0, min (iPage, 255)) ;

          SetScrollPos (hwnd, SB_VERT, iPage, TRUE) ;
          InvalidateRect (hwnd, NULL, TRUE) ;
          return 0 ;

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          SelectObject (hdc, CreateFontIndirect (&lf)) ;

          GetTextMetrics (hdc, &tm) ;
          cxChar = tm.tmMaxCharWidth ;
          cyChar = tm.tmHeight + tm.tmExternalLeading ;

          cxLabels = 0 ;

          for (i = 0 ; i < 16 ; i++)
          {
               wsprintf (szBuffer, TEXT (" 000%1X: "), i) ;
               GetTextExtentPoint (hdc, szBuffer, 7, &size) ;

               cxLabels = max (cxLabels, size.cx) ;
          }

          for (y = 0 ; y < 16 ; y++)
          {
               wsprintf (szBuffer, TEXT (" %03X_: "), 16 * iPage + y) ;
               TextOut (hdc, 0, y * cyChar, szBuffer, 7) ;

               for (x = 0 ; x < 16 ; x++)
               {
                    ch = (WCHAR) (256 * iPage + 16 * y + x) ;
                    TextOutW (hdc, x * cxChar + cxLabels,
                                   y * cyChar, &ch, 1);
               }
          }

          DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT)));
          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
//.........这里部分代码省略.........
开发者ID:Jeanhwea,项目名称:petzold-pw5e,代码行数:101,代码来源:Unichars.c

示例13: ITextHostImpl_TxSetScrollRange

DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxSetScrollRange(ITextHost *iface, INT fnBar, LONG nMinPos, INT nMaxPos,
                                           BOOL fRedraw)
{
    ITextHostImpl *This = impl_from_ITextHost(iface);
    return SetScrollRange(This->hWnd, fnBar, nMinPos, nMaxPos, fRedraw);
}
开发者ID:RareHare,项目名称:reactos,代码行数:6,代码来源:txthost.c

示例14: WndProc

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int  cxChar, cxCaps, cyChar, cyClient,
        iVscrollPos = 0, //竖直滑块当前位置
        row_num,
        col_num = 8;
    static wchar_t** data;
    static wchar_t* text;
    HDC         hdc;
    int         i, y;
    PAINTSTRUCT ps;
    TCHAR       szBuffer[10];
    TEXTMETRIC  tm;

    switch (message)
    {
    case WM_CREATE:
        hdc = GetDC(hwnd);
        GetTextMetrics(hdc, &tm);
        cyChar = tm.tmHeight + tm.tmExternalLeading;//字体高度
        ReleaseDC(hwnd, hdc);

        text = getFileContent();
        row_num = (int)ceil((double)wcslen(text) / col_num);
        data = (wchar_t**)malloc(sizeof(wchar_t*) * (row_num));
        SetScrollRange(hwnd, SB_VERT, 0, row_num - 1, FALSE);//范围
        SetScrollPos(hwnd, SB_VERT, iVscrollPos, TRUE);//初始位置
        return 0;

    case WM_SIZE:
        cyClient = HIWORD(lParam);
        return 0;

    case WM_VSCROLL:
        switch (LOWORD(wParam))
        {
        case SB_LINEUP://点滚动条上方的小箭头
            iVscrollPos -= 1;
            break;

        case SB_LINEDOWN://点滚动条下方的小箭头
            iVscrollPos += 1;
            break;

        case SB_PAGEUP://在滚动条上方点空白位置
            iVscrollPos -= cyClient / cyChar;
            break;

        case SB_PAGEDOWN://在滚动条下方点空白位置
            iVscrollPos += cyClient / cyChar;
            break;

        case SB_THUMBPOSITION://在滚动条上松开鼠标
            iVscrollPos = HIWORD(wParam);//这里用上了wParam
            break;

        default:
            break;
        }

        iVscrollPos = max(0, min(iVscrollPos, row_num - 1));

        if (iVscrollPos != GetScrollPos(hwnd, SB_VERT))//获取当前的位置
        {
            SetScrollPos(hwnd, SB_VERT, iVscrollPos, TRUE);//更新数值
            InvalidateRect(hwnd, NULL, TRUE);//刷新界面
        }
        return 0;

    case WM_PAINT:
        hdc = BeginPaint(hwnd, &ps);

        for (i = 0; i < row_num; i++) {
            y = cyChar * (i - iVscrollPos);
            *(data + i) = (wchar_t*)malloc(sizeof(wchar_t) * (col_num + 1));
            wcsncpy_s(*(data + i), col_num + 1, text + col_num * i, col_num);
            if (i != row_num - 1) {
                TextOut(hdc, 0, y, *(data + i), col_num);
            } else {
                if (!wcslen(text) % col_num) {
                    TextOut(hdc, 0, y, *(data + i), wcslen(text) % col_num);
                }
                else {
                    TextOut(hdc, 0, y, *(data + i), col_num);
                }
            }
        }
        EndPaint(hwnd, &ps);
        return 0;

    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
开发者ID:zhouyang209117,项目名称:CppTutorial,代码行数:96,代码来源:C14Vscroll.c

示例15: WindowProcedure

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    // Child windows' handles
    static HWND hwndListBox, hwndNewItem, hwndAddButton, hwndRemoveButton, hwndClearButton, hwndHeightScroll, hwndWidthScroll;
    static HINSTANCE hInstance;

    // Size and position variables
    int iSysWidth;
    int iSysHeight;
    int iWinWidth;
    int iWinHeight;

    int iWidth  = 60;   // Button width
    int iHeight = 30;   // Button height
    int x;
    int y;

    int i, cxChar, cyChar;

    // Menu & menu items
    HMENU hMenu;
    HMENU hSubMenu;

    // String
    char* szText;
    int iTextLength;

    // Paint and size structs
    TEXTMETRIC tm;
    SCROLLINFO si;
    HBRUSH brush;
    RECT rect, rct;
    int color;
    HDC hdc;


    hdc = GetDC(hwnd);
    GetTextMetrics(hdc, &tm);
    cxChar = tm.tmAveCharWidth;
    cyChar = tm.tmHeight;
    ReleaseDC(hwnd, hdc);

    switch(message) {

        case WM_CREATE:
            hwndListBox = CreateWindowEx(
                (DWORD)NULL,
                TEXT("ListBox"),
                NULL,
                WS_CHILD | WS_VISIBLE | WS_BORDER | LBS_NOTIFY | LBS_WANTKEYBOARDINPUT,
                0, 0, 0, 0, hwnd,
                (HMENU)IDC_LIST_BOX,
                hProgramInstance,
                NULL);

            hwndNewItem = CreateWindowEx(
                (DWORD)NULL,
                TEXT("Edit"),
                TEXT("Input candidates"),
                WS_CHILD | WS_VISIBLE | WS_BORDER |ES_AUTOVSCROLL | ES_AUTOHSCROLL,
                0, 0, 0, 0, hwnd,
                (HMENU)IDC_NEW_ITEM,
                hProgramInstance,
                NULL);

            hwndWidthScroll = CreateWindow(
                "Scrollbar",
                NULL,
                WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_BOTTOMALIGN,
                0, 0, 0, 0, hwnd,
                (HMENU)IDC_WIDTH_SCROLL,
                hProgramInstance,
                NULL);
            SetScrollRange(hwndWidthScroll, SB_CTL, 0, 100, FALSE);
            SetScrollPos(hwndWidthScroll, SB_CTL, 0, FALSE);

            hwndHeightScroll = CreateWindow(
                "Scrollbar",
                NULL,
                WS_CHILD | WS_VISIBLE | SBS_VERT | SBS_BOTTOMALIGN,
                0, 0, 0, 0, hwnd,
                (HMENU)IDC_HEIGHT_SCROLL,
                hProgramInstance,
                NULL);
            SetScrollRange(hwndHeightScroll, SB_CTL, 0, 100, TRUE);
            SetScrollPos(hwndHeightScroll, SB_CTL, 0, FALSE);

            hwndAddButton = CreateWindowEx(
                (DWORD)NULL,
                TEXT("Button"),
                TEXT("Add"),
                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                0, 0, 0, 0, hwnd,
                (HMENU)IDC_ADD_BUTTON,
                hProgramInstance,
                NULL);

            hwndRemoveButton = CreateWindowEx(
                (DWORD)NULL,
                TEXT("Button"),
                TEXT("Remove"),
//.........这里部分代码省略.........
开发者ID:TUM-FAF,项目名称:FAF-141-Croitoru-Vlad,代码行数:101,代码来源:main.cpp


注:本文中的SetScrollRange函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。