Saurabh's Blog

Help Integration | Windows Forms | Managed VSIP Integration | Random Rants

  • blogs, bloggers, updates and todos..

    I am not hiding or hibernating, and I have not vanished. You see, the “Paperwork Tango” required to close a real state has been keeping me away. Yes, I have my own place now!!!!.

    I do plan to blog more often. In the meantime, here is an update on what all happened in past few weeks.

    • VS IDE Team blog has gone live.
    • Help & Community Team has created its own blog to provide a way to talk/rant/give suggestions about “Help & Community Integration” in Visual Studio.
    • Marie, the community feature PM/Queen, has started blogging. She owns/rules the community integration in VS and the one to talk about features you would like to have around community.
    • My bio is on MSDN along with other members of the VS Core Team (i.e. my boss’s boss’s boss’s team).

    And to keep one interested, here is what my to-blog list looks like.

    • Key binding, consistency, ease of use and ease of discovering/memorizing: - because everybody else seems to be blogging about it.
    • How I debugged the issue of “no desktop icons or taskbar at startup and running explorer.exe from TaskMgr doesn’t fix it”.
    • Update on VS 2005 Help features (it might happen on Help & Community blog).
    • Managed VSIP integration: - The ambition is to post a walkthrough.
    • Any other compelling idea/rant/solution/suggestions.

  • Saving searches in VS CTP release

    If you have played with Help in CTP, you would have noticed that there Help Favorites has a node called “Searches”. However, it is not discoverable how to store a search. At least, Kevin was not able to find it.You can save a search by

    1. Performing a search.
    2. With Search window focused, click on "Add to Favorites button on the Web/Help toolbar. This is left of web url textbox. This will add your search to the Favorites.
    3. You can now click on the stored search to re-execute a search.

    We know that it is not discoverable and we will fix it soon by adding a “Save Search button (not in the next CTP though). This button will exist next to “Restore Defaults” and “Help Options” commands.

  • Keyboard Shortcut Consistency

    One fine day, I get a call to help in investigating failures in few of the automated tests. After some investigation, we figured that failures were happening because somebody decided to assign “F2” as a keyboard shortcut to build. What is wrong with that? Doesn't it simplify the keyboard shortcut compared to VS 2003's Cntrl+Shift+B? Well, it turns out that F2 is typically used for rename and test was relying on this fact.

    However, tests are not the only ones who rely on facts like this. Most users also assume/wish/want that keyboard shortcuts are consistent across applications (and with the operating system). It reduces the learning curve and makes them more productive. Consider the amount of chaos if Word decided to rebind “Cntl+C” to something other than “Copy”. One should know about “standard” keyboard shortcut before picking one for commands in their application. If a command exposes standard functionality (like copy); it should have a standard shortcut (like Cntl+C). This makes your application consistent with the OS. You can read about various WinXP keyboard shortcuts at http://www.microsoft.com/enable/products/keyboard/keyboardresults.asp?Product=27. You can read about keyboard shortcuts of various applications at Keyboard Assistance site (VS is not on that list :-(). Raymond has also posted a tip on why one should not use “Cntl+Alt” as modifiers. In addition, one should avoid creating of accelerators (or shortcuts) that override system accelerators. It is mentioned in “Accelerator Keystroke Assignment” section in About Keyboard Accelerators.

    I know VS is inconsistent. We have too many shortcuts exposed and we break many rules. Help is really notorious. However, I don’t know if we will fix each one of these instances. There are many legacy issues around it. For e.g., consider the scenario if we fix VS so that F10 activates the menu (essentially what “Alt” does). People will start complaining because we changed keystroke of one of the most used command of VS, the “step” debugger command.

    Hence my advice is more applicable to new application instead of legacy ones as you would be infuriating users by changing the shortcuts without enough justification.

  • RadioButton doesn't resize when you increase the Font size

    Sara forwarded me a customer question asking why radio button doesn’t resize when one changes the font on a Winform’s RadioButton control. Well, the simple answer is that is how underlying Windows control behaves and Winform’s control is just a wrapper on top of it. The next question is that I still want to have big radiobuttons. Well, “UI consistency cop” will say that even if you are able to change all the radiobuttons in your application to be big in size, you would still be inconsistent as your platform has small radiobuttons. However, if you still insist then you would have to

    • Inherit from RadioButton
    • You might have to set DoubleBuffer, AllPaintingInWmPaint and UserPaint ControlStyles to true to reduce the flicker.
    • Override OnPaint and Paint the radio button and text with bigger size. ControlPaint.DrawRadioButton should help you in drawing this. However you won’t get any help in drawing it themed until VS 2005 comes along. VS 2005 has renderers to help you with themed drawing. Until then, you are stuck with pinvoking UxTheme API.
    • I haven’t tried creating this control but I would think that you should able to get away without doing any custom hittesting (however, no guarantees; you are on your own).

    These overridden, oversized controls (RadioButton, CheckBox etc.) are not hard to create. They do however create inconsistency and one should avoid going down that path.

  • Issues around "Hide underline letters ..." checkbox

    Sara talks about effects of “Display Properties -> Appearance -> Effects -> Hide Underline letters ..” . The check box controls two behaviors: - first the underlining of the mnemonics (keyboard accelerators), and second “startup” focus. If that checkbox is checked (which is the default in Win2k+ OSes), Windows shell keeps track of user action and determines if focus and keyboard accelerators should be visible or not. “About Keyboard Accelerators” article on MSDN talks about it (scroll all the way to the bottom, and read the section “UI State”).

     

    Why should one keep this checkbox unchecked?

    Suppose you have a bug with title “Startup focus is not defined on dialog xyz”. You start investigating the issue, and you notice that sometimes focus is present, sometimes it is not. It is very easy to overlook the fact once you used mouse, and at other times, you used keyboard to bring up your dialog. The repro steps in bug will say, “bring up the dialog” and won't say “bring up the dialog using mouse”. You would be scratching your head before you figure out that difference is due to the way of activating the dialog.

     

    Or consider the case, you had this bug and you fixed the issue by defining the start focus, but when it comes to verification, the fix doesn't seem to work because you activated the dialog using mouse. Head banging stuff!! Hence, I always keep this checkbox unchecked and not worry about how I activate my dialog. 

     

    It also saves you time when you are defining mnemonics on your dialog. You don't have to press “Alt” key to see what all labels have mnemonics. A UI scan is sufficient.

     

    I am owner-drawing a control and want to have a consistent behavior. How do I figure out when to paint focus rectangle and when to draw string with mnemonics underlined?

     

    Managed Code: - There are two properties on Control, ShowFocusCues and ShowKeyboardCues, that you should pay attention to. A sample OnPaint function (C#) would look like

     

    protected override void OnPaint(PaintEventArgs e)

    {

    ...

        if (Focused && ShowFocusCues)

       {

            ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);

       }

    ...

    }

     

    To handle Keyboard accelators, you can have code similar to following to define StringFormat that you pass to Graphics.DrawString() method.

     

    StringFormat sf;

    ...

    sf.HotKeyPrefix = (ShowKeyBoardCues) ? HotKeyPrefix.Show : HotKeyPrefix.Hide;

    ...

     

    Native Code: - You can find the UI state by sending WM_QUERYUISTATE message to the control and paint according to the value returned. It is also possible that you might have to pay attention to WM_CHANGEUISTATE and WM_UPDATEUISTATE. Sorry, I don't have any sample code :-(.

     

    Thinking of overriding the default behavior and have focus and accelators visible irrespective of the state of checkbox?

    You should first answer the question “does it makes sense to override the default behavior and become inconsistent w.r.t. the platform (Windows)”? One should have very strong reasons to be UI inconsistent. UI inconsistency reflects badly on your application, confuses your users and leads to usability issues.

     

    Yes, you can override the default behavior. One way is to owner draw everything :-). The other suggestion would be to read about and experiment with WM_CHANGEUISTATE and WM_UPDATEUISTATE on the top-level window (Hint: - If you send WM_CHANGEUISTATE message to the top level window, it sends WM_UPDATEUISTATE message to all the child windows).

     

    Note that overriding ShowFocusCues on your toplevel form and always returning true might give you the impression that you can have focus visible irrespective of the way you activate the dialog (especially if your startup focus is on a LinkLabel). But then try setting startup focus on CheckBox with FlatSytle as System and you would realize that it doesn't work (don't forget to launch using mouse instead of keyboard while experimenting i.e. instead of hitting F5, click Debug->Start). Watch out for these pitfalls.

     

    --

    Cheers,

    Saurabh

     

    PS: - I do know that previous versions of VS (2002, 2003) are not consistent when it comes to keyboard accelators on menus. We have fixed it in VS 2005.

  • Relief from CE Documentation

    I believe that the following is going to be my claim to fame.

    Every Visual C++ developer has a pet peeve about CE documentation convoluting their help experience. There is no hack free foolproof way to get rid of CE documentation, but the following comes asymptotically close.

    Short Answer: - For people who use the “no filter” configuration.

    • Start Visual Studio and do Help->Edit Filters.
    • Click “New”.
    • In the filter definition, copy and paste the following: -

    ("Locale"="kbEnglish") NOT "TargetOS"="WinCE"

    • Click “Save As” and save it as “No CE” (or whatever name you like).
    • Open Help->Index and change the filter to “No CE”.
    • Type “GetWindowText” and hit enter. What happens next is left as an exercise.

    Update: - Simon pointed out that MFC topics still appear with the filter. Ivan Towlson mentioned that above filter removed some C# documentation. Here is an updated filter that fixes these two issues. Note that this filter does not filter CE documentation from C# documentation. However, I believe that it is not a big issue, as CE does not bite C# documentation.

    ((("Locale"="kbEnglish") NOT "TargetOS"="WinCE") NOT "Technology"="MFC") OR ("DocSet" = "C#")

    Long Answer: - Following is a suggestion that I received while I was searching for hacks/ways to get rid of CE documentation.

    You can get rid of WindowCE topics in VS7 and Everett (VS 7.1) by editing your existing filters or creating a new filter (Help->Edit Filters). Try putting an existing filter in parens and then adding NOT "TargetOS"="WinCE" to the end of it. For example, the Visual C++ filter is:

    "DevLang" = "C" OR "DevLang" = "C++" OR "Product" = "VC" OR "DocSet" = "PSDK" OR "DocSet" = "NETFramework" OR ("DocSet" = "kbmsdn" AND "ProductVers" = "kbVC700")

    Modify it to look like:

    ("DevLang" = "C" OR "DevLang" = "C++" OR "Product" = "VC" OR "DocSet" = "PSDK" OR "DocSet" = "NETFramework" OR ("DocSet" = "kbmsdn" AND "ProductVers" = "kbVC700")) NOT "TargetOS"="WinCE"

    This isn’t 100% since not all topics are appropriately annotated, but it’s a start. The most accurate attribute type is “DocSet”. If you look at the existing filters, this will be what you see used the most.

    Note that the NOT operator is a binary operator and not a UNARY operator.

    VS 2005: - The ability to edit filters was removed in VS 2005 using a web page (partly due to IE 6 SP2 changes). For now, the only way to add a new filter is through Help Studio Lite. It is distributed as part of Visual Studio 2005 SDK (it is 185 MB download though:(). With Help Studio Lite on the machine, one can add a filter using the following command line.

    InnovaHxReg.exe /R /F /NameSpace:ms.VSCC.v80 /FilterName:"No CE" /FilterQuery:"((((\"Locale\"=\"kbEnglish\") NOT \"TargetOS\"=\"WinCE
    \") NOT \"Technology\"=\"MFC\") NOT \"Technology\"=\"kbPocketPC\") OR (\"DocSet\" = \"C#\")"

  • Howdy Everybody...

    Hello World, I am developer on Visual Studio's Core IDE team. The following is a short introduction about me.

    Code Monkey Extraordinaire.
    Primary Function: - Help Integration in Visual Studio. (Come on, everybody uses Help, right!)
    Other Expertise: - General shell (IDE) issues, Managed UI (Windows Forms) integration with Visual Studio.
    Previously worked on Visual Studio Analyzer. Did my under graduation from IIT Bombay in Computer Sciences.
    In my free time(!!!!): - Read fiction. Follow Formula 1, cricket, baseball, NFL. Swim. Habitually lurking on XBOX live at 4 am.


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker