Getting Started
Introduction
Sample Programs
IDEs
History
Advice
Mini-Tutorial
Tutorials
Code Snippets

Resources
Web Sites
More Tutorials
Forums
Vendors/Tools
Books
Magazines
Newsletters
NewsGroups
User Groups
Talk Shows
Blogs

Controls
Overview
Button
Check3State
Checkbox
ComboBox
Frame
Graphic
Image
ImageX
ImgButton
ImgButtonX
Label
Line
ListBox
ListView
Option
Progress Bar
Scrollbar
StatusBar
TAB
TextBox
Toolbar
TreeView

GBIC >> PowerBASIC >> Tutorials >> Mouse

PowerBASIC Information Center Tutorials
These tutorials were written to help you get a quick, but thorough, understanding of PowerBASIC - the scope of the language as well as it's specific capabilities.

Introduction       Projects       Language           Messages       Functions           Advanced
  • Overview
  • Examples
  • IDE
  • Compilation
  • Distribution
  • Project Files
  • DDT Windows
  • Controls
  • Menus
  • Dialogs  
  • Help Files
  • Resources  
  • Templates  
  • Project Shell  
  • Syntax
  • Operators
  • Data Types
  • Variables
  • Scope
  • Declarations  
  • Procedures
  • Flow Control
  • Windows
  • Messages
  • Callbacks
  • Mouse
  • Keyboard
  • Dialogs
  • Controls
  • Subclassing
  • Arithmetic
  • Trig  
  • Strings
  • Arrays
  • Date/Time
  • Printing
  • Files
  • Folders
  • Keyboard
  • Mouse
  • Sound
  • System
  • Error Traps
  • Debugging
  • Objects
  • Graphics
  • Databases
  • API
  • DLLs
  • ASM
  • Threads
  • Mouse Function Summary
    Changing the shape of the mouse cursor is the only built-in PowerBASIC function related to controlling the mouse.

    Otherwise, responding to mouse events via the CallBack function is the primary approach PowerBASIC programmers use to respond to user mouse actions.

      • Mouse  
       MOUSEPTR 

    Client Area Messages
    These messages are sent to windows when a mouse event (press or release) occurs within the window's client area.

    WM_LBUTTONDBLCLK
    WM_LBUTTONDOWN
    WM_LBUTTONUP
    WM_MBUTTONDBLCLK
    WM_MBUTTONDOWN
    WM_MBUTTONUP
    WM_RBUTTONDBLCLK
    WM_RBUTTONDOWN
    WM_RBUTTONUP
    

    The x/y coordinates of the mouse hot spot are in the low-order/hi-order word, respectively, of lParam.

    area. The system posts the WM_MOUSEMOVE message to the window when the user moves the cursor within the client area. WM_CAPTURECHANGED - sent to window losing mouse capture WM_MOUSEACTIVATE - set top-level window as active WM_MOUSEHOVER - hovers over the client area for a certain time period WM_MOUSEHWHEEL - detects movement of mouse wheel WM_MOUSELEAVE - leaves the client area WM_MOUSEMOVE - moves within the client area WM_MOUSEWHEEL - detects movement of mouse wheel WM_NCHITTEST - determines if mouse event was in client/non-client area =============Non-Client Area

    Non-Client Area Messages
    A window also receives a message when a mouse event occurs in the window, but outside the client area - border, menu bar, title bar, scroll bar, window menu, minimize button, and maximize button.

    These non-client messages are generated primarily for use by Windows. There is a corresponding non-client area mouse message for each client area mouse message.

        WM_NCLBUTTONDBLCLK
        WM_NCLBUTTONDOWN
        WM_NCLBUTTONUP
        WM_NCMBUTTONDBLCLK
        WM_NCMBUTTONDOWN
        WM_NCMBUTTONUP
        WM_NCMOUSEHOVER
        WM_NCMOUSELEAVE
        WM_NCMOUSEMOVE
        WM_NCRBUTTONDBLCLK
        WM_NCRBUTTONDOWN
        WM_NCRBUTTONUP
    

    XButton Messages
    Windows supports a mouse with 5 buttons. in addition to the left, middle, and right buttons there are XBUTTON1 and XBUTTON2, which provide backward and forward navigation when internet browsers.

    These messages are provided:

        WM_XBUTTONDBLCLK		- client area
        WM_XBUTTONDOWN		- client area
        WM_XBUTTONUP		- client area 
        WM_NCXBUTTONDBLCLK		- non-client area
        WM_NCXBUTTONDOWN		- non-client area
        WM_NCXBUTTONUP		- non-client area
    
    The HIWORD of the WPARAM in these messages contains a flag indicating which X button was pressed.

    Capturing Mouse Events

    Most programmer effort related to mouse control takes place in a Callback Function, responding to mouse events.

    Mouse Properties
    The properties of a mouse depends on the software drivers supporting the mouse. The Control Panel/Mouse applet is typically used to make changes to the action of the mouse, such as button configurations, pointer options, wheel features and set points.

    Function Reference
    Here's an example of the MOUSEPTR statement.

    • MOUSEPTR - sets the mouse pointer to a new shape
          MOUSEPTR iStyle& TO iResult&    'TO is optional
          
      iResult is set to zero if the operation fails, or to a handle for the old cursor if it succeeds. The handle may be used to restore the cursor by using it in place of iStyle&

      iStyle options are:

          0 -  Hide
          1 -  Arrow
          2 -  Cross
          3 -  I-Beam
          4 -  Arrow
          5 -  Sizing pointer (all directions)
          6 -  Sizing pointer (NE-SW diagonal)
          7 -  Sizing pointer (vertical)
          8 -  Sizing pointer (NW-SE diagonal)
          9 -  Sizing pointer (horizontal)
          10 - Up arrow
          11 - Hourglass
          12 - No mouse pointer
          13 - App Starting (arrow with an hourglass)
      

    If you have any suggestions or corrections, please let me know.