Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy OnVScroll() method enters only once?
    primarykey
    data
    text
    <p>I design a class which derives from CScrollBar in a dialog-based MFC application. In the dialog class (MyScrollbarDlg), I set the <strong>ON_WM_VSCROLL</strong> message and declare the <strong>OnVSCroll</strong> method in the header file. I also Implement the OnVScroll() method in the corresponding .cpp file. But to my surprise, when I click the arrow at the buttom of of the scrollbar, it only did its work at the first time. </p> <p>I want to debug my code, so I set a break point in the OnVScroll method. Then strange thing happened. The break point was only arrived at the first click. When I continue, the scrollbar disappeared from the dialog! I've no idea how this could happen. Could anyone help me to fix this annoying bug? Thank you very much!</p> <p>I have set the scroll range like below:</p> <pre><code> SCROLLINFO scrllInfo; m_scrollbar.GetScrollInfo(&amp;scrllInfo, SIF_ALL); scrllInfo.nMax = 15; scrllInfo.nMin = 0; scrllInfo.nPage = 0; scrllInfo.nPos = 0; m_scrollbar.SetScrollInfo(&amp;scrllInfo, TRUE); </code></pre> <p>btw, I don't use the embedded scrollbar of the dialog, but a scrollbar control which set to be a member of the dialog.</p> <p>I did some experiment and found that the problem I mentioned only occurred when I click the arrow at the bottom of the scrollbar control. It acts well when I click the other arrow or drag the scroll box. Is there anything different when clicking the bottom arrow of a scrollbar which I am not aware of?</p> <p>I figured out that when the scroll message is NOT THUMBPOSITION or THUMBTRACK, the parameter <code>nPos</code> of <code>OnVScroll()</code> method is not used. So I changed my code like this:</p> <pre><code> int currPos = m_scrollbar.GetScrollPos(); m_scrollbar.SetScrollPos(currPos + 1, TRUE); </code></pre> <p>This time it acts normal, but if I set a break point, the scrollbar disappeared again. Do you know why?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload