Menu

Old OWL - How to insert the Help icon in a TMDIChild

2022-10-02
2022-10-06
  • Gianni Rossi

    Gianni Rossi - 2022-10-02

    Hi All,
    As some of you knows, I'm still maintaining a very large BC++ 5.02 OWL application even though I'm planning to migrate it to OwlNext in the near future.

    In the mean time, I would like to add the Help icon in my TMDIChild windows in order to open the user context help guide from that command:

    MDIChild

    If I recall well, this should be possible in old OWL but I can't find how to do it, so any help would be grateful appreciated.

    Thanks.

    Gianni

     

    Last edit: Gianni Rossi 2022-10-02
  • Ognyan Chernokozhev

    You should need to set the WS_EX_CONTEXTHELP extended windows style.

    Since BC5.02 is quite old, it may not have the definition for this style, but the value is 0x00000400L, so you can define it on your own, something like:

    #if !defined(WS_EX_CONTEXTHELP)
    #define WS_EX_CONTEXTHELP       0x00000400L
    #endif
    

    You can use either TWindow::SetExStyle or TWindow::ModifyExStyle to set the extended style.

     
    👍
    1
  • Gianni Rossi

    Gianni Rossi - 2022-10-03

    Thanks Jogy,
    I followed your suggestion and tried to call SetExStyle in my TMDIChild::SetupWindow but the help icon doesn't appear.
    As for ModifyExStyle, the old OWL guide simply show its signature here below without any explanation of the arguments:

    bool ModifyExStyle(uint32 offBits, uint32 onBits, uint swpFlags = 0);
    

    So I don't know how to call it.
    Would you be so kind as to post a code sample on how to reach my goal?

    Thanks in advance.
    Gianni

     
    • Ognyan Chernokozhev

      Hi,

      According to the documentation:

      WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.

      So, if you have those styles, you need to first clear them.
      This can be done for example in the constructor.

      Then in SetupWindow you can set the WS_EX_CONTEXTHELP style.

      Here is a simple BC5.02 example:

      #if !defined(WS_EX_CONTEXTHELP)
      #define WS_EX_CONTEXTHELP       0x00000400L
      #endif
      
      TTestMDIChild::TTestMDIChild(TMDIClient& parent, const char far* title, TWindow* clientWnd, bool shrinkToClient, TModule* module)
      :
        TMDIChild(parent, title, !clientWnd ? new TTestEditFile(0, 0, 0) : clientWnd, shrinkToClient, module)
      {
        // INSERT>> Your constructor code here.
        Attr.Style &= ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
      }
      
      void TTestMDIChild::SetupWindow()
      {
        TMDIChild::SetupWindow();
      
        ModifyExStyle(0, WS_EX_CONTEXTHELP);
      }
      
       
      👍
      1
  • Gianni Rossi

    Gianni Rossi - 2022-10-04

    It works, thank you for your always valuable help.

    However, I don't want to remove WS_MAXIMIZEBOX and WS_MINIMIZEBOX styles because my users often need to minimize and maximize their windows.

    Currently I have implemented the context help by responding to the F1 keyboard key, but I would like that the users also have an on-screen icon to click. So I was thinking of using the general tollbar CM_HELPCONTENTS icon by having it responding with help contextual to the active MDIChild.
    What do you think on this? Do you happen to have a better solution?

    P.S. my context help consists of my PDF guide that opens at the point where the functionality related to the current window is explained.

    Thanks again.

     
    • Ognyan Chernokozhev

      The only option I can think of is to use custom painting of the window header. There is an example created by Sebastian Ledesma.

      The original can be found here:
      http://jahanshahi.ws/owl.htm
      Look for WM_NC_DEMO

      It is also included among the OWLNext 6.44 examples.
      Check the attached screenshots which demonstrate some of the customization capabilities.

       
      👍
      1
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-10-05

    @georox wrote:

    So I was thinking of using the general tollbar CM_HELPCONTENTS icon by having it responding with help contextual to the active MDIChild. What do you think on this?

    We discussed this very topic last year [9c4e63e6c5], and I still think a toolbar button is a simple and good-enough solution, rather than customising the MDI child windows. Try it and see how it works.

     

    Related

    Discussion: 9c4e63e6c5


    Last edit: Vidar Hasfjord 2022-10-05
  • Gianni Rossi

    Gianni Rossi - 2022-10-05

    Thanks Jogy and Vidar for your suggestions.

    Jogy's suggestion is very professional but I guess it would be very difficult for me using old BC++5.02-OWL. So finally I've implemented Vidar's solution, i. e. I manage the CM_HELPCONTENTS command (toolbar icon and F1 key) accordingly to the current active MDIChild. So when the user run the command I show a pick-list of help topics and when he/she chooses one of them I open the PDF guide in the proper destination.

    Thanks again for your help.

    P. S.: I'll be back here shortly asking your adivices in order to migrate (or not migrate) to OWLNext.


    Moderator: Formatted paragraphs.

     
    👍
    1

    Last edit: Vidar Hasfjord 2022-10-05
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-10-05

    @georox wrote:

    So when the user run the command I show a pick-list of help topics and when he/she chooses one of them I open the PDF guide in the proper destination.

    That sounds pretty nice, since you can show both context-sensitive and general help topics in your pick-list. I guess most users will figure out how the context-sensitivity works, but if not, you can educate them in the documentation and with tool tips and hint texts, etc.

    PS. Last year you had a problem opening the PDF file reliably. It sounds like you resolved that problem. However, I'm curious to what the problem was, since it remains unresolved in the original discussion [9c4e63e6c5]. Can you post a follow-up there, please, in case anyone else has the same problem?

     

    Related

    Discussion: 9c4e63e6c5

  • Gianni Rossi

    Gianni Rossi - 2022-10-06

    That sounds pretty nice, since you can show both context-sensitive and general help topics in your pick-list. I guess most users will figure out how the context-sensitivity works, but if not, you can educate them in the documentation and with tool tips and hint texts, etc.

    My application is a very large one (topography), so when the user opens one of the (more than 20) MDIChild windows he/she could performs many actions on it. Some of these actions are not simply related to how to use the program, but imply conceptual topics as well. When they first buy the application, this is a big obstacle for them to learn how to use it because, as you pointed out in the topic above, they are not willing to read the whole user's guide (in my case it is over 1000 pages). So I'm quite sure that the solution I've implemented can help them a lot reducing at the same time the need of a direct supprt (phone calls, emails, etc.).

    Here's how it works (plese see the image below):
    1. the user can either press F1 or click the Help icon on the toolbar;
    2. a pick-list shows up with all the Guide topics related to that MDIChild window;
    3. the user chooses the topic he/she is intersted with;
    4. the PDF Guide is opened (if it isn't already) in that destination page.

    Guida.png

    I use SumatraPDF for this purpose because it is free of license and very performant.

     
    👍
    2

    Last edit: Gianni Rossi 2022-10-06

Anonymous
Anonymous

Add attachments
Cancel