Implementing a Gripper in StaticWindows Dialog
-
I’ve noticed that there isn’t a gripper on the StaticWindows Dialog (that little notch in the bottom right corner indicating that the window can be resized). Not important but nice to have. I’ve attempted to implement it on my own by diving into the source code and looking at Gripper.cpp.
In there, I found the function named drawRectangle. The comments hint at it drawing the gripper using an outer and inner rectangle. However, as I went through the code, I struggled to understand the exact implementation. The foundation of this seems to be the use of PATINVERT to draw these rectangles, but the precise manner in which this is achieved is escaping me.
A point of confusion for me is the various rc variables used for sizing. They all appear to be initialized with {}, and I can’t determine where they get their actual data from. When I tried to reimplement the code on my own, the size of the Bitmap remained zero, as I expected.
In my experiments with a custom-defined brush, I found that the brush inherently cannot accommodate more than 8 pixels on the X axis. But maybe i’m wrong here.Is anyone more experienced with bitmaps and can shed some light on this for me? My main goal is to achieve a similar looking gripper it shouldn’t be the same way…
-
I am not certain of this, but I think the gripper implementation you are studying is not for a Windows sizing grip. I haven’t studied it enough to say what it does do, but I’m guessing maybe enhancing the normal function of the window’s title bar so that it can dock and undock the dialog?
A Windows sizing grip is normally implemented using a style flag for a status bar control. Windows draws it and manages interactions with it. I see that Notepad++ uses the SBARS_SIZEGRIP flag, so the ones we see — for example, in the Search dialog — are probably done that way.
I see that as of Windows 7, Windows design guidelines suggest that sizing grips are not needed, though they stop short of recommending against them.
I suggest using the status bar style if your window has a status bar, and not using a size grip if it doesn’t. Implementing one that behaves correctly from scratch is almost certain to be more trouble than it’s worth.
-
Thank you, Coises, for the new perspective.
I must admit, I was perhaps too deep into the implementation. Using styles to address this seems to be a more logical approach. My initial attempts with SBARS_SIZEGRIP didn’t produce the gripper as intended. I’ll continue to comb through the code to find the “right” way to implement this.
Have you tried using the gripper with StatusWindowsDialog in your plugin? Does it work for you? -
@Thomas-Knoefel
I’m afraid I have no useful experience.Since I didn’t plan for any of my dialogs to be dockable, I’m just using ordinary Windows dialogs, built using the resource editor in Visual Studio. Since the resource editor’s toolbox doesn’t offer a status bar control, on the one dialog I have that does show a status line at the bottom, I’m just using a static text control — which means, no sizing grip.
I’m not sure if I could manually edit the .rc file to add a “STATUSBAR” control; I haven’t tried. I assume that would make the dialog uneditable in the resource editor, and I don’t really want that. Maybe someday, if everything else is working so perfectly that that level of polish is the only priority left…