Welcome to the Axosoft Community, Sign in | Register | Help
in Search

Jonas Bush

...it's Blog Blog Blog!

Handling Back and Forward in your Application

For something we're working on for our next version, I wanted to be able to handle a user clicking on the "back" button on their mouse to do something in OnTime. Turns out this is pretty straightforward in .Net. There's a notification windows sends called WM_APPCOMMAND, and the parameters it sends will tell you if the user is pushing the "back" button. The code is fairly simple:

private const int WM_APPCOMMAND = 0x0319;
private const int APPCOMMAND_BROWSER_BACKWARD = 1;
private const int APPCOMMAND_BROWSER_FORWARD = 2;
protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_APPCOMMAND)
    {
        int command = (m.LParam.ToInt32() >> 16) & 0x0FFF;
        switch (command)
        {
            case APPCOMMAND_BROWSER_BACKWARD:
                //go back
                return;
            case APPCOMMAND_BROWSER_FORWARD:
                //go forward
                return;
        }
    }
    base.WndProc(ref m);
}

You'll see the point of this code in the near future, once we start unveiling some of the new features slated for the next version of OnTime.
 

Published Tuesday, August 28, 2007 5:21 PM by Jonas
Filed under:

Comments

 

matkinson said:

Might be easier to just do this in some cases...

void OnMouseClick(object sender, MouseEventArgs e)

{

 if (e.Button == System.Windows.Forms.MouseButtons.XButton1)

     // go back

 else if (e.Button == System.Windows.Forms.MouseButtons.XButton2)

    // go forward

}

October 19, 2007 8:36 AM
Anonymous comments are disabled


© 2002 - 2007, Axosoft, LLC. All Rights Reserved. | Privacy
Bug Tracking | Defect Tracking Videos | Help Desk Software