Announcement

Collapse
No announcement yet.

What's This Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What's This Help

    I cannot find any decent documentation on how to implement "What's This?" help. The sort of thing I want is like Word 2000 which has a "What's This" option on the help menu. I've managed to cobble together the following, but can someone please confirm, or criticise, this scheme.

    I put a "What's This" option on my help menu and a %IDM_HELP_QUESTION button on my toolbar.

    I respond to these by doing,

    Code:
      CALL SetCapture (hWnd)
      CALL SetCursor(LoadCursor(%NULL, BYVAL %IDC_HELP))
      g_HelpMode = %TRUE
    where hWnd is the handle of my main window.

    While g_HelpMode is true, I respond to %WM_LBUTTONDOWN by first cancelling help mode with

    Code:
      CALL ReleaseCapture()
      g_HelpMode = %FALSE
    and then I use ChildWindowFromPoint to get the handle of the window under the mouse cursor. From there I can call up the appropriate context help.

    Is this a sensible scheme?

    Keith

    ------------------

  • #2
    This way looks more natural for me (tested under Wn2000 only).
    Click Help button, then textbox.
    Code:
       #Compile Exe
       #Dim All
       #Register None
       #Include "WIN32API.INC"
                               
       CallBack Function StartHelp
         SendMessage CbHndl, %WM_SYSCOMMAND, %SC_CONTEXTHELP, 0
       End Function
             
       CallBack Function DlgProc
          Select Case CbMsg
             Case %WM_HELP
                Dim lphi As HELPINFO Ptr
                lphi = CbLparam
                MsgBox "Id = " & Str$(@lphi.iCtrlId)
                Function = 1: Exit Function
          End Select
      End Function
    
      Function PbMain
         Local hDlg As Long
         Dialog New 0, "Context Help",,, 240, 180, %WS_CAPTION Or %WS_SYSMENU, To hDlg
         Control Add Button,   hDlg, 101,     "&Help",     190, 10, 40, 14 Call StartHelp
         Control Add TextBox,  hDlg, 102, "", 10, 30, 170, 130, _
            %ES_MULTILINE Or %ES_WANTRETURN Or %WS_TABSTOP, %WS_EX_CLIENTEDGE
         Dialog Show Modal hDlg Call DlgProc
      End Function
    ------------------
    E-MAIL: [email protected]

    Comment


    • #3
      see http://www.powerbasic.com/support/pb...ad.php?t=22766



      ------------------

      Comment


      • #4
        Borje

        Ok, Peter Stephensen creates a dialog box that includes the %DS_CONTEXTHELP style and then responds to %WM_HELP.

        Yes, if I create a window (CreateWindowEx) with the %WS_EX_CONTEXTHELP style, I too get a little "?" button on the caption bar that I can click and then respond to %WM_HELP in the program. That's easy. Word is doing something else.
        Word has minimise/maximise buttons on the caption bar of its main application window, like most other programs. It does not have a little "?" button on the caption bar because, as I understand the windows API, WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. So Word has a "What's This" option on its Help menu. You click this option and you get the "Arrow-Question mark" mouse cursor, which you can then click on something to get context help. How's this done? It's not simply a matter of responding to WM_HELP is it?

        Keith


        ------------------

        Comment


        • #5
          Keith --
          Can you explain, what's wrong in SendMessage CbHndl, %WM_SYSCOMMAND, %SC_CONTEXTHELP, 0 works even for popup windows ?


          ------------------
          E-MAIL: [email protected]

          Comment


          • #6
            Semen

            I apologise for not acknowledging your response straight away. Yes, I see what you are saying. You send message %WM_SYSCOMMAND with wParam = %SC_CONTEXTHELP which changes the cursor to a question mark with a pointer. If the user then clicks a control on the window, the control receives a WM_HELP message, which you can then process in the normal way. That's a very neat solution - no need to bother with mouse capture at all.

            Many thanks
            Keith


            ------------------

            Comment


            • #7
              Peter shows a good way of implementing those neat help popups, without
              having to have a helpfile. Can be invoked via button, menu, whatever.

              BTW, haven't seen any of the later MS Word, so don't know how they do it.
              Stopped bying expensive upgrades when extremely buggy Office97 came out.
              Lost all respect for MS "programmers" there. Cluttered, slow and so many
              weird and unexpected crashes. Mostly use my own software ever since..


              ------------------

              Comment


              • #8
                On www.hellobasic.com you'll find a complete example

                CallHelp..


                ------------------
                hellobasic

                Comment


                • #9
                  Borje

                  Yes, I appreciate Peter's popups without help file - may try them in my programs.

                  I know exactly what you say about MS products. A few things in Word impress me but every time I use it, sooner or later I get infuriated by it and have to restrain myself from inflicting physical damage on my computer.

                  Semen's solution for "What's This" help is very elegant and I'm going to adopt it in my programs. It doesn't allow "What's This" help on the non-client area of the main application window (perhaps Semen will correct me here with another brilliant code snippet) or at least, it doesn't generate a WM_HELP for the non-client areas. Word does have "What's This" help on the non-client areas (dubious benefit to a user) so perhaps it's using a mouse capture technique.

                  Edwin

                  Just downloaded CallHelp. It's doing SendMessage CbHndl, %WM_SYSCOMMAND, %SC_CONTEXTHELP, 0, as Semen.

                  Many thanks to you both, and again to Semen
                  Keith


                  ------------------

                  Comment


                  • #10
                    Keith --
                    Did not test, but completely sure that %WM_CAPTURECHANGED occurs, when OS finishes SC_CONTEXTHELP.
                    Instead of WM_HELP, it's possible to retrieve cursor position and forward

                    ------------------
                    E-MAIL: [email protected]

                    Comment


                    • #11
                      ...as i understand the windows api, ws_ex_contexthelp cannot be used with the ws_maximizebox or ws_minimizebox styles.
                      this was covered in the thread %ws_ex_contexthelp - example use?
                      If you try to make something idiot-proof, someone will invent a better idiot.

                      Comment


                      • #12
                        Matthew

                        Thanks for the link, which I have read with interest, especially Semen's code sample. I copied and compiled. Well, I did suspect Semen would prove me wrong. I can only repeat Wayne Diamond when he says in that thread, Semen never ceases to amaze me.

                        Keith


                        ------------------

                        Comment

                        Working...
                        X