Solved

Dialog Box: Faster scrolling

Posted on 1998-12-08
6
310 Views
Last Modified: 2012-06-21
Hi,

I have written some code to implement scrolling within my dialog box, but is is very slow because I have over 100 controls in there. My code is below. What I am looking for is for a much faster and more robust piece of code to implement scrolling.

#########################################################
void DPRMYLDHKDdlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
      // TODO: Add your message handler code here and/or call default
      //##S

      int mdown = -450;
      int      mup = 450;
            
      #define      NUM_CTRL 109
      static      hkdidc[NUM_CTRL]={IDC_HkdFxRateSTATIC1,
      IDC_HkdCcySTATIC1,IDC_HkdValDateSTATIC1,IDC_HkdFxRateEDIT1,
      IDC_HkdCcyEDIT1,IDC_HkdValDateEDIT1,IDC_HkdStDcSTATIC1,
      IDC_HkdFutDcSTATIC1,IDC_HkdLtDcSTATIC1,IDC_HkdStDcEDIT1,
      IDC_HkdFutDcEDIT1,IDC_HkdLtDcEDIT1,IDC_HkdStBaseSTATIC1,
      IDC_HkdFutBaseSTATIC1,IDC_HkdLtBaseSTATIC1,IDC_HkdStBaseEDIT1,
      IDC_HkdFutBaseEDIT1,IDC_HkdLtBaseEDIT1,IDOK,
      IDC_HkdNumSTATIC1,IDC_HkdTenorSTATIC1,IDC_HkdInstruSTATIC1,
      IDC_HkdBidSTATIC1,IDC_HkdAskSTATIC1,IDC_HkdMidSTATIC1,
      IDC_HkdNum1STATIC1,IDC_HkdTenorEDIT1,IDC_HkdInstruEDIT1,
      IDC_HkdBidEDIT1,IDC_HkdAskEDIT1,IDC_HkdMidEDIT1,
      IDC_HkdNum2STATIC1,IDC_HkdTenorEDIT2,IDC_HkdInstruEDIT2,
      IDC_HkdBidEDIT2,IDC_HkdAskEDIT2,IDC_HkdMidEDIT2,
      IDC_HkdNum3STATIC1,IDC_HkdTenorEDIT3,IDC_HkdInstruEDIT3,
      IDC_HkdBidEDIT3,IDC_HkdAskEDIT3,IDC_HkdMidEDIT3,
      IDC_HkdNum4STATIC1,IDC_HkdTenorEDIT4,IDC_HkdInstruEDIT4,
      IDC_HkdBidEDIT4,IDC_HkdAskEDIT4,IDC_HkdMidEDIT4,
      IDC_HkdNum5STATIC1,IDC_HkdTenorEDIT5,IDC_HkdInstruEDIT5,
      IDC_HkdBidEDIT5,IDC_HkdAskEDIT5,IDC_HkdMidEDIT5,
      IDC_HkdNum6STATIC1,IDC_HkdTenorEDIT6,IDC_HkdInstruEDIT6,
      IDC_HkdBidEDIT6,IDC_HkdAskEDIT6,IDC_HkdMidEDIT6,
      IDC_HkdNum7STATIC1,IDC_HkdTenorEDIT7,IDC_HkdInstruEDIT7,
      IDC_HkdBidEDIT7,IDC_HkdAskEDIT7,IDC_HkdMidEDIT7,
      IDC_HkdNum8STATIC1,IDC_HkdTenorEDIT8,IDC_HkdInstruEDIT8,
      IDC_HkdBidEDIT8,IDC_HkdAskEDIT8,IDC_HkdMidEDIT8,
      IDC_HkdNum9STATIC1,IDC_HkdTenorEDIT9,IDC_HkdInstruEDIT9,
      IDC_HkdBidEDIT9,IDC_HkdAskEDIT9,IDC_HkdMidEDIT9,
      IDC_HkdNum10STATIC1,IDC_HkdTenorEDIT10,IDC_HkdInstruEDIT10,
      IDC_HkdBidEDIT10,IDC_HkdAskEDIT10,IDC_HkdMidEDIT10,
      IDC_HkdNum11STATIC1,IDC_HkdTenorEDIT11,IDC_HkdInstruEDIT11,
      IDC_HkdBidEDIT11,IDC_HkdAskEDIT11,IDC_HkdMidEDIT11,
      IDC_HkdNum12STATIC1,IDC_HkdTenorEDIT12,IDC_HkdInstruEDIT12,
      IDC_HkdBidEDIT12,IDC_HkdAskEDIT12,IDC_HkdMidEDIT12,
      IDC_HkdNum13STATIC1,IDC_HkdTenorEDIT13,IDC_HkdInstruEDIT13,
      IDC_HkdBidEDIT13,IDC_HkdAskEDIT13,IDC_HkdMidEDIT13,
      IDC_HkdNum14STATIC1,IDC_HkdTenorEDIT14,IDC_HkdInstruEDIT14,
      IDC_HkdBidEDIT14,IDC_HkdAskEDIT14,IDC_HkdMidEDIT14};

      CRect      hkdrect[NUM_CTRL];
      CWnd      *hkdpCtrl[NUM_CTRL];
      int i;
      for      (i = 0; i < NUM_CTRL; i++) {
            hkdpCtrl[i]=GetDlgItem(hkdidc[i]);
      }




      switch (nSBCode)
      {
            
      case SB_BOTTOM:

            break;

      case SB_TOP:

            break;

      case SB_PAGEDOWN:

            break;

      case SB_PAGEUP:

            break;

      case SB_LINEDOWN:

            for      (i = 0; i < NUM_CTRL; i++) {
                  hkdpCtrl[i]->GetWindowRect(&hkdrect[i]);
                  ScreenToClient(&hkdrect[i]);
                  hkdrect[i] += CPoint (0,mdown);
                  hkdpCtrl[i]->MoveWindow(hkdrect[i]);
            }
            //UpdateData(FALSE);
            Invalidate();


    break;

      case SB_LINEUP:

            for      (i = 0; i < NUM_CTRL; i++) {
                  hkdpCtrl[i]->GetWindowRect(&hkdrect[i]);
                  ScreenToClient(&hkdrect[i]);
                  hkdrect[i] += CPoint (0,mup);
                  hkdpCtrl[i]->MoveWindow(hkdrect[i]);
            }
            //UpdateData(FALSE);
            Invalidate();



            break;

      case SB_THUMBPOSITION:
            
            break;
      }
      //##E

      CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
##########################################################

Rgds,
A.
0
Comment
Question by:decornez
6 Comments
 
LVL 6

Accepted Solution

by:
stsanz earned 20 total points
ID: 1179531
Use BeginDeferWindowPos/EndDeferWindowPos WIN32 APIs to move simultaneously all your controls.




0
 
LVL 22

Expert Comment

by:nietod
ID: 1179532
Also associated with that, specify the flag that prevents the moved window from redrawing (I don't remember what it is called) and then scroll the window with ScrollWindow()  This will update the screen much faster.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1179533
You probably mean the WM_SETREDRAW message.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:nietod
ID: 1179534
No, I meant the DWP_NOTREDRAW flag to the DeferWindowPos() procedure.  It is much faster for the OS to move the windows without updating the screen and then just scroll the pixels on screen and finally just paint the small area exposed.
0
 

Author Comment

by:decornez
ID: 1179535
Going off on holiday until the 17th of dec.

I will try your suggestions when I get back and will let you know then.

Thanks,
A.
0
 

Author Comment

by:decornez
ID: 1179536
Stanz,

Thanks for your help.
I actually used Nietod's suggestion. I used ScrollWindow() in conjunction with UpdateWindow(). It is extremely fast, easy to implement, and there is no flickering.

Nietod,

Thanks for your suggestion.
I'll post some points for you.

Rgds,
A.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 134
c++ getting the first 10 characters of a char* string 11 90
basic hardware to learn oop advanced design patterns 3 88
Problem with SqlConnection 4 160
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now