static LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam) {
	int ret = 0;

	if (nCode == HSHELL_APPCOMMAND)
	{
		int cmd = GET_APPCOMMAND_LPARAM(lParam);
		switch (cmd)
		{
		case APPCOMMAND_MEDIA_PLAY:
		case APPCOMMAND_MEDIA_PAUSE:
		case APPCOMMAND_MEDIA_STOP:
		case APPCOMMAND_MEDIA_PREVIOUSTRACK:
		case APPCOMMAND_MEDIA_NEXTTRACK:
			PostMessage(mediaCmdRelayWindowHandle, WM_USER, cmd, NULL);
			ret = 1;
			break;
		}
	}

	// Return non-zero to block the message from being passed on.
	// Otherwise, invoke CallNextHookEx().
	if (ret > 0)
		return ret;
	else
		return CallNextHookEx(hook, nCode, wParam, lParam);
}
	long MusikFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
	{
		if(message == WM_APPCOMMAND)
		{
			
			switch( GET_APPCOMMAND_LPARAM( lParam ) )
			{
			case APPCOMMAND_MEDIA_NEXTTRACK:
				if( wxGetApp().Player.IsPlaying() )
					wxGetApp().Player.NextSong();
				return 1;
			case APPCOMMAND_MEDIA_PREVIOUSTRACK:
				if( wxGetApp().Player.IsPlaying() )
					wxGetApp().Player.PrevSong();
				return 1;
			case APPCOMMAND_MEDIA_STOP:
				if( wxGetApp().Player.IsPlaying() )
					wxGetApp().Player.Stop();;
				return 1;
			case APPCOMMAND_MEDIA_PLAY_PAUSE:
					wxGetApp().Player.PlayPause();
				return 1;		
			}
		}
		return wxFrame::MSWWindowProc(message,wParam,lParam);
	}	
Beispiel #3
0
static int windows_filter_pump(const SDL_Event *event) {
	//handle multimedia button events
	if (event->type == SDL_SYSWMEVENT)
	{
		SDL_SysWMmsg *wmmsg;
		wmmsg = event->syswm.msg;
		
		if (wmmsg->msg == WM_APPCOMMAND) {
			switch (GET_APPCOMMAND_LPARAM(wmmsg->lParam)) {
				case APPCOMMAND_MEDIA_NEXTTRACK:
					jive_send_key_event(JIVE_EVENT_KEY_PRESS, JIVE_KEY_FWD, jive_jiffies());
					return 0; // return non-zero, because we have handled the message (see MSDN doc)
				case APPCOMMAND_MEDIA_PREVIOUSTRACK:
					jive_send_key_event(JIVE_EVENT_KEY_PRESS, JIVE_KEY_REW, jive_jiffies());
					return 0;
				case APPCOMMAND_MEDIA_PLAY_PAUSE:
					jive_send_key_event(JIVE_EVENT_KEY_PRESS, JIVE_KEY_PAUSE, jive_jiffies());
					return 0;
				case APPCOMMAND_VOLUME_DOWN:
					jive_send_key_event(JIVE_EVENT_KEY_DOWN, JIVE_KEY_VOLUME_DOWN, jive_jiffies());
					jive_send_key_event(JIVE_EVENT_KEY_UP, JIVE_KEY_VOLUME_DOWN, jive_jiffies());
					return 0;
				case APPCOMMAND_VOLUME_UP:
					jive_send_key_event(JIVE_EVENT_KEY_DOWN, JIVE_KEY_VOLUME_UP, jive_jiffies());
					jive_send_key_event(JIVE_EVENT_KEY_UP, JIVE_KEY_VOLUME_UP, jive_jiffies());
					return 0;
				//todo: APPCOMMAND_MEDIA_STOP or JIVE_KEY_VOLUME_UP - do anything for these?
				default : break;
			}
		}
    }
	return 1;
}
Beispiel #4
0
LRESULT CALLBACK ShellProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	// Do we have to handle this message?
	if (nCode == HSHELL_APPCOMMAND)
	{
		// Process the hook if the hNotifyWnd window handle is valid
		if (hNotifyWnd != NULL)
		{
			short AppCommand = GET_APPCOMMAND_LPARAM(lParam);
			switch (AppCommand)
			{
			case APPCOMMAND_MEDIA_NEXTTRACK:
			case APPCOMMAND_MEDIA_PLAY_PAUSE:
			case APPCOMMAND_MEDIA_PREVIOUSTRACK:
			case APPCOMMAND_MEDIA_STOP:
				::PostMessage(hNotifyWnd,WM_APPCOMMAND,wParam,lParam);
				return 1; // dont call CallNextHookEx, instead return non-zero, because we have handled the message (see MSDN doc)

			}
		}
	}

	// Call the next handler in the chain
    return CallNextHookEx (hShellHook, nCode, wParam, lParam);
}
/*
 * WndProc method registered to the hidden window to listen for WM_HOTKEY 
 * messages and send them back to the Java listeners.
 */
LRESULT CALLBACK JIntellitypeHandler::WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam )
{
      
    // check for Intellitype messages and if found send them to Intellitype listeners
    if (uMessage == WM_SHELLHOOK) {
        if (wParam == HSHELL_APPCOMMAND) {
           jint cmd  = GET_APPCOMMAND_LPARAM(lParam);        
           JIntellitypeHandler *l_this = (JIntellitypeHandler *) GetWindowLong( hWnd, GWL_USERDATA ); 
           l_this->intellitype(cmd);          
        }
        return TRUE;        
    } 
    
    // check for registered hotkey messages and send them to HotKeyListeners
    switch( uMessage ) {
        case WM_HOTKEY: {
            JIntellitypeHandler *l_this = (JIntellitypeHandler *) GetWindowLong( hWnd, GWL_USERDATA ); 
        	l_this->fireHotKey(wParam);
            return TRUE;
    		break;      
        }
    default:
        return DefWindowProc( hWnd, uMessage, wParam, lParam );    
	}

}
Beispiel #6
0
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
    switch(uMsg){
    
    case WM_KEYDOWN:
        printf("[WM_KEYDOWN] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_KEYUP:
        printf("[WM_KEYUP] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_CHAR:
        printf("[WM_CHAR] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_DEADCHAR:
        printf("[WM_DEADCHAR] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_SYSKEYDOWN:
        printf("[WM_SYSKEYDOWN] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_SYSKEYUP:
        printf("[WM_SYSKEYUP] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_SYSDEADCHAR:
        printf("[WM_SYSDEADCHAR] key = %u, lParam = %lu\n", wParam, lParam);
        return 0;
    case WM_HOTKEY:
        printf("[WM_HOTKEY] keys1 = %u, keys2 = %lu\n", wParam, lParam);
        return 0;
    case WM_APPCOMMAND:
        printf("[WM_APPCOMMAND] cmd = %u, device = %u, keys = %u\n", GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam));
        return 0;

    case WM_CLOSE:
        PostQuitMessage(0);
        return 0;

    }
    
    printf("Received message %u with wParam = %u, lParam = %lu\n", uMsg, wParam, lParam);
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
LRESULT WINAPI CallWndProc(int nCode, WPARAM wParam, LPARAM lParam) 
{ 
    if (nCode < 0)  // do not process message 
        return CallNextHookEx(myhookdata.hhook, nCode, wParam, lParam); 
   
	CWPSTRUCT *C = (CWPSTRUCT *)lParam;

    unsigned int msg = C->message;
    if (msg == 0x0319)
    {
		int cmd  = GET_APPCOMMAND_LPARAM(C->lParam);
		switch (cmd){
		case APPCOMMAND_MEDIA_NEXTTRACK:
			//MessageBox(plugin.hwndParent, L"Next!", L"", MB_OK);
			SendMessage(plugin.hwndParent, WM_COMMAND, WINAMP_BUTTON5, 0);
			break;
		case APPCOMMAND_MEDIA_PAUSE:
			//MessageBox(plugin.hwndParent, L"Pause!", L"", MB_OK);
			SendMessage(plugin.hwndParent, WM_COMMAND, WINAMP_BUTTON3, 0);
			break;
		case APPCOMMAND_MEDIA_PLAY:
			//MessageBox(plugin.hwndParent, L"Play!", L"", MB_OK);
			SendMessage(plugin.hwndParent, WM_COMMAND, WINAMP_BUTTON2, 0);
			break;
		case APPCOMMAND_MEDIA_PLAY_PAUSE:
			//MessageBox(plugin.hwndParent, L"Play Pause!", L"", MB_OK);
			break;
		case APPCOMMAND_MEDIA_PREVIOUSTRACK:
			//MessageBox(plugin.hwndParent, L"Previous!", L"", MB_OK);
			SendMessage(plugin.hwndParent, WM_COMMAND, WINAMP_BUTTON1, 0);
			break;
		case APPCOMMAND_MEDIA_STOP:
			//MessageBox(plugin.hwndParent, L"Stop!", L"", MB_OK);
			SendMessage(plugin.hwndParent, WM_COMMAND, WINAMP_BUTTON4, 0);
			break;
		}
	}
    return CallNextHookEx(myhookdata.hhook, nCode, wParam, lParam); 
} 
INT_PTR CMessageForwarder::ForwardMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	m_hwnd = hwnd;
	m_uMsg = uMsg;
	m_wParam = wParam;
	m_lParam = lParam;

	/* Private message? */
	if(uMsg > WM_APP && uMsg < 0xBFFF)
	{
		return OnPrivateMessage(uMsg,wParam,lParam);
	}

	switch(uMsg)
	{
		case WM_INITDIALOG:
			return OnInitDialog();
			break;

		case WM_CTLCOLORSTATIC:
			return OnCtlColorStatic(reinterpret_cast<HWND>(lParam),
				reinterpret_cast<HDC>(wParam));
			break;

		case WM_CTLCOLOREDIT:
			return OnCtlColorEdit(reinterpret_cast<HWND>(lParam),
				reinterpret_cast<HDC>(wParam));
			break;

		case WM_HSCROLL:
			return OnHScroll(reinterpret_cast<HWND>(lParam));
			break;

		case WM_APPCOMMAND:
			return OnAppCommand(reinterpret_cast<HWND>(wParam),
				GET_APPCOMMAND_LPARAM(lParam),
				GET_DEVICE_LPARAM(lParam),
				GET_KEYSTATE_LPARAM(lParam));
			break;

		case WM_TIMER:
			return OnTimer(static_cast<int>(wParam));
			break;

		case WM_MBUTTONUP:
			return OnMButtonUp(&MAKEPOINTS(lParam));
			break;

		case WM_COMMAND:
			return OnCommand(wParam,lParam);
			break;

		case WM_NOTIFY:
			return OnNotify(reinterpret_cast<LPNMHDR>(lParam));
			break;

		case WM_GETMINMAXINFO:
			return OnGetMinMaxInfo(reinterpret_cast<LPMINMAXINFO>(lParam));
			break;

		case WM_SIZE:
			return OnSize(static_cast<int>(wParam),
				LOWORD(lParam),HIWORD(lParam));
			break;

		case WM_CLOSE:
			return OnClose();
			break;

		case WM_DESTROY:
			return OnDestroy();
			break;

		case WM_NCDESTROY:
			return OnNcDestroy();
			break;


		case EM_SETSEL:
			OnEMSetSel(wParam,lParam);
			break;
	}

	return GetDefaultReturnValue(hwnd,uMsg,wParam,lParam);
}
Beispiel #9
0
LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  XBMC_Event newEvent;
  ZeroMemory(&newEvent, sizeof(newEvent));
  static HDEVNOTIFY hDeviceNotify;

  if (uMsg == WM_CREATE)
  {
    SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG)(((LPCREATESTRUCT)lParam)->lpCreateParams));
    DIB_InitOSKeymap();
    g_uQueryCancelAutoPlay = RegisterWindowMessage(TEXT("QueryCancelAutoPlay"));
    shcne.pidl = NULL;
    shcne.fRecursive = TRUE;
    long fEvents = SHCNE_DRIVEADD | SHCNE_DRIVEREMOVED | SHCNE_MEDIAREMOVED | SHCNE_MEDIAINSERTED;
    SHChangeNotifyRegister(hWnd, SHCNRF_ShellLevel | SHCNRF_NewDelivery, fEvents, WM_MEDIA_CHANGE, 1, &shcne);
    RegisterDeviceInterfaceToHwnd(USB_HID_GUID, hWnd, &hDeviceNotify);
    return 0;
  }

  m_pEventFunc = (PHANDLE_EVENT_FUNC)GetWindowLongPtr(hWnd, GWLP_USERDATA);
  if (!m_pEventFunc)
    return DefWindowProc(hWnd, uMsg, wParam, lParam);

  if(g_uQueryCancelAutoPlay != 0 && uMsg == g_uQueryCancelAutoPlay)
    return S_FALSE;

  switch (uMsg)
  {
    case WM_CLOSE:
    case WM_QUIT:
    case WM_DESTROY:
      newEvent.type = XBMC_QUIT;
      m_pEventFunc(newEvent);
      break;
    case WM_SHOWWINDOW:
      {
        bool active = g_application.m_AppActive;
        g_application.m_AppActive = wParam != 0;
        if (g_application.m_AppActive != active)
          g_Windowing.NotifyAppActiveChange(g_application.m_AppActive);
        CLog::Log(LOGDEBUG, __FUNCTION__"Window is %s", g_application.m_AppActive ? "shown" : "hidden");
      }
      break;
    case WM_ACTIVATE:
      {
        bool active = g_application.m_AppActive;
        if (HIWORD(wParam))
        {
          g_application.m_AppActive = false;
        }
        else
        {
          WINDOWPLACEMENT lpwndpl;
          lpwndpl.length = sizeof(lpwndpl);
          if (LOWORD(wParam) != WA_INACTIVE)
          {
            if (GetWindowPlacement(hWnd, &lpwndpl))
              g_application.m_AppActive = lpwndpl.showCmd != SW_HIDE;
          }
          else
          {
            g_application.m_AppActive = g_Windowing.WindowedMode();
          }
        }
        if (g_application.m_AppActive != active)
          g_Windowing.NotifyAppActiveChange(g_application.m_AppActive);
        CLog::Log(LOGDEBUG, __FUNCTION__"Window is %s", g_application.m_AppActive ? "active" : "inactive");
      }
      break;
    case WM_SETFOCUS:
    case WM_KILLFOCUS:
      g_application.m_AppFocused = uMsg == WM_SETFOCUS;
      g_Windowing.NotifyAppFocusChange(g_application.m_AppFocused);
      if (uMsg == WM_KILLFOCUS)
      {
        CStdString procfile;
        if (CWIN32Util::GetFocussedProcess(procfile))
          CLog::Log(LOGDEBUG, __FUNCTION__": Focus switched to process %s", procfile.c_str());
      }
      break;
    case WM_SYSKEYDOWN:
      switch (wParam)
      {
        case VK_F4: //alt-f4, default event quit.
          return(DefWindowProc(hWnd, uMsg, wParam, lParam));
        case VK_RETURN: //alt-return
          if ((lParam & REPEATED_KEYMASK) == 0)
            g_graphicsContext.ToggleFullScreenRoot();
          return 0;
      }
      //deliberate fallthrough
    case WM_KEYDOWN:
    {
      switch (wParam)
      {
        case VK_CONTROL:
          if ( lParam & EXTENDED_KEYMASK )
            wParam = VK_RCONTROL;
          else
            wParam = VK_LCONTROL;
          break;
        case VK_SHIFT:
          /* EXTENDED trick doesn't work here */
          if (GetKeyState(VK_LSHIFT) & 0x8000)
            wParam = VK_LSHIFT;
          else if (GetKeyState(VK_RSHIFT) & 0x8000)
            wParam = VK_RSHIFT;
          break;
        case VK_MENU:
          if ( lParam & EXTENDED_KEYMASK )
            wParam = VK_RMENU;
          else
            wParam = VK_LMENU;
          break;
      }
      XBMC_keysym keysym;
      TranslateKey(wParam, HIWORD(lParam), &keysym, 1);

      newEvent.type = XBMC_KEYDOWN;
      newEvent.key.keysym = keysym;
      m_pEventFunc(newEvent);
    }
    return(0);

    case WM_SYSKEYUP:
    case WM_KEYUP:
      {
      switch (wParam)
      {
        case VK_CONTROL:
          if ( lParam&EXTENDED_KEYMASK )
            wParam = VK_RCONTROL;
          else
            wParam = VK_LCONTROL;
          break;
        case VK_SHIFT:
          {
            uint32_t scanCodeL = MapVirtualKey(VK_LSHIFT, MAPVK_VK_TO_VSC);
            uint32_t scanCodeR = MapVirtualKey(VK_RSHIFT, MAPVK_VK_TO_VSC);
            uint32_t keyCode = (uint32_t)((lParam & 0xFF0000) >> 16);
            if (keyCode == scanCodeL)
              wParam = VK_LSHIFT;
            else if (keyCode == scanCodeR)
              wParam = VK_RSHIFT;
          }
          break;
        case VK_MENU:
          if ( lParam&EXTENDED_KEYMASK )
            wParam = VK_RMENU;
          else
            wParam = VK_LMENU;
          break;
      }
      XBMC_keysym keysym;
      TranslateKey(wParam, HIWORD(lParam), &keysym, 1);

      if (wParam == VK_SNAPSHOT)
        newEvent.type = XBMC_KEYDOWN;
      else
        newEvent.type = XBMC_KEYUP;
      newEvent.key.keysym = keysym;
      m_pEventFunc(newEvent);
    }
    return(0);
    case WM_APPCOMMAND: // MULTIMEDIA keys are mapped to APPCOMMANDS
    {
      CLog::Log(LOGDEBUG, "WinEventsWin32.cpp: APPCOMMAND %d", GET_APPCOMMAND_LPARAM(lParam));
      newEvent.appcommand.type = XBMC_APPCOMMAND;
      newEvent.appcommand.action = GET_APPCOMMAND_LPARAM(lParam);
      if (m_pEventFunc(newEvent))
        return TRUE;
      else
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }
    case WM_GESTURENOTIFY:
    {
      OnGestureNotify(hWnd, lParam);
      return DefWindowProc(hWnd, WM_GESTURENOTIFY, wParam, lParam);
    }
    case WM_GESTURE:
    {
      OnGesture(hWnd, lParam);
      return 0;
    }
    case WM_SYSCHAR:
      if (wParam == VK_RETURN) //stop system beep on alt-return
        return 0;
      break;
    case WM_SETCURSOR:
      if (HTCLIENT != LOWORD(lParam))
        g_Windowing.ShowOSMouse(true);
      break;
    case WM_MOUSEMOVE:
      newEvent.type = XBMC_MOUSEMOTION;
      newEvent.motion.x = GET_X_LPARAM(lParam);
      newEvent.motion.y = GET_Y_LPARAM(lParam);
      newEvent.motion.state = 0;
      m_pEventFunc(newEvent);
      return(0);
    case WM_LBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_RBUTTONDOWN:
      newEvent.type = XBMC_MOUSEBUTTONDOWN;
      newEvent.button.state = XBMC_PRESSED;
      newEvent.button.x = GET_X_LPARAM(lParam);
      newEvent.button.y = GET_Y_LPARAM(lParam);
      newEvent.button.button = 0;
      if (uMsg == WM_LBUTTONDOWN) newEvent.button.button = XBMC_BUTTON_LEFT;
      else if (uMsg == WM_MBUTTONDOWN) newEvent.button.button = XBMC_BUTTON_MIDDLE;
      else if (uMsg == WM_RBUTTONDOWN) newEvent.button.button = XBMC_BUTTON_RIGHT;
      m_pEventFunc(newEvent);
      return(0);
    case WM_LBUTTONUP:
    case WM_MBUTTONUP:
    case WM_RBUTTONUP:
      newEvent.type = XBMC_MOUSEBUTTONUP;
      newEvent.button.state = XBMC_RELEASED;
      newEvent.button.x = GET_X_LPARAM(lParam);
      newEvent.button.y = GET_Y_LPARAM(lParam);
      newEvent.button.button = 0;
      if (uMsg == WM_LBUTTONUP) newEvent.button.button = XBMC_BUTTON_LEFT;
      else if (uMsg == WM_MBUTTONUP) newEvent.button.button = XBMC_BUTTON_MIDDLE;
      else if (uMsg == WM_RBUTTONUP) newEvent.button.button = XBMC_BUTTON_RIGHT;
      m_pEventFunc(newEvent);
      return(0);
    case WM_MOUSEWHEEL:
      {
        // SDL, which our events system is based off, sends a MOUSEBUTTONDOWN message
        // followed by a MOUSEBUTTONUP message.  As this is a momentary event, we just
        // react on the MOUSEBUTTONUP message, resetting the state after processing.
        newEvent.type = XBMC_MOUSEBUTTONDOWN;
        newEvent.button.state = XBMC_PRESSED;
        // the coordinates in WM_MOUSEWHEEL are screen, not client coordinates
        POINT point;
        point.x = GET_X_LPARAM(lParam);
        point.y = GET_Y_LPARAM(lParam);
        WindowFromScreenCoords(hWnd, &point);
        newEvent.button.x = (uint16_t)point.x;
        newEvent.button.y = (uint16_t)point.y;
        newEvent.button.button = GET_Y_LPARAM(wParam) > 0 ? XBMC_BUTTON_WHEELUP : XBMC_BUTTON_WHEELDOWN;
        m_pEventFunc(newEvent);
        newEvent.type = XBMC_MOUSEBUTTONUP;
        newEvent.button.state = XBMC_RELEASED;
        m_pEventFunc(newEvent);
      }
      return(0);
    case WM_SIZE:
      newEvent.type = XBMC_VIDEORESIZE;
      newEvent.resize.type = XBMC_VIDEORESIZE;
      newEvent.resize.w = GET_X_LPARAM(lParam);
      newEvent.resize.h = GET_Y_LPARAM(lParam);
      if (newEvent.resize.w * newEvent.resize.h)
        m_pEventFunc(newEvent);
      return(0);
    case WM_MEDIA_CHANGE:
      {
        // There may be multiple notifications for one event
        // There are also a few events we're not interested in, but they cause no harm
        // For example SD card reader insertion/removal
        long lEvent;
        PIDLIST_ABSOLUTE *ppidl;
        HANDLE hLock = SHChangeNotification_Lock((HANDLE)wParam, (DWORD)lParam, &ppidl, &lEvent);

        if (hLock)
        {
          char drivePath[MAX_PATH+1];
          if (!SHGetPathFromIDList(ppidl[0], drivePath))
            break;

          switch(lEvent)
          {
            case SHCNE_DRIVEADD:
            case SHCNE_MEDIAINSERTED:
              CLog::Log(LOGDEBUG, __FUNCTION__": Drive %s Media has arrived.", drivePath);
              if (GetDriveType(drivePath) == DRIVE_CDROM)
                g_application.getApplicationMessenger().OpticalMount(drivePath, true);
              else
                CWin32StorageProvider::SetEvent();
              break;

            case SHCNE_DRIVEREMOVED:
            case SHCNE_MEDIAREMOVED:
              CLog::Log(LOGDEBUG, __FUNCTION__": Drive %s Media was removed.", drivePath);
              if (GetDriveType(drivePath) == DRIVE_CDROM)
                g_application.getApplicationMessenger().OpticalUnMount(drivePath);
              else
                CWin32StorageProvider::SetEvent();
              break;
          }
          SHChangeNotification_Unlock(hLock);
        }
        break;
      }
    case WM_POWERBROADCAST:
      if (wParam==PBT_APMSUSPEND)
      {
        CLog::Log(LOGDEBUG,"WM_POWERBROADCAST: PBT_APMSUSPEND event was sent");
        CWin32PowerSyscall::SetOnSuspend();
      }
      else if(wParam==PBT_APMRESUMEAUTOMATIC)
      {
        CLog::Log(LOGDEBUG,"WM_POWERBROADCAST: PBT_APMRESUMEAUTOMATIC event was sent");
        CWin32PowerSyscall::SetOnResume();
      }
      break;
    case WM_DEVICECHANGE:
      {
        PDEV_BROADCAST_DEVICEINTERFACE b = (PDEV_BROADCAST_DEVICEINTERFACE) lParam;
        CStdString dbcc_name(b->dbcc_name);
        dbcc_name = CKeymapLoader::ParseWin32HIDName(b->dbcc_name);
        switch (wParam)
        {
          case DBT_DEVICEARRIVAL:
            CKeymapLoader().DeviceAdded(dbcc_name);
            break;
          case DBT_DEVICEREMOVECOMPLETE:
            CKeymapLoader().DeviceRemoved(dbcc_name);
            break;
          case DBT_DEVNODES_CHANGED:
            //CLog::Log(LOGDEBUG, "HID Device Changed");
            //We generally don't care about Change notifications, only need to know if a device is removed or added to rescan the device list
            break;
        }
        break;
      }
    case WM_PAINT:
      //some other app has painted over our window, mark everything as dirty
      g_windowManager.MarkDirty();
      break;
  }
  return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}
Beispiel #10
0
LONG WINAPI MainWndProc (
    HWND    hWnd,
    UINT    uMsg,
    WPARAM  wParam,
    LPARAM  lParam)
{
	LONG		lRet = 0;
	static qboolean newwindow = true;
	static qboolean minimized = false;

	if (uMsg == MSH_MOUSEWHEEL)
	{
		if (((int)wParam) > 0)
		{
			Key_Event(K_MWHEELUP, true, sys_msg_time);
			Key_Event(K_MWHEELUP, false, sys_msg_time);
		}
		else
		{
			Key_Event(K_MWHEELDOWN, true, sys_msg_time);
			Key_Event(K_MWHEELDOWN, false, sys_msg_time);
		}
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	//Com_Printf("%x\n", uMsg);

	switch (uMsg)
	{
	case WM_MOUSEWHEEL:
		/*
		** this chunk of code theoretically only works under NT4 and Win98
		** since this message doesn't exist under Win95
		*/
		if ((short)HIWORD(wParam) > 0)
		{
			Key_Event(K_MWHEELUP, true, sys_msg_time);
			Key_Event(K_MWHEELUP, false, sys_msg_time);
		}
		else
		{
			Key_Event(K_MWHEELDOWN, true, sys_msg_time);
			Key_Event(K_MWHEELDOWN, false, sys_msg_time);
		}
		break;

	case WM_HOTKEY:
		return 0;

	case WM_CREATE:
		cl_hwnd = hWnd;
		newwindow = true;
		MSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG"); 
        return DefWindowProc (hWnd, uMsg, wParam, lParam);

	case WM_PAINT:
		SCR_DirtyScreen();	// force entire screen to update next frame
        return DefWindowProc(hWnd, uMsg, wParam, lParam);

	case WM_DESTROY:
		// let sound and input know about this?
		cl_hwnd = NULL;
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
/*
	case WM_KILLFOCUS: // jit - make sure mouse is deactivated if another window takes focus
		AppActivate(false, minimized, newwindow);

		if (reflib_active)
			re.AppActivate(false);

		return DefWindowProc(hWnd, uMsg, wParam, lParam);

	case WM_NCACTIVATE:
		AppActivate(wParam, minimized, newwindow);

		if (reflib_active)
			re.AppActivate(wParam);

		return DefWindowProc(hWnd, uMsg, wParam, lParam);
*/
	/*case WM_ACTIVATEAPP:
		AppActivate(wParam, minimized, newwindow);

		if (reflib_active)
			re.AppActivate(wParam);

		return DefWindowProc(hWnd, uMsg, wParam, lParam);*/
/* jit - disabled this because we run CheckActive() every frame because we aren't getting appropriate events when the game loses focus/foreground, sometimes.
	case WM_ACTIVATE:
		{
			int	fActive;
			qboolean active;
			HWND foregroundWindow = GetForegroundWindow();

			// KJB: Watch this for problems in fullscreen modes with Alt-tabbing.
			fActive = LOWORD(wParam);
			minimized = (BOOL)HIWORD(wParam); 
			active = (fActive != WA_INACTIVE);

			//if (foregroundWindow != hWnd)
			//	active = false;

			Com_Printf("\nForeground: %d hWnd: %d\n\n", foregroundWindow, hWnd);
			AppActivate(active, minimized, newwindow);

			if (reflib_active)
				re.AppActivate(active);

			newwindow = false;
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
		}
/*
	case WM_WINDOWPOSCHANGED: // jit - handle another case of losing app focus
		{
			LPWINDOWPOS windowpos = (LPWINDOWPOS)lParam;

			if (windowpos->flags & 0x800) // SWP_STATECHANGED
			{
				HWND foregroundWindow = GetForegroundWindow();
				qboolean active = (foregroundWindow == hWnd);

				AppActivate(active, minimized, newwindow);

				if (reflib_active)
					re.AppActivate(active);
			}

			Com_Printf("\nWindowposchanged flags %x\n", windowpos->flags);
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
		}
*/
	case WM_MOVE:
		{
			int		xPos, yPos;
			RECT	r;
			int		style;

			if (!vid_fullscreen->value)
			{
				xPos = (short)LOWORD(lParam);    // horizontal position 
				yPos = (short)HIWORD(lParam);    // vertical position 
				r.left   = 0;
				r.top    = 0;
				r.right  = 1;
				r.bottom = 1;
				style = GetWindowLong(hWnd, GWL_STYLE);
				AdjustWindowRect(&r, style, FALSE);
				Cvar_SetValue("vid_xpos", xPos + r.left);
				Cvar_SetValue("vid_ypos", yPos + r.top);
				vid_xpos->modified = false;
				vid_ypos->modified = false;
			}

			// jitmouse - force mouse to recenter properly
			if (ActiveApp)
				IN_Activate(true);
		}

        return DefWindowProc(hWnd, uMsg, wParam, lParam);

// this is complicated because Win32 seems to pack multiple mouse events into
// one update sometimes, so we always check all states and look for events
	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_RBUTTONDOWN:
	case WM_RBUTTONUP:
	case WM_MBUTTONDOWN:
	case WM_MBUTTONUP:
	case WM_MOUSEMOVE:
	case WM_XBUTTONDOWN: // jitmouse
	case WM_XBUTTONUP: // jitmouse
		{
			int	temp = 0;

			if (wParam & MK_LBUTTON)
				temp |= 1;

			if (wParam & MK_RBUTTON)
				temp |= 2;

			if (wParam & MK_MBUTTON)
				temp |= 4;

			// === jitmouse
			if (wParam & MK_XBUTTON1)
				temp |= 8;

			if (wParam & MK_XBUTTON2)
				temp |= 16;
			// ===

			IN_MouseEvent(temp);

			// ++ ARTHUR [9/04/03] - Mouse movement emulates keystroke
			Key_Event(K_MOUSEMOVE, true, sys_msg_time);
			// -- ARTHUR	
		}
		break;

	case WM_INPUT: // jitmouse
		if (m_rawinput->value && !(cls.key_dest == key_console || g_windowed && M_MenuActive())) // Don't accumulate in-game mouse input when at the console or menu
		{
			UINT dwSize = 40;
			static BYTE lpb[40];
			RAWINPUT *raw;
			GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER));
			raw = (RAWINPUT*)lpb;

			if (raw->header.dwType == RIM_TYPEMOUSE) 
			{
				extern int g_raw_mouse_x, g_raw_mouse_y;

				g_raw_mouse_x += raw->data.mouse.lLastX;
				g_raw_mouse_y += raw->data.mouse.lLastY;
			}
		}
		break;

	case WM_SYSCOMMAND:
		if (wParam == SC_SCREENSAVE)
			return 0;

        return DefWindowProc(hWnd, uMsg, wParam, lParam);

	case WM_SYSKEYDOWN:

		if (wParam == 13) // alt-enter toggles fullscreen
		{
			if (!win_noaltenter || !win_noaltenter->value) // jitkeyboard
			{
				if (vid_fullscreen)
					Cvar_SetValue("vid_fullscreen", !vid_fullscreen->value);

				return 0;
			}
		}

		// fall through

	case WM_KEYDOWN:
		Key_Event(Sys_MapKeyModified(wParam, lParam), true, sys_msg_time);
		break;

	case WM_SYSKEYUP:
	case WM_KEYUP:
		Key_Event(Sys_MapKeyModified(wParam, lParam), false, sys_msg_time);
		break;

	case WM_SIZE:
		if (lParam) // This is 0 when minimized?
		{
			M_RefreshMenu(); // jitmenu
			re.DrawResizeWindow(LOWORD(lParam), HIWORD(lParam));
			VID_NewWindow(LOWORD(lParam), HIWORD(lParam));
		}

		if (wParam == SIZE_MINIMIZED) // jit
			minimized = true;
		else
			minimized = false;
		break;

	case WM_CLOSE:
	case WM_QUIT:
		Com_Quit();
		break;

	case WM_APPCOMMAND:

	#ifdef OGG_SUPPORT
		if(ogg_started)
			switch(GET_APPCOMMAND_LPARAM(lParam))
			{
			case APPCOMMAND_MEDIA_PLAY_PAUSE:
				Cbuf_AddText("ogg_playpause\n");
				return 1;
			case APPCOMMAND_MEDIA_NEXTTRACK:
				Cbuf_AddText("ogg_play >\n");
				return 1;
			case APPCOMMAND_MEDIA_PREVIOUSTRACK:
				Cbuf_AddText("ogg_play <\n");
				return 1;
			case APPCOMMAND_MEDIA_STOP:
				Cbuf_AddText("ogg_stop\n");
				return 1;
			}
		break;
	#endif

	case MM_MCINOTIFY:
		{
			LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
			lRet = CDAudio_MessageHandler(hWnd, uMsg, wParam, lParam);
		}
		break;

	default:	// pass all unhandled messages to DefWindowProc
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }

	//CheckActive(hWnd);

    // return 0 if handled message, 1 if not
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Beispiel #11
0
LRESULT CALLBACK WndProc(   HWND hwnd,      // "handle" to the window that this message is for
                            UINT message,   // TYPE of message (e.g. WM_PAINT is a message asking to paint the window)
                            WPARAM wparam,  // information about the actual message
                            LPARAM lparam ) // MORE info about the message
{
    // If WinMain was the heart of the Windows application, then
    // WndProc is the soul.

    // WndProc does just 1 thing:
    //    - Execute some bit of code in response
    //      to user interactions with our windows
    //      application.  

    // The tricky bit about WndProc is that NOWHERE IN THIS APP'S
    // CODE DO YOU EVER SEE ANY EXPLICIT FUNCTION CALLS
    // TO WndProc!!!  Does that mean WndProc never
    // gets used???

    // NO!!!  Take a look again, around where
    // we create the WNDCLASS.

    // Notice, how the WNDCLASS has lpfnWndProc = WndProc??
    // THAT is the reference to this function.

    // The WINDOWS O/S PERFORMS the function call to
    // WndProc when we call DispatchMessage().

    short AppCommand = 0;

    // printf("MESSAGE: %d\n", message);

    switch( message )
    {
    case WM_CREATE:
        // upon creation, let the speaker beep at 50Hz, for 10ms.
        Beep( 50, 10 );
        return 0;
        break;

    case WM_PAINT:
        {
            // we would place our Windows painting code here.
            HDC hdc;
            PAINTSTRUCT ps;
            hdc = BeginPaint( hwnd, &ps );

            // draw a circle and a 2 squares
            // Ellipse( hdc, 20, 20, 160, 160 );
            // Rectangle( hdc, 50, 50, 90, 90 );
            // Rectangle( hdc, 100, 50, 140, 90 );
            
            EndPaint( hwnd, &ps );
        }
        return 0;
        break;

    case WM_APPCOMMAND:
        AppCommand = GET_APPCOMMAND_LPARAM(lparam);
        switch (AppCommand)
        {
        case APPCOMMAND_MEDIA_NEXTTRACK:
            printf("{\"action\":\"next\"}\n");
            break;
        case APPCOMMAND_MEDIA_PLAY_PAUSE:
            printf("{\"action\":\"play\"}\n");
            break;
        case APPCOMMAND_MEDIA_PREVIOUSTRACK:
            printf("{\"action\":\"back\"}\n");
            break;
        case APPCOMMAND_MEDIA_STOP:
            break;
        }
        return 0;
        break;


    case WM_DESTROY:
        if (dllHandle != NULL) {
            UnSetMMShellHookType UnSetMMShellHook = (UnSetMMShellHookType) GetProcAddress(dllHandle, "UnSetMMShellHook");
            UnSetMMShellHook(hwnd);
        }

        PostQuitMessage( 0 ) ;
        return 0;
        break;

        
    }

    // Now, try going into Visual Studio and
    // press WM_ then press CTRL + SPACE.

    // Or go to
    // http://msdn2.microsoft.com/en-us/library/ms632595.aspx

    // See that huge listing?  Those are ALL THE EVENTS
    // that Windows could possibly throw at our application.
    // WOW!  That's a lot of events.  WE don't want to 
    // have to write code for every single one of them!
    // But our WndProc gets called whenever ANY event
    // happens to our application.  What do we do with
    // the events we don't want to handle?
    
    // Simple.  We will pass the events we DON'T want
    // to handle to DefWindowProc().  DefWindowProc()
    // knows what to do with the events we don't want
    // to handle so that our application remains stable
    // and good.
    return DefWindowProc( hwnd, message, wparam, lparam );
}
Beispiel #12
0
int getWinampCommand(LPARAM lParam)
{
	int app_cmd, winamp_cmd;

	app_cmd = GET_APPCOMMAND_LPARAM(lParam);

	if (app_cmd == APPCOMMAND_MEDIA_PLAY_PAUSE)
	{
		if ( SendMessage(winamp_hwnd, WM_USER, 0, IPC_ISPLAYING) == 1)
			winamp_cmd = WINAMP_BUTTON_PAUSE;
		else
			winamp_cmd = WINAMP_BUTTON_PLAY;
	}
	
	else if (app_cmd == APPCOMMAND_MEDIA_STOP)
		winamp_cmd = WINAMP_BUTTON_STOP;
		
	else if (app_cmd == APPCOMMAND_MEDIA_NEXTTRACK)
		winamp_cmd = WINAMP_BUTTON_NEXTTRACK;
		
	else if (app_cmd == APPCOMMAND_MEDIA_PREVIOUSTRACK)
		winamp_cmd = WINAMP_BUTTON_PREVTRACK;
		
	else if (app_cmd == APPCOMMAND_VOLUME_DOWN)
		winamp_cmd = WINAMP_VOLUMEDOWN;
		
	else if (app_cmd == APPCOMMAND_VOLUME_UP)
		winamp_cmd = WINAMP_VOLUMEUP;

	else if (app_cmd == APPCOMMAND_MEDIA_PLAY)
		winamp_cmd = WINAMP_BUTTON_PLAY;
		
	else if (app_cmd == APPCOMMAND_MEDIA_PAUSE)
		winamp_cmd = WINAMP_BUTTON_PAUSE;
		
	else if (app_cmd == APPCOMMAND_MEDIA_RECORD)
	{
		winamp_cmd = WINAMP_OPTIONS_PLEDIT; //hmm, i set it to something more useful - opens playlist

		//give focus to playlist
		HWND winamp_playlist_hwnd = FindWindow("Winamp PE", NULL);

		if ( winamp_playlist_hwnd != NULL )
			SetForegroundWindow(winamp_playlist_hwnd);
	}
		
	else if (app_cmd == APPCOMMAND_MEDIA_FAST_FORWARD)
		winamp_cmd = WINAMP_FFWD5S;
		
	else if (app_cmd == APPCOMMAND_MEDIA_REWIND)
		winamp_cmd = WINAMP_REW5S;
		
	else if (app_cmd == APPCOMMAND_MEDIA_CHANNEL_UP)
		winamp_cmd = WINAMP_BUTTON_NEXTTRACK;
		
	else if (app_cmd == APPCOMMAND_MEDIA_CHANNEL_DOWN)
		winamp_cmd = WINAMP_BUTTON_PREVTRACK;
	
	//else if (app_cmd == APPCOMMAND_HELP)
	//	winamp_cmd = WINAMP_HELP_ABOUT;

	else
		winamp_cmd = -1;

	return winamp_cmd;
}
Beispiel #13
0
LONG WINAPI FaderWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
/////////////////////////////////////////////////////////////////////////////
{
	PAINTSTRUCT	ps;
	PFADERINFO	pFI			= (PFADERINFO)GetWindowLong( hWnd, GWL_USERDATA );
	HWND		hParentWnd	= GetParent( hWnd );
	
	switch( iMessage ) 
	{
	case WM_GETDLGCODE:
		return( DLGC_WANTARROWS );

	case WM_SETFOCUS:
		if( pFI )
		{
			CreateCaret( hWnd, (HBITMAP)1, pFI->bmFader.bmWidth - 5, pFI->bmFader.bmHeight - CARET_OFFSET );
			SetCaretPos( pFI->nBitmapX + 2, pFI->nBitmapPos + (CARET_OFFSET/2) );
			ShowCaret( hWnd );
			pFI->bHasFocus = TRUE;
		}
		break;
		
	case WM_KILLFOCUS:
		if( pFI )
			pFI->bHasFocus = FALSE;
		HideCaret( hWnd );
		DestroyCaret();
		break;
		
	case WM_APPCOMMAND:
		switch( GET_APPCOMMAND_LPARAM(lParam) )
		{
		case APPCOMMAND_VOLUME_MUTE:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_BOTTOM, (LPARAM)hWnd );
			return( TRUE );
		case APPCOMMAND_VOLUME_UP:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEUP, (LPARAM)hWnd );
			return( TRUE );
		case APPCOMMAND_VOLUME_DOWN:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEDOWN, (LPARAM)hWnd );
			return( TRUE );
		default:
			return( DefWindowProc( hWnd, iMessage, wParam, lParam ) );
		}
		break;

	case WM_KEYDOWN:		/* Keyboard Interface for Fader */
		switch( wParam ) 
		{
		case VK_TAB:
			// pass this on to the parent
			//PostMessage( hParentWnd, iMessage, wParam, lParam );
			break;

		case VK_RIGHT:
		case VK_DOWN:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEDOWN, (LPARAM)hWnd );
			break;
			
		case VK_LEFT:
		case VK_UP:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEUP, (LPARAM)hWnd );
			break;
			
		case VK_PRIOR:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_PAGEUP, (LPARAM)hWnd );
			break;
			
		case VK_NEXT:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_PAGEDOWN, (LPARAM)hWnd );
			break;
			
		case VK_HOME:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_TOP, (LPARAM)hWnd );
			break;
			
		case VK_END:
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_BOTTOM, (LPARAM)hWnd );
			break;
			
		}
		break;
		
	case WM_LBUTTONUP:
		ReleaseCapture();
		if( pFI )
		{
			// we know this control has the focus
			SetCaretPos( pFI->nBitmapX + 2, pFI->nBitmapPos + (CARET_OFFSET/2) );
			ShowCaret( hWnd );
			pFI->bMouseDown = FALSE;
		}
		break;
		
	case WM_LBUTTONDOWN:
		SetFocus( hWnd );
		SetCapture( hWnd );
		HideCaret( hWnd );
		if( pFI )
		{
			pFI->bMouseDown = TRUE;		/* Fall Through */
		}
		
	case WM_MOUSEMOVE:
		//fwKeys = wParam;        // key flags 
		//xPos = LOWORD(lParam);  // horizontal position of cursor 
		//yPos = HIWORD(lParam);  // vertical position of cursor (zero at the top)

		if( pFI )
		{
			if( pFI->bMouseDown )
			{
				short	X = LOWORD( lParam );
				short	Y = HIWORD( lParam );
				WORD	wPos;
				int		nScale = pFI->nWindowY - pFI->bmFader.bmHeight;

				// make sure we don't go out of bounds
				if( Y > (pFI->nWindowY - (pFI->bmFader.bmHeight/2)) )
					Y = (pFI->nWindowY - (pFI->bmFader.bmHeight/2));
				
				if( Y < (pFI->bmFader.bmHeight/2) )
					Y = (pFI->bmFader.bmHeight/2);

				Y	-= (pFI->bmFader.bmHeight/2);

				if( Y > nScale )
					Y = nScale;

				wPos = pFI->nMax - (((int)Y * pFI->nMax) / nScale);

				PostMessage( hParentWnd, WM_VSCROLL, MAKELONG( SB_THUMBTRACK, wPos ), (LPARAM)hWnd );
			}
		}
		break;

	case WM_MOUSEWHEEL:
		{
		short	fwKeys = LOWORD( wParam );
		short	nZDelta = HIWORD( wParam );
		short	nX = LOWORD( lParam );
		short	nY = HIWORD( lParam );
		POINT	Point;
		HWND	hParent;
//		long	CntlID;

		// what window is the mouse currently above?

		Point.x = nX;
		Point.y = nY;

		hWnd = WindowFromPoint( Point );

		hParent = GetParent( hWnd );

		// if the parent of this window is not our parent, we are done
		if( hParent != hParentWnd )
			return( 0L );
		
		// is this one of our fader windows?
/***********
		CntlID = GetWindowLong( hWnd, GWL_ID );
		switch( CntlID )
		{
		case IDC_OUT1_VOLUME:
		case IDC_OUT2_VOLUME:
		case IDC_OUT3_VOLUME:
		case IDC_OUT4_VOLUME:
			break;
		default:
			return( 0L );
		}
***********/

		SetFocus( hWnd );
		HideCaret( hWnd );

		//sprintf( szBuffer, "fwKeys [%d] nZ [%d] nX [%d] nY [%d]", fwKeys, nZDelta, nX, nY );
		//SetDlgItemText( GetParent( hWnd ), IDC_STATUS, szBuffer );

		if( nZDelta > 0 )
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEUP, (LPARAM)hWnd );
		else
			PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEDOWN, (LPARAM)hWnd );
		}
		break;
		
	case WM_SIZE:
		if( pFI )
		{
			pFI->nWindowX = LOWORD( lParam );
			pFI->nWindowY = HIWORD( lParam );
			// Place the Knob at the top of the control
			pFI->nBitmapPos = pFI->nWindowY - pFI->bmFader.bmHeight - 2;
			pFI->nBitmapX = (pFI->nWindowX / 2) - (pFI->bmFader.bmWidth / 2);
		}
		break;
		
	case WM_CREATE:
		pFI = (PFADERINFO)malloc( sizeof( FADERINFO ) );
		SetWindowLong( hWnd, GWL_USERDATA, (DWORD)pFI );
		if( !pFI )
		{
			MessageBox( NULL, TEXT("Fader: malloc failed!"), TEXT("LynxONE Mixer"), MB_OK | MB_ICONSTOP | MB_TASKMODAL );
			break;
		}
		ZeroMemory( pFI, sizeof( FADERINFO ) );
		pFI->hFader = LoadBitmap( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDB_FADER ) );
		pFI->hGradient = LoadBitmap( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDB_GRADIENT ) );
		GetObject( pFI->hFader, sizeof( BITMAP ), (LPSTR)&pFI->bmFader );
		GetObject( pFI->hGradient, sizeof( BITMAP ), (LPSTR)&pFI->bmGradient );
		break;
		
	case WM_DESTROY:
		if( pFI )
		{
			DeleteObject( pFI->hFader );
			DeleteObject( pFI->hGradient );
			free( pFI );
		}
		SetWindowLong( hWnd, GWL_USERDATA, (DWORD)0 );
		break;
		
	case WM_PAINT:
		BeginPaint( hWnd, (LPPAINTSTRUCT)&ps );
		if( pFI )
			PaintControl( ps.hdc, pFI );
		EndPaint( hWnd, (LPPAINTSTRUCT)&ps );
		break;
		
	default:
		return( DefWindowProc( hWnd, iMessage, wParam, lParam ) );
	}
	return( 0L );
}
AnsiString TJvShellHookDemoMainForm::GetAppCommand(int LParam)
{
 AnsiString tmp;
//begin
//  case GET_APPCOMMAND_LPARAM(lParam) of
   switch(GET_APPCOMMAND_LPARAM(LParam))
   {
     case APPCOMMAND_BROWSER_BACKWARD   :{ tmp = "APPCOMMAND_BROWSER_BACKWARD";}break;
     case APPCOMMAND_BROWSER_FORWARD    :{ tmp = "APPCOMMAND_BROWSER_FORWARD"; }break;
     case APPCOMMAND_BROWSER_REFRESH    :{ tmp = "APPCOMMAND_BROWSER_REFRESH"; }break;
     case APPCOMMAND_BROWSER_STOP       :{ tmp = "APPCOMMAND_BROWSER_STOP";    }break;
     case APPCOMMAND_BROWSER_SEARCH     :{ tmp = "APPCOMMAND_BROWSER_SEARCH";  }break;
     case APPCOMMAND_BROWSER_FAVORITES  :
                                        { tmp = "APPCOMMAND_BROWSER_FAVORITES";}break;
     case APPCOMMAND_BROWSER_HOME       :{ tmp = "APPCOMMAND_BROWSER_HOME";    }break;
     case APPCOMMAND_VOLUME_MUTE        :{ tmp = "APPCOMMAND_VOLUME_MUTE";     }break;
     case APPCOMMAND_VOLUME_DOWN        :{ tmp = "APPCOMMAND_VOLUME_DOWN";     }break;
     case APPCOMMAND_VOLUME_UP          :{ tmp = "APPCOMMAND_VOLUME_UP";       }break;
     case APPCOMMAND_MEDIA_NEXTTRACK    :{ tmp = "APPCOMMAND_MEDIA_NEXTTRACK"; }break;
     case APPCOMMAND_MEDIA_PREVIOUSTRACK:
                                  { tmp =     "APPCOMMAND_MEDIA_PREVIOUSTRACK";}break;
     case APPCOMMAND_MEDIA_STOP         :{ tmp = "APPCOMMAND_MEDIA_STOP";      }break;
     case APPCOMMAND_MEDIA_PLAY_PAUSE   :{ tmp = "APPCOMMAND_MEDIA_PLAY_PAUSE";}break;
     case APPCOMMAND_LAUNCH_MAIL        :{ tmp = "APPCOMMAND_LAUNCH_MAIL";     }break;
     case APPCOMMAND_LAUNCH_MEDIA_SELECT:
                                  { tmp = "APPCOMMAND_LAUNCH_MEDIA_SELECT";    }break;
     case APPCOMMAND_LAUNCH_APP1        :{ tmp = "APPCOMMAND_LAUNCH_APP1";     }break;
     case APPCOMMAND_LAUNCH_APP2        :{ tmp = "APPCOMMAND_LAUNCH_APP2";     }break;
     case APPCOMMAND_BASS_DOWN          :{ tmp = "APPCOMMAND_BASS_DOWN";       }break;
     case APPCOMMAND_BASS_BOOST         :{ tmp = "APPCOMMAND_BASS_BOOST";      }break;
     case APPCOMMAND_BASS_UP            :{ tmp = "APPCOMMAND_BASS_UP";         }break;
     case APPCOMMAND_TREBLE_DOWN        :{ tmp = "APPCOMMAND_TREBLE_DOWN";     }break;
     case APPCOMMAND_TREBLE_UP          :{ tmp = "APPCOMMAND_TREBLE_UP";       }break;
     case APPCOMMAND_MICROPHONE_VOLUME_MUTE:
                                  { tmp = "APPCOMMAND_MICROPHONE_VOLUME_MUTE"; }break;
     case APPCOMMAND_MICROPHONE_VOLUME_DOWN:
                                  { tmp = "APPCOMMAND_MICROPHONE_VOLUME_DOWN"; }break;
     case APPCOMMAND_MICROPHONE_VOLUME_UP:
                                  { tmp =   "APPCOMMAND_MICROPHONE_VOLUME_UP"; }break;
     case APPCOMMAND_HELP               :{ tmp = "APPCOMMAND_HELP";            }break;
     case APPCOMMAND_FIND               :{ tmp = "APPCOMMAND_FIND";            }break;
     case APPCOMMAND_NEW                :{ tmp = "APPCOMMAND_NEW";             }break;
     case APPCOMMAND_OPEN               :{ tmp = "APPCOMMAND_OPEN";            }break;
     case APPCOMMAND_CLOSE              :{ tmp = "APPCOMMAND_CLOSE";           }break;
     case APPCOMMAND_SAVE               :{ tmp = "APPCOMMAND_SAVE";            }break;
     case APPCOMMAND_PRINT              :{ tmp = "APPCOMMAND_PRINT";           }break;
     case APPCOMMAND_UNDO               :{ tmp = "APPCOMMAND_UNDO";            }break;
     case APPCOMMAND_REDO               :{ tmp = "APPCOMMAND_REDO";            }break;
     case APPCOMMAND_COPY               :{ tmp = "APPCOMMAND_COPY";            }break;
     case APPCOMMAND_CUT                :{ tmp = "APPCOMMAND_CUT";             }break;
     case APPCOMMAND_PASTE              :{ tmp = "APPCOMMAND_PASTE";           }break;
     case APPCOMMAND_REPLY_TO_MAIL      :{ tmp = "APPCOMMAND_REPLY_TO_MAIL";   }break;
     case APPCOMMAND_FORWARD_MAIL       :{ tmp = "APPCOMMAND_FORWARD_MAIL";    }break;
     case APPCOMMAND_SEND_MAIL          :{ tmp = "APPCOMMAND_SEND_MAIL";       }break;
     case APPCOMMAND_SPELL_CHECK        :{ tmp = "APPCOMMAND_SPELL_CHECK";     }break;
     case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE:
                       { tmp = "APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE"; }break;
     case APPCOMMAND_MIC_ON_OFF_TOGGLE  :
                                  { tmp =       "APPCOMMAND_MIC_ON_OFF_TOGGLE";}break;
     case APPCOMMAND_CORRECTION_LIST    :{ tmp = "APPCOMMAND_CORRECTION_LIST"; }break;
     case APPCOMMAND_MEDIA_PLAY         :{ tmp = "APPCOMMAND_MEDIA_PLAY";      }break;
     case APPCOMMAND_MEDIA_PAUSE        :{ tmp = "APPCOMMAND_MEDIA_PAUSE";     }break;
     case APPCOMMAND_MEDIA_RECORD       :{ tmp = "APPCOMMAND_MEDIA_RECORD";    }break;
     case APPCOMMAND_MEDIA_FAST_FORWARD :
                                  { tmp =      "APPCOMMAND_MEDIA_FAST_FORWARD";}break;
     case APPCOMMAND_MEDIA_REWIND       :{ tmp = "APPCOMMAND_MEDIA_REWIND";    }break;
     case APPCOMMAND_MEDIA_CHANNEL_UP   :{ tmp = "APPCOMMAND_MEDIA_CHANNEL_UP";}break;
     case APPCOMMAND_MEDIA_CHANNEL_DOWN :
                                  { tmp =      "APPCOMMAND_MEDIA_CHANNEL_DOWN";}break;
    default:
    {
     tmp = Format("Unknown ($%.8x)", ARRAYOFCONST( (LParam) ) );
    }break;
   }

  return ( Format("HSHELL_APPCOMMAND: %s", ARRAYOFCONST((tmp)) ) );
}
Beispiel #15
0
static LRESULT CALLBACK _window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) {    
  TRACKMOUSEEVENT tme = {0};

  switch ( msg ) {
    case APP_WINDOW_CREATE: {
      RECT rect;
      GetClientRect(hwnd, &rect);
      window.w = rect.right-rect.left;
      window.h = rect.bottom-rect.top;
      window.created = 1;
      pushL_windowevent("create");      
      return 0;
                            }

    case WM_ACTIVATEAPP:
      if ( wparam ) {
        window.activated = 1;
        SetForegroundWindow(hwnd);
        LockSetForegroundWindow( LSFW_LOCK );
        InvalidateRect(hwnd, 0, 0);
        if (window.created) pushL_windowevent("activate");
      }
      else {
        window.activated = 0;
        if (window.created) pushL_windowevent("deactivate");
      }          
      return 0;

    case APP_TICK:  
	  window.timerposted = 0;
      pushL_tick();      
      return 0;

    case WM_DESTROY:      
      PostQuitMessage(0);
      return 0;

    case WM_SHOWWINDOW:
      if (wparam) {
        if (window.created) pushL_windowevent("show");
      } 
      else {
        if (window.created) pushL_windowevent("hide");
      }
      return 0;

    case WM_MOVE:
      if ( !IsIconic( hwnd ) ) {
        window.x = (int)(short)LOWORD( lparam );
        window.y = (int)(short)HIWORD( lparam );
        if (window.created) pushL_windowevent("move");        
      }
      return 0;    

    case WM_SIZE:
      if ( SIZE_MAXIMIZED == wparam || SIZE_RESTORED == wparam ) {
        window.w = LOWORD( lparam );
        window.h = HIWORD( lparam );
        if (window.created) {
          pushL_windowevent("resize");              
          pushL_draw();        
          SwapBuffers(window.hdc);  
        }
      }
      return 0;

    case WM_ERASEBKGND:
      return 1;

    case WM_PAINT:
      if ( GetUpdateRect(hwnd, 0, FALSE) ) {
        ValidateRect(hwnd, 0 );
        pushL_draw();        
        SwapBuffers(window.hdc);  
      }
      return 0;

    case WM_APPCOMMAND:
      switch ( GET_APPCOMMAND_LPARAM( lparam ) ) {
        case APPCOMMAND_COPY: 
          pushL_command("copy");
          break;
        case APPCOMMAND_CUT:   
          pushL_command("cut");
          break;
        case APPCOMMAND_PASTE: 
          pushL_command("paste");
          break;
        default:
          return DefWindowProc(hwnd, msg, wparam, lparam);
      }
      return 1;
    
    case WM_MBUTTONDBLCLK:
      pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

    case WM_LBUTTONDBLCLK:
      pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "left", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

    case WM_RBUTTONDBLCLK:
      pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "right", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

    case WM_MBUTTONDOWN:
      SetCapture( hwnd );
      pushL_mousedown(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

    case WM_LBUTTONDOWN:
      SetCapture( hwnd );
      pushL_mousedown(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "left", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

    case WM_RBUTTONDOWN:
      SetCapture( hwnd );
      pushL_mousedown(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "right", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

    case WM_MBUTTONUP:
      ReleaseCapture();
      pushL_mouseup(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;  

    case WM_LBUTTONUP:
      ReleaseCapture();
      pushL_mouseup(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "left", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;  

    case WM_RBUTTONUP:    
      ReleaseCapture();
      pushL_mouseup(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "right", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;    

    case WM_CHAR:
	
      if ( ( 32 <= ( wparam & 0xFF ) )) {
		pushL_char(wparam);  
      }	  
      return 0;    

    case WM_MOUSELEAVE:
      window.tracking = 0;
      pushL_mouseexit();
      return 0;

    case WM_MOUSEMOVE:
      SetCursor( window.hcursor );
      if ( !window.tracking ) {
        window.tracking = 1;

        tme.cbSize = sizeof( TRACKMOUSEEVENT );
        tme.dwFlags = TME_LEAVE;
        tme.hwndTrack = hwnd;
        tme.dwHoverTime = HOVER_DEFAULT;

        TrackMouseEvent( &tme );

        pushL_mouseenter();
      }

      pushL_mousemove(GET_X_LPARAM(lparam ), GET_Y_LPARAM(lparam ), 
        GetKeyState( VK_MENU ) & 0x8000,
        GetKeyState( VK_CONTROL ) & 0x8000,
        GetKeyState( VK_SHIFT ) & 0x8000);      
      return 0;

    case WM_MOUSEWHEEL:
      {
        POINT pt;
        UINT step;
        SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &step, 0 );

        pt.x = GET_X_LPARAM( lparam );
        pt.y = GET_Y_LPARAM( lparam );
        ScreenToClient(hwnd, &pt);
        pushL_mousewheel(pt.x, pt.y, 
          GET_WHEEL_DELTA_WPARAM( wparam ) / WHEEL_DELTA,
          step,
          GetKeyState( VK_MENU ) & 0x8000,
          GetKeyState( VK_CONTROL ) & 0x8000,
          GetKeyState( VK_SHIFT ) & 0x8000);        
      }  
      return 0;

    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:
      if ( KF_REPEAT & HIWORD( lparam ) ) {
        pushL_keypress(_translate_keyboard_key( wparam ),
          GetKeyState( VK_MENU ) & 0x8000, 
          GetKeyState( VK_CONTROL ) & 0x8000, 
          GetKeyState( VK_SHIFT ) & 0x8000);
      }
      else {
        pushL_keydown(_translate_keyboard_key( wparam ),
          GetKeyState( VK_MENU ) & 0x8000, 
          GetKeyState( VK_CONTROL ) & 0x8000, 
          GetKeyState( VK_SHIFT ) & 0x8000);
      }
      if ( GetKeyState( VK_CONTROL ) & 0x8000 ) {
        switch ( wparam ) {
          case 0x43:
            pushL_command("copy");
            break;
          case 0x58:
            pushL_command("cut");            
            break;
          case 0x56:
            pushL_command("paste");            
            break;         
        }        
      }
      return 0;

    case WM_KEYUP:
    case WM_SYSKEYUP:  
      pushL_keyup(_translate_keyboard_key( wparam ),
          GetKeyState( VK_MENU ) & 0x8000, 
          GetKeyState( VK_CONTROL ) & 0x8000, 
          GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;
  }

  return DefWindowProc(hwnd, msg, wparam, lparam);
}
bool MyApplication::winEventFilter(MSG * msg, long * result) {
	//qDebug() << "MyApplication::winEventFilter" << msg->message << "lParam:" << msg->lParam;

	static uint last_appcommand = 0;
	
	if (msg->message == WM_KEYDOWN) {
		//qDebug("MyApplication::winEventFilter: WM_KEYDOWN: %X", msg->wParam);
		bool eat_key = false;
		if ((last_appcommand == APPCOMMAND_MEDIA_NEXTTRACK) && (msg->wParam == VK_MEDIA_NEXT_TRACK)) eat_key = true;
		else
		if ((last_appcommand == APPCOMMAND_MEDIA_PREVIOUSTRACK) && (msg->wParam == VK_MEDIA_PREV_TRACK)) eat_key = true;
		else
		if ((last_appcommand == APPCOMMAND_MEDIA_PLAY_PAUSE) && (msg->wParam == VK_MEDIA_PLAY_PAUSE)) eat_key = true;
		else
		if ((last_appcommand == APPCOMMAND_MEDIA_STOP) && (msg->wParam == VK_MEDIA_STOP)) eat_key = true;
		
		if (eat_key) { 
			qDebug("MyApplication::winEventFilter: ignoring key %X", msg->wParam);
			last_appcommand = 0; 
			*result = true; 
			return true; 
		}
	}
	else
	if (msg->message == WM_APPCOMMAND) {
		/*
		QKeySequence k(Qt::Key_MediaTogglePlayPause);
		qDebug() << "MyApplication::winEventFilter" << k.toString();
		*/

		//qDebug() << "MyApplication::winEventFilter" << msg->message << "lParam:" << msg->lParam;
		uint cmd  = GET_APPCOMMAND_LPARAM(msg->lParam);
		uint uDevice = GET_DEVICE_LPARAM(msg->lParam);
		uint dwKeys = GET_KEYSTATE_LPARAM(msg->lParam);
		qDebug() << "MyApplication::winEventFilter: cmd:" << cmd <<"uDevice:" << uDevice << "dwKeys:" << dwKeys;

		//if (uDevice == FAPPCOMMAND_KEY) {
			int key = 0;
			Qt::KeyboardModifiers modifier = Qt::NoModifier;
			QString name;
			
			switch (cmd) {
				case APPCOMMAND_MEDIA_PAUSE: key = Qt::Key_MediaPause; name = "Media Pause"; break;
				case APPCOMMAND_MEDIA_PLAY: key = Qt::Key_MediaPlay; name = "Media Play"; break;
				case APPCOMMAND_MEDIA_STOP: key = Qt::Key_MediaStop; name = "Media Stop"; break;
				case APPCOMMAND_MEDIA_PLAY_PAUSE: key = Qt::Key_MediaTogglePlayPause; name = "Toggle Media Play/Pause"; break;
			
				case APPCOMMAND_MEDIA_NEXTTRACK: key = Qt::Key_MediaNext; name = "Media Next"; break;
				case APPCOMMAND_MEDIA_PREVIOUSTRACK: key = Qt::Key_MediaPrevious; name = "Media Previous"; break;

				case APPCOMMAND_MEDIA_FAST_FORWARD: key = Qt::Key_F; modifier = Qt::ShiftModifier | Qt::ControlModifier; break;
				case APPCOMMAND_MEDIA_REWIND: key = Qt::Key_B; modifier = Qt::ShiftModifier | Qt::ControlModifier; break;
			}
			
			if (key != 0) {
				last_appcommand = cmd;
				
				QKeyEvent event(QEvent::KeyPress, key, modifier, name);
				QWidget * w = QApplication::focusWidget();
				if (w) QCoreApplication::sendEvent(w, &event);
				*result = true;
				return true;
			}
		//}
	}

	return false;
}