Commit 399d21ab authored by Tamar Christina's avatar Tamar Christina Committed by GitHub
Browse files

Merge win32 extras (#67)

* Win32: Initial merge

* Win32: Finish merging Win32.

* Win32: Merge finally done.

* Win32: Update includes

* Win32: Fix build

* Win32: Define WINVER level.

* Win32: Define WINVER level again.

* Win32: GHC compat support.

* Merge: Finally rebased.

* Merge: Added GHC compat.

* Merge: Add compat with layered window.

* Merge: Compat with AnimateWindow

* Merge: Compat with Input

* Merge: Missing structs.

* Merge: remove attribute

* Merge: include header more places.

* Merge: fix remaining issues.

* More compat changes for mouse.

* Merge: Missing mouse defines.

* Merge: So random..

* Merge: such a big mess..

* Merge: such a big mess..

* Merge: such a big mess..
parent d1c4a935
......@@ -31,7 +31,12 @@ module Graphics.Win32 (
module Graphics.Win32.Message,
module Graphics.Win32.Misc,
module Graphics.Win32.Resource,
module Graphics.Win32.Window
module Graphics.Win32.Window,
module Graphics.Win32.LayeredWindow,
module Graphics.Win32.Window.AnimateWindow,
module Graphics.Win32.Window.ForegroundWindow,
module Graphics.Win32.Window.IMM,
module Graphics.Win32.Window.PostMessage
) where
import System.Win32.Types
......@@ -45,3 +50,8 @@ import Graphics.Win32.Message
import Graphics.Win32.Misc
import Graphics.Win32.Resource
import Graphics.Win32.Window
import Graphics.Win32.LayeredWindow
import Graphics.Win32.Window.AnimateWindow
import Graphics.Win32.Window.ForegroundWindow
import Graphics.Win32.Window.IMM
import Graphics.Win32.Window.PostMessage
{-# LANGUAGE CPP #-}
{- |
Module : Graphics.Win32.GDI.AlphaBlend
Copyright : 2013 shelarcy
License : BSD-style
Maintainer : shelarcy@gmail.com
Stability : Provisional
Portability : Non-portable (Win32 API)
Provides alpha blending functionality.
-}
module Graphics.Win32.GDI.AlphaBlend where
import Foreign.Storable ( Storable(..) )
import Foreign.Ptr ( Ptr )
import Graphics.Win32.GDI.Types ( HDC )
import System.Win32.Types ( BOOL, BYTE, UINT )
#include <windows.h>
##include "windows_cconv.h"
foreign import ccall unsafe "alphablend.h"
c_AlphaBlend :: HDC -> Int -> Int -> Int -> Int -> HDC -> Int -> Int -> Int -> Int -> PBLENDFUNCTION -> IO BOOL
{-
We use C wrapper function to call this API.
Because foreign stacall/ccall/capi doesn't work with non-pointer user defined type.
We think that capi should support that when user defined type has Storable class instance
and using CTYPE pragma in the scope.
{-# LANGUAGE CApiFFI #-}
data {-# CTYPE "windows.h" "BLENDFUNCTION" #-} BLENDFUNCTION =
foreign import capi unsafe "windows.h AlphaBlend"
c_AlphaBlend :: HDC -> Int -> Int -> Int -> Int -> HDC -> Int -> Int -> Int -> Int -> BLENDFUNCTION -> IO BOOL
-}
foreign import WINDOWS_CCONV unsafe "windows.h TransparentBlt"
c_TransparentBlt :: HDC -> Int -> Int -> Int -> Int -> HDC -> Int -> Int -> Int -> Int -> UINT -> IO BOOL
aC_SRC_OVER :: BYTE
aC_SRC_OVER = #const AC_SRC_OVER
aC_SRC_ALPHA :: BYTE
aC_SRC_ALPHA = #const AC_SRC_ALPHA
type PBLENDFUNCTION = Ptr BLENDFUNCTION
type LPBLENDFUNCTION = Ptr BLENDFUNCTION
data BLENDFUNCTION = BLENDFUNCTION
{ blendOp :: BYTE
, blendFlags :: BYTE
, sourceConstantAlpha :: BYTE
, alphaFormat :: BYTE
} deriving (Show)
instance Storable BLENDFUNCTION where
sizeOf = const #size BLENDFUNCTION
alignment = sizeOf
poke buf func = do
(#poke BLENDFUNCTION, BlendOp) buf (blendOp func)
(#poke BLENDFUNCTION, BlendFlags) buf (blendFlags func)
(#poke BLENDFUNCTION, SourceConstantAlpha) buf (sourceConstantAlpha func)
(#poke BLENDFUNCTION, AlphaFormat) buf (alphaFormat func)
peek buf = do
blendOp' <- (#peek BLENDFUNCTION, BlendOp) buf
blendFlags' <- (#peek BLENDFUNCTION, BlendFlags) buf
sourceConstantAlpha' <-
(#peek BLENDFUNCTION, SourceConstantAlpha) buf
alphaFormat' <- (#peek BLENDFUNCTION, AlphaFormat) buf
return $ BLENDFUNCTION blendOp' blendFlags' sourceConstantAlpha' alphaFormat'
......@@ -22,11 +22,17 @@ module Graphics.Win32.GDI.Clip where
import Control.Monad
import Graphics.Win32.GDI.Types
import System.Win32.Types
import Graphics.Win32.Message ( WindowMessage )
import Foreign
##include "windows_cconv.h"
#undef WINVER
#define WINVER 0x0600
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#include <windows.h>
type ClipboardFormat = UINT
......@@ -55,8 +61,14 @@ type ClipboardFormat = UINT
, cF_TEXT = CF_TEXT
, cF_WAVE = CF_WAVE
, cF_TIFF = CF_TIFF
, cF_DIBV5 = CF_DIBV5
, cF_GDIOBJLAST = CF_GDIOBJLAST
, cF_UNICODETEXT = CF_UNICODETEXT
}
wM_CLIPBOARDUPDATE :: WindowMessage
wM_CLIPBOARDUPDATE = 0x031D -- #const WM_CLIPBOARDUPDATE -- Can't use constant due to GHC 7.8.x support.
-- % , CF_UNICODETEXT -- WinNT only
foreign import WINDOWS_CCONV unsafe "windows.h ChangeClipboardChain"
......
......@@ -6,7 +6,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Graphics.Win32.Key
-- Copyright : (c) Alastair Reid, 1997-2003
-- Copyright : (c) Alastair Reid, 1997-2003, 2013 shelarcy
-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : Esa Ilari Vuokko <ei@vuokko.info>
......@@ -21,87 +21,169 @@ module Graphics.Win32.Key where
import Control.Monad (liftM)
import Graphics.Win32.GDI.Types (HWND)
import System.Win32.Types (DWORD, UINT, WORD, ptrToMaybe)
import System.Win32.Types ( DWORD, UINT, WORD, ptrToMaybe, BOOL, SHORT,
failIfFalse_, failIfZero )
import Control.Exception ( bracket )
import Foreign.Ptr ( Ptr, nullPtr )
import Foreign.C.Types ( CWchar(..) )
import Foreign.Marshal.Array ( allocaArray, peekArray )
import System.Win32.String ( LPTSTR, LPCTSTR
, withTString, withTStringBuffer, peekTString )
import System.Win32.Thread ( TID, getCurrentThreadId )
##include "windows_cconv.h"
#include <windows.h>
#include "winuser_compat.h"
type VKey = DWORD
#{enum VKey,
, vK_LBUTTON = VK_LBUTTON
, vK_RBUTTON = VK_RBUTTON
, vK_CANCEL = VK_CANCEL
, vK_MBUTTON = VK_MBUTTON
, vK_BACK = VK_BACK
, vK_TAB = VK_TAB
, vK_CLEAR = VK_CLEAR
, vK_RETURN = VK_RETURN
, vK_SHIFT = VK_SHIFT
, vK_CONTROL = VK_CONTROL
, vK_MENU = VK_MENU
, vK_PAUSE = VK_PAUSE
, vK_CAPITAL = VK_CAPITAL
, vK_ESCAPE = VK_ESCAPE
, vK_SPACE = VK_SPACE
, vK_PRIOR = VK_PRIOR
, vK_NEXT = VK_NEXT
, vK_END = VK_END
, vK_HOME = VK_HOME
, vK_LEFT = VK_LEFT
, vK_UP = VK_UP
, vK_RIGHT = VK_RIGHT
, vK_DOWN = VK_DOWN
, vK_SELECT = VK_SELECT
, vK_EXECUTE = VK_EXECUTE
, vK_SNAPSHOT = VK_SNAPSHOT
, vK_INSERT = VK_INSERT
, vK_DELETE = VK_DELETE
, vK_HELP = VK_HELP
, vK_NUMPAD0 = VK_NUMPAD0
, vK_NUMPAD1 = VK_NUMPAD1
, vK_NUMPAD2 = VK_NUMPAD2
, vK_NUMPAD3 = VK_NUMPAD3
, vK_NUMPAD4 = VK_NUMPAD4
, vK_NUMPAD5 = VK_NUMPAD5
, vK_NUMPAD6 = VK_NUMPAD6
, vK_NUMPAD7 = VK_NUMPAD7
, vK_NUMPAD8 = VK_NUMPAD8
, vK_NUMPAD9 = VK_NUMPAD9
, vK_MULTIPLY = VK_MULTIPLY
, vK_ADD = VK_ADD
, vK_SEPARATOR = VK_SEPARATOR
, vK_SUBTRACT = VK_SUBTRACT
, vK_DECIMAL = VK_DECIMAL
, vK_DIVIDE = VK_DIVIDE
, vK_F1 = VK_F1
, vK_F2 = VK_F2
, vK_F3 = VK_F3
, vK_F4 = VK_F4
, vK_F5 = VK_F5
, vK_F6 = VK_F6
, vK_F7 = VK_F7
, vK_F8 = VK_F8
, vK_F9 = VK_F9
, vK_F10 = VK_F10
, vK_F11 = VK_F11
, vK_F12 = VK_F12
, vK_F13 = VK_F13
, vK_F14 = VK_F14
, vK_F15 = VK_F15
, vK_F16 = VK_F16
, vK_F17 = VK_F17
, vK_F18 = VK_F18
, vK_F19 = VK_F19
, vK_F20 = VK_F20
, vK_F21 = VK_F21
, vK_F22 = VK_F22
, vK_F23 = VK_F23
, vK_F24 = VK_F24
, vK_NUMLOCK = VK_NUMLOCK
, vK_SCROLL = VK_SCROLL
, vK_LBUTTON = VK_LBUTTON
, vK_RBUTTON = VK_RBUTTON
, vK_CANCEL = VK_CANCEL
, vK_MBUTTON = VK_MBUTTON
, vK_BACK = VK_BACK
, vK_TAB = VK_TAB
, vK_CLEAR = VK_CLEAR
, vK_RETURN = VK_RETURN
, vK_SHIFT = VK_SHIFT
, vK_CONTROL = VK_CONTROL
, vK_MENU = VK_MENU
, vK_PAUSE = VK_PAUSE
, vK_CAPITAL = VK_CAPITAL
, vK_ESCAPE = VK_ESCAPE
, vK_SPACE = VK_SPACE
, vK_PRIOR = VK_PRIOR
, vK_NEXT = VK_NEXT
, vK_END = VK_END
, vK_HOME = VK_HOME
, vK_LEFT = VK_LEFT
, vK_UP = VK_UP
, vK_RIGHT = VK_RIGHT
, vK_DOWN = VK_DOWN
, vK_SELECT = VK_SELECT
, vK_EXECUTE = VK_EXECUTE
, vK_SNAPSHOT = VK_SNAPSHOT
, vK_INSERT = VK_INSERT
, vK_DELETE = VK_DELETE
, vK_HELP = VK_HELP
, vK_NUMPAD0 = VK_NUMPAD0
, vK_NUMPAD1 = VK_NUMPAD1
, vK_NUMPAD2 = VK_NUMPAD2
, vK_NUMPAD3 = VK_NUMPAD3
, vK_NUMPAD4 = VK_NUMPAD4
, vK_NUMPAD5 = VK_NUMPAD5
, vK_NUMPAD6 = VK_NUMPAD6
, vK_NUMPAD7 = VK_NUMPAD7
, vK_NUMPAD8 = VK_NUMPAD8
, vK_NUMPAD9 = VK_NUMPAD9
, vK_MULTIPLY = VK_MULTIPLY
, vK_ADD = VK_ADD
, vK_SEPARATOR = VK_SEPARATOR
, vK_SUBTRACT = VK_SUBTRACT
, vK_DECIMAL = VK_DECIMAL
, vK_DIVIDE = VK_DIVIDE
, vK_F1 = VK_F1
, vK_F2 = VK_F2
, vK_F3 = VK_F3
, vK_F4 = VK_F4
, vK_F5 = VK_F5
, vK_F6 = VK_F6
, vK_F7 = VK_F7
, vK_F8 = VK_F8
, vK_F9 = VK_F9
, vK_F10 = VK_F10
, vK_F11 = VK_F11
, vK_F12 = VK_F12
, vK_F13 = VK_F13
, vK_F14 = VK_F14
, vK_F15 = VK_F15
, vK_F16 = VK_F16
, vK_F17 = VK_F17
, vK_F18 = VK_F18
, vK_F19 = VK_F19
, vK_F20 = VK_F20
, vK_F21 = VK_F21
, vK_F22 = VK_F22
, vK_F23 = VK_F23
, vK_F24 = VK_F24
, vK_NUMLOCK = VK_NUMLOCK
, vK_SCROLL = VK_SCROLL
, vK_XBUTTON1 = VK_XBUTTON1
, vK_XBUTTON2 = VK_XBUTTON2
, vK_KANA = VK_KANA
, vK_HANGUL = VK_HANGUL
, vK_JUNJA = VK_JUNJA
, vK_FINAL = VK_FINAL
, vK_HANJA = VK_HANJA
, vK_KANJI = VK_KANJI
, vK_CONVERT = VK_CONVERT
, vK_NONCONVERT = VK_NONCONVERT
, vK_ACCEPT = VK_ACCEPT
, vK_MODECHANGE = VK_MODECHANGE
, vK_PRINT = VK_PRINT
, vK_APPS = VK_APPS
, vK_SLEEP = VK_SLEEP
, vK_LWIN = VK_LWIN
, vK_RWIN = VK_RWIN
, vK_LSHIFT = VK_LSHIFT
, vK_RSHIFT = VK_RSHIFT
, vK_LCONTROL = VK_LCONTROL
, vK_RCONTROL = VK_RCONTROL
, vK_LMENU = VK_LMENU
, vK_RMENU = VK_RMENU
, vK_BROWSER_BACK = VK_BROWSER_BACK
, vK_BROWSER_FORWARD = VK_BROWSER_FORWARD
, vK_BROWSER_REFRESH = VK_BROWSER_REFRESH
, vK_BROWSER_STOP = VK_BROWSER_STOP
, vK_BROWSER_SEARCH = VK_BROWSER_SEARCH
, vK_BROWSER_FAVORITES = VK_BROWSER_FAVORITES
, vK_BROWSER_HOME = VK_BROWSER_HOME
, vK_VOLUME_MUTE = VK_VOLUME_MUTE
, vK_VOLUME_DOWN = VK_VOLUME_DOWN
, vK_VOLUME_UP = VK_VOLUME_UP
, vK_MEDIA_NEXT_TRACK = VK_MEDIA_NEXT_TRACK
, vK_MEDIA_PREV_TRACK = VK_MEDIA_PREV_TRACK
, vK_MEDIA_STOP = VK_MEDIA_STOP
, vK_MEDIA_PLAY_PAUSE = VK_MEDIA_PLAY_PAUSE
, vK_LAUNCH_MAIL = VK_LAUNCH_MAIL
, vK_LAUNCH_MEDIA_SELECT = VK_LAUNCH_MEDIA_SELECT
, vK_LAUNCH_APP1 = VK_LAUNCH_APP1
, vK_LAUNCH_APP2 = VK_LAUNCH_APP2
, vK_OEM_1 = VK_OEM_1
, vK_OEM_PLUS = VK_OEM_PLUS
, vK_OEM_COMMA = VK_OEM_COMMA
, vK_OEM_MINUS = VK_OEM_MINUS
, vK_OEM_PERIOD = VK_OEM_PERIOD
, vK_OEM_2 = VK_OEM_2
, vK_OEM_3 = VK_OEM_3
, vK_OEM_4 = VK_OEM_4
, vK_OEM_5 = VK_OEM_5
, vK_OEM_6 = VK_OEM_6
, vK_OEM_7 = VK_OEM_7
, vK_OEM_8 = VK_OEM_8
, vK_OEM_102 = VK_OEM_102
, vK_PROCESSKEY = VK_PROCESSKEY
, vK_PACKET = VK_PACKET
, vK_ATTN = VK_ATTN
, vK_CRSEL = VK_CRSEL
, vK_EXSEL = VK_EXSEL
, vK_EREOF = VK_EREOF
, vK_PLAY = VK_PLAY
, vK_ZOOM = VK_ZOOM
, vK_NONAME = VK_NONAME
, vK_PA1 = VK_PA1
, vK_OEM_CLEAR = VK_OEM_CLEAR
}
foreign import WINDOWS_CCONV unsafe "windows.h VkKeyScanExW"
c_VkKeyScanEx :: CWchar -> HKL -> IO SHORT
foreign import WINDOWS_CCONV unsafe "windows.h MapVirtualKeyW"
c_MapVirtualKey :: VKey -> UINT -> IO UINT
foreign import WINDOWS_CCONV unsafe "windows.h MapVirtualKeyExW"
c_MapVirtualKeyEx :: VKey -> UINT -> HKL -> IO UINT
foreign import WINDOWS_CCONV unsafe "windows.h EnableWindow"
enableWindow :: HWND -> Bool -> IO Bool
......@@ -124,3 +206,69 @@ foreign import WINDOWS_CCONV unsafe "windows.h GetKBCodePage"
foreign import WINDOWS_CCONV unsafe "windows.h IsWindowEnabled"
isWindowEnabled :: HWND -> IO Bool
getCurrentKeyboardLayout :: IO HKL
getCurrentKeyboardLayout = do
tid <- getCurrentThreadId
c_GetKeyboardLayout tid
getKeyboardLayoutList :: IO [HKL]
getKeyboardLayoutList = do
len' <- failIfZero "GetKeyboardLayoutList" $ c_GetKeyboardLayoutList 0 nullPtr
let len = fromIntegral len'
allocaArray len $ \buf -> do
_ <- failIfZero "GetKeyboardLayoutList" $ c_GetKeyboardLayoutList len buf
peekArray len buf
getKeyboardLayoutName :: IO String
getKeyboardLayoutName
= withTStringBuffer 256 $ \buf -> do
failIfFalse_ "GetKeyboardLayoutName" $ c_GetKeyboardLayoutName buf
peekTString buf
withLoadKeyboardLayout :: KeyLayoutFlags -> (HKL -> IO a) -> IO a
withLoadKeyboardLayout flag io
= withTStringBuffer 256 $ \buf -> do
failIfFalse_ "GetKeyboardLayoutName" $ c_GetKeyboardLayoutName buf
bracket (c_LoadKeyboardLayout buf flag)
unloadKeyboardLayout
io
withLoadKeyboardLayoutWithName :: String -> KeyLayoutFlags -> (HKL -> IO a) -> IO a
withLoadKeyboardLayoutWithName str flag io
= withTString str $ \c_str ->
bracket (c_LoadKeyboardLayout c_str flag)
unloadKeyboardLayout
io
unloadKeyboardLayout :: HKL -> IO ()
unloadKeyboardLayout
= failIfFalse_ "UnloadKeyboardLayout" . c_UnloadKeyboardLayout
foreign import WINDOWS_CCONV unsafe "windows.h GetKeyboardLayout"
c_GetKeyboardLayout :: TID -> IO HKL
foreign import WINDOWS_CCONV unsafe "windows.h GetKeyboardLayoutList"
c_GetKeyboardLayoutList :: Int -> (Ptr HKL) -> IO UINT
foreign import WINDOWS_CCONV unsafe "windows.h GetKeyboardLayoutNameW"
c_GetKeyboardLayoutName :: LPTSTR -> IO BOOL
foreign import WINDOWS_CCONV unsafe "windows.h LoadKeyboardLayoutW"
c_LoadKeyboardLayout :: LPCTSTR -> KeyLayoutFlags -> IO HKL
foreign import WINDOWS_CCONV unsafe "windows.h UnloadKeyboardLayout"
c_UnloadKeyboardLayout :: HKL -> IO BOOL
type HKL = Ptr ()
type KeyLayoutFlags = UINT
#{enum KeyLayoutFlags,
, kLF_ACTIVATE = KLF_ACTIVATE
, kLF_NOTELLSHELL = KLF_NOTELLSHELL
, kLF_REORDER = KLF_REORDER
, kLF_REPLACELANG = KLF_REPLACELANG
, kLF_SUBSTITUTE_OK = KLF_SUBSTITUTE_OK
, kLF_SETFORPROCESS = KLF_SETFORPROCESS
}
{-# LANGUAGE CPP #-}
{- |
Module : Graphics.Win32.LayeredWindow
Copyright : 2012-2013 shelarcy
License : BSD-style
Maintainer : shelarcy@gmail.com
Stability : Provisional
Portability : Non-portable (Win32 API)
Provides LayeredWindow functionality.
-}
module Graphics.Win32.LayeredWindow where
import Control.Monad ( void )
import Data.Bits ( (.|.) )
import Foreign.Ptr ( Ptr )
import Foreign.C.Types ( CIntPtr(..) )
import Foreign.Marshal.Utils ( with )
import Graphics.Win32.GDI.AlphaBlend ( BLENDFUNCTION )
import Graphics.Win32.GDI.Types ( COLORREF, HDC, SIZE, SIZE, POINT )
import Graphics.Win32.Window ( WindowStyleEx, c_SetWindowLongPtr, )
import System.Win32.Types ( DWORD, HANDLE, BYTE, BOOL,
LONG_PTR, INT )
#include <windows.h>
##include "windows_cconv.h"
#include "winuser_compat.h"
toLayeredWindow :: HANDLE -> IO ()
toLayeredWindow w = do
flg <- c_GetWindowLongPtr w gWL_EXSTYLE
void $ with (fromIntegral $ flg .|. (fromIntegral wS_EX_LAYERED)) $ c_SetWindowLongPtr w gWL_EXSTYLE
-- test w = c_SetLayeredWindowAttributes w 0 128 lWA_ALPHA
gWL_EXSTYLE :: INT
gWL_EXSTYLE = #const GWL_EXSTYLE
wS_EX_LAYERED :: WindowStyleEx
wS_EX_LAYERED = #const WS_EX_LAYERED
lWA_COLORKEY, lWA_ALPHA :: DWORD
lWA_COLORKEY = #const LWA_COLORKEY
lWA_ALPHA = #const LWA_ALPHA
foreign import WINDOWS_CCONV unsafe "windows.h SetLayeredWindowAttributes"
c_SetLayeredWindowAttributes :: HANDLE -> COLORREF -> BYTE -> DWORD -> IO BOOL
foreign import WINDOWS_CCONV unsafe "windows.h GetLayeredWindowAttributes"
c_GetLayeredWindowAttributes :: HANDLE -> COLORREF -> Ptr BYTE -> Ptr DWORD -> IO BOOL
foreign import WINDOWS_CCONV unsafe "windows.h UpdateLayeredWindow"
c_UpdateLayeredWindow :: HANDLE -> HDC -> Ptr POINT -> Ptr SIZE -> HDC -> Ptr POINT -> COLORREF -> Ptr BLENDFUNCTION -> DWORD -> IO BOOL
foreign import WINDOWS_CCONV "windows.h GetWindowLongPtrW"
c_GetWindowLongPtr :: HANDLE -> INT -> IO LONG_PTR
#{enum DWORD,
, uLW_ALPHA = ULW_ALPHA
, uLW_COLORKEY = ULW_COLORKEY
, uLW_OPAQUE = ULW_OPAQUE
}
......@@ -133,7 +133,7 @@ messageBox wnd text caption style =
withTString text $ \ c_text ->
withTString caption $ \ c_caption ->
failIfZero "MessageBox" $ c_MessageBox wnd c_text c_caption style
foreign import WINDOWS_CCONV unsafe "windows.h MessageBoxW"
foreign import WINDOWS_CCONV safe "windows.h MessageBoxW"
c_MessageBox :: HWND -> LPCTSTR -> LPCTSTR -> MBStyle -> IO MBStatus
----------------------------------------------------------------
......
{-# LANGUAGE CPP #-}
{- |
Module : Graphics.Win32.Window.AnimateWindow
Copyright : 2013 shelarcy
License : BSD-style
Maintainer : shelarcy@gmail.com
Stability : Provisional
Portability : Non-portable (Win32 API)
Provide AnimatedWindow function and flags.
-}
module Graphics.Win32.Window.AnimateWindow where
import Graphics.Win32.GDI.Types ( HWND )
import System.Win32.Types ( DWORD, BOOL, failIfFalse_ )
#include <windows.h>
##include "windows_cconv.h"
#include "winuser_compat.h"
type AnimateWindowType = DWORD
#{enum AnimateWindowType,
, aW_SLIDE = AW_SLIDE
, aW_ACTIVATE = AW_ACTIVATE
, aW_BLEND = AW_BLEND
, aW_HIDE = AW_HIDE
, aW_CENTER = AW_CENTER
, aW_HOR_POSITIVE = AW_HOR_POSITIVE
, aW_HOR_NEGATIVE = AW_HOR_NEGATIVE
, aW_VER_POSITIVE = AW_VER_POSITIVE
, aW_VER_NEGATIVE = AW_VER_NEGATIVE
}
animateWindow :: HWND -> DWORD -> AnimateWindowType -> IO ()
animateWindow hwnd dwTime dwFlags
= failIfFalse_ "AnimateWindow" $ c_AnimateWindow hwnd dwTime dwFlags
foreign import WINDOWS_CCONV "windows.h AnimateWindow"
c_AnimateWindow :: HWND -> DWORD -> AnimateWindowType -> IO BOOL
{-# LANGUAGE CPP #-}
{- |
Module : Graphics.Win32.Window.ForegroundWindow
Copyright : 2012 shelarcy
License : BSD-style
Maintainer : shelarcy@gmail.com
Stability : Provisional
Portability : Non-portable (Win32 API)
Get/Set Foreground Window.
-}
module Graphics.Win32.Window.ForegroundWindow
( getForegroundWindow
, setForegroundWindow
, c_SetForegroundWindow
, allowSetForegroundWindow
, c_AllowSetForegroundWindow
) where
import Control.Monad ( void )
import Graphics.Win32.GDI.Types ( HWND )
import Graphics.Win32.Window ( getForegroundWindow )
import System.Win32.Process ( ProcessId )
#include "windows_cconv.h"
----------------------------------------------------------------
-- | Setting Window to Foreground.
-- See: <https://github.com/haskell/win32/pull/9>,
-- <http://stackoverflow.com/questions/14297146/win32-setforegroundwindow-in-haskell>.
----------------------------------------------------------------
setForegroundWindow :: HWND -> IO Bool
setForegroundWindow = c_SetForegroundWindow
foreign import WINDOWS_CCONV safe "windows.h SetForegroundWindow"
c_SetForegroundWindow :: HWND -> IO Bool
----------------------------------------------------------------
-- | Allow other process to set Window to Foreground
-- by using 'setForegroundWindow' function.
allowSetForegroundWindow :: ProcessId -> IO ()
allowSetForegroundWindow = void . c_AllowSetForegroundWindow
foreign import WINDOWS_CCONV safe "windows.h AllowSetForegroundWindow"
c_AllowSetForegroundWindow :: ProcessId -> IO Bool
{-# LANGUAGE CPP #-}
{- |
Module : Graphics.Win32.Window.HotKey
Copyright : 2013 shelarcy
License : BSD-style
Maintainer : shelarcy@gmail.com
Stability : Provisional
Portability : Non-portable (Win32 API)
An FFI binding to the hot key part of the Win32 API.
-}
module Graphics.Win32.Window.HotKey where
import Data.Bits ( (.|.) )
import Graphics.Win32.GDI.Types ( HWND, MbHWND )
import Graphics.Win32.Key ( VKey )
import Graphics.Win32.Message ( WindowMessage )
import System.Win32.Types ( UINT, BOOL, maybePtr, failIfFalse_ )
import System.Win32.Exception.Unsupported ( unsupportedVal, upgradeWindowsOS )
import System.Win32.Info.Version ( is7OrLater )
#include <windows.h>
##include "windows_cconv.h"
type FsModifiers = [FsModifier]
type FsModifier = UINT
#{enum FsModifier,
, mOD_ALT = MOD_ALT
, mOD_CONTROL = MOD_CONTROL
, mOD_SHIFT = MOD_SHIFT
, mOD_WIN = MOD_WIN