Page 1 of 1

how to disable mouse click in many location area (help plzz)

Posted: Sat Nov 12, 2005 3:55 pm
by Nueng
I want to make program for control game
because user can click in option menu, high score, exit and many many ect

If I protect mouse click may be this project will be success

can you introduce me about mouse hook

thank you... (^^)

Posted: Sat Nov 12, 2005 4:27 pm
by rsts
releaseMouse won't do it for you?

did you try a search?

cheers,

Posted: Sat Nov 12, 2005 4:36 pm
by Nueng
in the game mouse still use..
but can't click in some button sush as option, exit game

...

I found mouse hook source code

Code: Select all

Global hhook
Procedure MouseProc(nCode, wParam, lParam)
  *ms.MOUSEHOOKSTRUCT = lParam
  SetGadgetText(0, "x: "+Str(*ms\pt\x))
  SetGadgetText(1, "y: "+Str(*ms\pt\y))
  If wParam = #WM_LBUTTONUP ; 205h
    If *ms\pt\x >= 190 And *ms\pt\x <= 373 And *ms\pt\y >= 432 And *ms\pt\y <= 470
      result = 1 
      ;MessageRequester("Message", "Right button up hooked", 0)
    EndIf
  Else
    result = 0
  EndIf
  ProcedureReturn result
EndProcedure

hInstance = GetModuleHandle_(0)
If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu, "Mouse hook example")
  WindowID = WindowID()
  If CreateGadgetList(WindowID)
    TextGadget(0, 4, 4, 48, 24, "x: ")
    TextGadget(1, 4, 32, 48, 24, "y: ")
  EndIf
  lpdwProcessId = GetWindowThreadProcessId_(WindowID, 0)
  hhook = SetWindowsHookEx_(#WH_MOUSE, @MouseProc(), hInstance, lpdwProcessId)
  Repeat
    EventID = WaitWindowEvent()
  Until EventID = #PB_EventCloseWindow
EndIf
UnhookWindowsHookEx_(hhook)
End
but it's not global... can you introduce me how to write mouse hook with global or all program