Solved

Dialog Box: Faster scrolling

Posted on 1998-12-08
6
314 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

710 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