CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Posts
    79

    Scroll bar not moving

    Hi,
    I have added a scroll bar to one of the splitter windows in my application. I see the scroll bar but it wount move.
    Here is the initialisation

    void CTableView::OnInitialUpdate()
    {
    CView::OnInitialUpdate();

    // TODO: Add your specialized code here and/or call the base class
    CSize sizeTotal;
    // TODO: calculate the total size of this view
    sizeTotal.cx = 180;
    sizeTotal.cy = 1000;
    SetScrollSizes(MM_TEXT, sizeTotal);

    }

    The OnDraw function looks like this,

    void CTableView::OnDraw(CDC* pDC)
    {
    CGsdoc_b1Doc* pDoc = GetDocument();
    // TODO: add draw code here
    RECT rct;
    int textY = 0;
    int textX1 = 0;
    int textX2 = 0;
    int i = 0, j = 0;
    short tmpVal = 0, decimal = 0, integer = 0;
    unsigned char lsbVal = 0, msbVal = 0;
    float floatVal = 0;
    CString strTemp;
    int numTempVal = 0;
    int minute = 0;
    int hour = 0;
    CString strTime;


    ASSERT_VALID(pDoc);
    CPen blackPen;
    blackPen.CreatePen(PS_SOLID,1,RGB(0,0,0));
    CPen* pBlackOldPen = pDC->SelectObject(&blackPen); //Select aPen as pen
    if(pDoc->GetGraphComplete())
    {
    textX1 = 25;
    textX2 = 110;
    textY = 32;
    rct.left = 20;
    rct.top = 30;
    rct.right = 190;
    rct.bottom = 50;

    pDC->Rectangle(&rct);
    pDC->TextOut(textX1, textY,"Tid");
    pDC->TextOut(textX2, textY,"Temperatur");

    numTempVal = (pDoc->m_FileSize-5)/2;

    for(i=0; i<numTempVal; i++)
    {
    rct.top = rct.bottom;
    rct.bottom = rct.bottom + 20;
    textY = textY + 20;

    lsbVal = pDoc->m_FileBuffer[j];
    j++;
    msbVal = pDoc->m_FileBuffer[j];
    j++;
    tmpVal = msbVal << 8; //store and shift up MSB of data value
    tmpVal = tmpVal | lsbVal; //concatenate MSB and LSB
    integer = tmpVal / 10;
    decimal = tmpVal % 10;
    floatVal = decimal*0.1;
    floatVal = integer + floatVal;
    integer = floatVal;
    strTemp.Format("%d", integer);

    minute = pDoc->m_Minute + i;
    hour = pDoc->m_Hour;

    if (minute >= 60)
    {
    hour++;
    minute = minute-60;
    }

    if(hour >= 24)
    {
    hour = hour-24;
    }

    strTime.Format("%d%s%d", hour, ":", minute);
    pDC->Rectangle(&rct);
    pDC->TextOut(textX1,textY, strTime);
    pDC->TextOut(textX2, textY, strTemp);
    }
    pDC->MoveTo(105,30);
    pDC->LineTo(105,rct.bottom);
    }
    }


    Happy for any help.

  2. #2
    Join Date
    Jul 2003
    Posts
    79
    I have seen this topic in an other thread left with no answer. Is'nt there anyone with an idea. Please....

  3. #3
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    What is CTableView?
    What has drawing code to do with your scroll bars problem?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Scroll bar not moving

    Originally posted by martenbengtsson
    I have added a scroll bar to one of the splitter windows in my application. I see the scroll bar but it wount move.
    Here is the initialisation
    How did you add the scroll bar? Note that in order to use SetScrollSizes(), you have to use a CScrollView or CFormView. If you added the scroll bar yourself, you will also have to handle the scrolling messages and do all the required calculations like SetViewPortOrg() etc. yourself.

  5. #5
    Join Date
    Jul 2003
    Posts
    79
    My big misstace was that I did'nt let Visual Studio create a ScrollView class. I tried to do it myself but I must have missed something in the OnScroll handling.

    Next time I let the tool do the jobb, thanks for the reply.

  6. #6
    Join Date
    Mar 2004
    Location
    Phoenix, AZ
    Posts
    15

    Re: Scroll bar not moving

    Try SetWindowOrg, SetWindowExt, SetViewportOrg, SetViewportExt

    Nitti
    Last edited by NittiLin; March 23rd, 2004 at 11:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured