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.