Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dialog Box: Faster scrolling

Posted on 1998-12-08
6
Medium Priority
?
316 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 60 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

705 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