Tutorial 17 - Handling double-clicks in PPL

Written By Akki On Friday, November 16, 2007

Tutorial 17 - Handling double-clicks in PPL

Handling double-clicks in PPL

Windows doesn't simplify the task of handling double-clicks. It makes hard for us. Here is a piece of code to simplify your life a little.#declare GetDoubleClickTime apidll GetDoubleClickTime 0 1

#declare GetDoubleClickTime apidll GetDoubleClickTime 0 1

func mainproc(hWnd$, Msg$, wParam$, lParam$)
// Make ClickCount$ global
global(ClickCount$);

ok$ = true;

case (Msg$)

WM_CLOSE: // Window is closed
ShutGameAPI(hWnd$);

WM_LBUTTONDOWN: // Stylus is pressed.
// Get double click time set in milliseconds in Windows.
t$ = GetDoubleClickTime;

// Add 1 to our clickcount variable.
ClickCount$++;

// Loop for double-click time processing windows messages.
lasttime$ = tick;
while (tick - lasttime$ < t$)
HandleMessage;
end;

// If only one click is used it is a single-click.
if (ClickCount$ == 1)
g_ShowMessage("Single-click");
ClickCount$ = 0;
else
g_ShowMessage("Double-click");
ClickCount$ = 0;
end;

WM_KEYDOWN: // A hardware key or software key is pressed.
PostMessage(hWnd$, WM_CLOSE, 0, 0);

end;

return (ok$);

end;

You can apply this to sprite functions as well on the WM_LBUTTONDOWN event.

Share and Enjoy:
  • del.icio.us
  • StumbleUpon
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Reddit
  • Technorati
  • IndianPad
  • YahooMyWeb

No Comments