Jump to content

ScrollWindow() funkcija Windows


Recommended Posts

Nesaprotu šīs funkcijas jēgu, tajos piemēros kuros ir parādīts kā to lietot. Piemēram MSDN lapā ( http://msdn.microsoft.com/en-us/library/windows/desktop/hh298421%28v=vs.85%29.aspx ) vai C.Pretzolda programmā sysmets3.c ( http://www.charlespetzold.com/pw5/SysMets3.c ).

Kad WinProc saņem WM_VSCROLL message , tad tieši pirms return 0 ir šāds kods:
 

        // If the position has changed, scroll window and update it.
        if (si.nPos != yPos)
        {                    
           ScrollWindow(hwnd, 0, yChar * (yPos - si.nPos), NULL, NULL);
           UpdateWindow (hwnd);
        }

taču, ScrollWindow funkciju var izņemt un nomainīt pret:
 

    InvalidateRect(hwnd, NULL, TRUE);

jo kad ir WM_PAINT message, tad for loops uzzīmē visu kā vajag vadoties pēc SCROLLINFO struktūras datiem,
iznāk ka šajos piemēros lieki tiek prasīts zīmēt divas reizes - vienu prasa ScrollWindow, kas kautko tikai uzzīmē un for cikls, kas uzzīmē visu:

 

  case WM_PAINT :
        // Prepare the window for painting.
        hdc = BeginPaint (hwnd, &ps);

        // Get vertical scroll bar position.
        si.cbSize = sizeof (si);
        si.fMask  = SIF_POS;
        GetScrollInfo (hwnd, SB_VERT, &si);
        yPos = si.nPos;

        // Get horizontal scroll bar position.
        GetScrollInfo (hwnd, SB_HORZ, &si);
        xPos = si.nPos;

        // Find painting limits.
        FirstLine = max (0, yPos + ps.rcPaint.top / yChar);
        LastLine = min (LINES - 1, yPos + ps.rcPaint.bottom / yChar);
         
        for (i = FirstLine; i <= LastLine; i++)
    {..
    }    

Vai varat izskaidrot šīs funkcijas nozīmi šajā(s) programmā(s) un pielietojumu reālās programmās?
 

Edited by Satan
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...