Announcement

Collapse
No announcement yet.

Mouse tracking in tab control?

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

  • Mouse tracking in tab control?

    I'd like to access graphs that show up in a large tab control. How can I track the mouse position in a tab control? I've tried intercepting %WM_MOUSEMOVE from the main dialog callback that owns the tab, but of course, it will not receive these messages when over the tab's (client?) area. There are no %TCM/TCN type messages for this. Also have tried intercepting ANY messages from within the tab's callback itself, but am getting nothing. Any ideas?
    Thanks,
    Todd

    [This message has been edited by Todd Wasson (edited May 18, 2000).]
    Todd Wasson
    http://PerformanceSimulations.Com
    PowerBasic Racing Simulator (October 2007 clip - 15.1MB wmv file) http:http://www.performancesimulations.co...m-GenIV-12.wmv

  • #2
    Todd;

    You have to "subclass" the Tab control and then process the mouse messages before they are passed on to the Tab controls window procedure.

    Search the forum for more info about subclassing.



    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      This is the code I'm using. Aren't the tabs subclassed already when using DDT this way? What gets me is that the callback functions cbTab1, cbTab2, and cbTab3 don't ever BEEP. Nothing is reaching these callbacks as far as I can see. You mention grabbing the messages BEFORE they reach the tab callbacks via subclassing. I'll keep reading!
      Thanks,
      Todd

      Code:
      '-----TabEx.bas----
      #COMPILE EXE
      #INCLUDE "commctrl.inc"
      #INCLUDE "TabDDT.inc"
          GLOBAL hDlg AS LONG
          GLOBAL TEXT AS STRING
          GLOBAL hTabDlg1 AS LONG
          GLOBAL hTabDlg2 AS LONG
          GLOBAL hTabDlg3 AS LONG
      %IDC_TAB = 1000
      
      
      DECLARE CALLBACK FUNCTION MainDlgProc
      
      FUNCTION PBMAIN
          LOCAL th AS TABHDR
          LOCAL hTab AS LONG
      
          ' Main dialog
          DIALOG NEW 0, "DDT - Tab Example",,,400, 300, %WS_SYSMENU OR %WS_MINIMIZEBOX OR %DS_CENTER TO hDlg
      
          ' Tab control
          hTab = TabCtrl(hDlg, %IDC_TAB, 20, 20, 300, 200)
      
          ' Tab - dialog 1
          DIALOG NEW hTab, "Tab nr. 1",,,400, 300, %WS_CHILD OR %WS_VISIBLE  TO hTabDlg1
          CONTROL ADD LABEL, hTabDlg1, -1, "This is Tab 1", 5,25,50,14
          ' Tab - dialog 2
          DIALOG NEW hTab, "Tab nr. 2",,,400, 300, %WS_CHILD OR %WS_VISIBLE TO hTabDlg2
          CONTROL ADD LABEL, hTabDlg2, -1, "This is Tab 2", 5,5,50,14
          ' Tab - dialog 3
          DIALOG NEW hTab, "Tab nr. 3",,,400,300, %WS_CHILD OR %WS_VISIBLE TO hTabDlg3
          CONTROL ADD BUTTON, hTabDlg3, 100, "A big button",50,50, 90,90
          th.lID = %IDC_TAB
          th.cDialogs = 3
      
          th.DlgHdr(0).hTabDlg       = hTabDlg1
          th.DlgHdr(0).lpfnCallback  = CODEPTR(cbTab1)
      
          th.DlgHdr(1).hTabDlg       = hTabDlg2
          th.DlgHdr(1).lpfnCallback  = CODEPTR(cbTab2)
      
          th.DlgHdr(2).hTabDlg       = hTabDlg3
          th.DlgHdr(2).lpfnCallback  = CODEPTR(cbTab3)
      
          InitTabControl hDlg, th
      
          DIALOG SHOW MODAL hDlg CALL MainDlgProc
      
      END FUNCTION
      
      CALLBACK FUNCTION MainDlgProc
      
          SELECT CASE CBMSG
              CASE %WM_NOTIFY
      
                  OnTabNotify CBHNDL, CBLPARAM
              CASE %WM_COMMAND
                  SELECT CASE LOWRD(CBWPARAM)
                  END SELECT
        END SELECT
      
      END FUNCTION
      
      CALLBACK FUNCTION cbTab1
      BEEP
          SELECT CASE CBMSG
      
              CASE %WM_INITDIALOG
              CASE %WM_COMMAND
                  SELECT CASE LOWRD(CBWPARAM)
                 END SELECT
        END SELECT
      
      END FUNCTION
      
      
      CALLBACK FUNCTION cbTab2
      BEEP
        SELECT CASE CBMSG
      
               CASE %WM_INITDIALOG
               CASE %WM_COMMAND
                    SELECT CASE LOWRD(CBWPARAM)
                    END SELECT
        END SELECT
      
      END FUNCTION
      
      CALLBACK FUNCTION cbTab3
      BEEP
        SELECT CASE CBMSG
      
               CASE %WM_INITDIALOG
               CASE %WM_COMMAND
                    SELECT CASE LOWRD(CBWPARAM)
                    END SELECT
        END SELECT
      
      END FUNCTION
      ------------------




      [This message has been edited by Todd Wasson (edited May 18, 2000).]
      Todd Wasson
      http://PerformanceSimulations.Com
      PowerBasic Racing Simulator (October 2007 clip - 15.1MB wmv file) http:http://www.performancesimulations.co...m-GenIV-12.wmv

      Comment


      • #4
        Tab controls use notification messages (%WM_NOTIFY), not %WM_COMMAND messages. Also, specifying a callback for a control is not the same as subclassing a control - a DDT control callback receives messages from the specified control that it's parent callback would have otherwise received. Control callbacks are designed to break a dialog callback into a bunch of more manageable and separated functions.

        Subclassing is a technique of intercepting messages before they are passed to the control own window procedure, thus providing a way to alter the behaviour of an existing instance of a control.

        The messages that your own callbacks' receive originate from the controls own window procedure, in response to messages it receives from the application's message quque.

        For (a simplistic) example, a button control may get a %WM_MOUSEDOWN followed by a %WM_MOUSEUP message, and in turn it sends a %WM_COMMAND|%BN_CLICKED message to the dialog callback (or the button callback if one exists).

        This is 'elementary' windows theory - consult Petzold for a detailed description of how each window class must implement it's own window procedure.

        Creating a whole new control class based on an existing class is call superclassing, and that is another whole topic by itself, but it opens another avenue for creating custom controls.


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          Thanks, Lance. Will hit the book and search for SetWindowLong() now.
          Todd

          ------------------
          Todd Wasson
          http://PerformanceSimulations.Com
          PowerBasic Racing Simulator (October 2007 clip - 15.1MB wmv file) http:http://www.performancesimulations.co...m-GenIV-12.wmv

          Comment

          Working...
          X