Problem: Dialog Gets Resized Automatically to a Larger Size (C#)

I recently discovered a little bug in Kwapture, a little screen cap app I wrote. The issue was that when the user selected a small area, it would automatically get resized to a larger size.

Yes. Another WTF file entry. Well.. sort of..

The way Kwapture works, is that after you select an area to capture, it creates another dialog over that area that uses the underlying image as a background and allows the user to draw/write on top of that. The dialog is dynamically sized using the size of the rectangle selected by user.

The dialog that is created is essentially blank:

AutoScaleMode = None
ControlBox = Flase
ShowIcon = False
ShowInTaskBar = False

However, I realized that when the user selection was below a certain size, it would always get resized to the same larger size… Approximately like this – the smallest size you can shrink Notepad into:


 Well.. long story short, changing the MinimumSize attribute from 0,0 to 1,1 solves the problem!.

I am guessing that if minimum size is 0,0 there is some pesky if statement that sets the minimum size to accomodate the control box and the icon and does NOT consired the custom value of these properties. But.. that’s just a guess. None the less, WTF.

Hope this helps,