I have two questions.
1) I found a small gem of code for how to make control scroll smoothly .
Great. But it overrides the WndProc method, so to use it I had to pull out the FlowLayoutPanel, which I dropped onto the form at design time, subclass FlowLayoutPanel, and then finally instantiate a new class and create all the properties manually and change all the links for the this control. Controls ["ControlName"]. (Or, I think, I could create a class level variable that was essentially a control, but how do they allow you to use intellisense on it when it is not declared anywhere?)
So, now I'm just wondering if there really is a way to execute.
Is it possible to do something simple like this, where MainPanel is the name of the control:
MainPanel = (SmoothScrollingFlowLayoutPanel)MainPanel
It can't be that easy, can it? However, this is annoying because I still have to have a subclass (which may be a good design decision, but I would like it to be free of it). Thus, we could put the code in the parent element of the FlowLayoutPanel something like this:
private Delegate void WndProcHandler(ref Message m);
private WndProcHandler w;
public void SomeCode() {
w = MainPanel.WndProc;
MainPanel.WndProc = WndProcSmoothScroll;
}
private void WndProcSmoothScroll(ref Message m) {
if (
(m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
&& (((int)m.WParam & 0xFFFF) == 5)
) {
m.WParam = (IntPtr)(((int)m.WParam & ~0xFFFF) | 4);
}
if (w != null) { w(); }
base.WndProc(ref m);
}
I understand that this is probably quite naive. I view the WndProc method as an event, and it is not.
2) So, the second question: if WndProc was an event instead of a method, how would I do the same - save a copy of the original list of event handlers for the event, set my own event handler to trigger first call all the original event handlers?
BITS INCLUDED
, - , :
m.WParam = (IntPtr)((int)m.WParam ^ 1);
16 5 4, (XOR), AND, OR.