Skip to content

Commit 45befb8

Browse files
authored
Merge pull request #3866 from Vogel612/wtf-vbe
Add Bandaid around VBE WM_SIZE parameters blowing up System.Windows.Size
2 parents 737717d + c5e667c commit 45befb8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Rubberduck.Main/ComClientLibrary/UI/DockableWindowHost.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,13 @@ private void OnCallBackEvent(object sender, SubClassingWindowEventArgs e)
347347
return;
348348
}
349349
var param = new LParam { Value = (uint)e.LParam };
350-
_userControl.Size = new Size(param.LowWord, param.HighWord);
350+
// The VBE passes a special value to the HighWord when docking into the VBE Codepane
351+
// instead of docking into the VBE itself.
352+
// that special value (0xffef) blows up inside the guts of Window management because it's
353+
// apparently converted to a signed short somewhere and then considered "negative"
354+
// that is why we drop the signbit for shorts off our values when creating the control Size.
355+
const ushort signBitMask = 0x8000;
356+
_userControl.Size = new Size(param.LowWord & ~signBitMask, param.HighWord & ~signBitMask);
351357
}
352358

353359
public void AddUserControl(UserControl control, IntPtr vbeHwnd)

0 commit comments

Comments
 (0)