Permalink
Browse files

Don't use stdcall on Win64: It isn't supported; ccall is used instead

  • Loading branch information...
1 parent 6c035c1 commit bda29f7fe0b61b70f558549407e598c9256ad293 @igfoo igfoo committed May 16, 2012
@@ -25,6 +25,8 @@ import Graphics.Win32.Message
import Foreign hiding (unsafePerformIO)
import System.IO.Unsafe
+##include "windows_cconv.h"
+
#include <windows.h>
#include <commctrl.h>
@@ -73,20 +75,20 @@ type ButtonState = UINT
checkDlgButton :: HWND -> Int -> ButtonState -> IO ()
checkDlgButton dialog button check =
failIfFalse_ "CheckDlgButton" $ c_CheckDlgButton dialog button check
-foreign import stdcall unsafe "windows.h CheckDlgButton"
+foreign import WINDOWS_CCONV unsafe "windows.h CheckDlgButton"
c_CheckDlgButton :: HWND -> Int -> ButtonState -> IO Bool
checkRadioButton :: HWND -> Int -> Int -> Int -> IO ()
checkRadioButton dialog first_button last_button check =
failIfFalse_ "CheckRadioButton" $
c_CheckRadioButton dialog first_button last_button check
-foreign import stdcall unsafe "windows.h CheckRadioButton"
+foreign import WINDOWS_CCONV unsafe "windows.h CheckRadioButton"
c_CheckRadioButton :: HWND -> Int -> Int -> Int -> IO Bool
isDlgButtonChecked :: HWND -> Int -> IO ButtonState
isDlgButtonChecked wnd button =
failIfZero "IsDlgButtonChecked" $ c_IsDlgButtonChecked wnd button
-foreign import stdcall unsafe "windows.h IsDlgButtonChecked"
+foreign import WINDOWS_CCONV unsafe "windows.h IsDlgButtonChecked"
c_IsDlgButtonChecked :: HWND -> Int -> IO ButtonState
@@ -324,7 +326,7 @@ createCommonControl c estyle nm wstyle mb_x mb_y mb_w mb_h mb_parent mb_menu h =
(maybePos mb_x) (maybePos mb_y) (maybePos mb_w) (maybePos mb_h)
(maybePtr mb_parent) (maybePtr mb_menu) h nullPtr
-foreign import stdcall unsafe "windows.h InitCommonControls"
+foreign import WINDOWS_CCONV unsafe "windows.h InitCommonControls"
initCommonControls :: IO ()
#endif
@@ -26,6 +26,8 @@ import System.Win32.Types
import Foreign
import Foreign.C
+##include "windows_cconv.h"
+
#include <windows.h>
type DTemplate = LPCTSTR
@@ -67,7 +69,7 @@ dialogBoxParam inst template mb_parent dia_fn init_val = do
c_dia_fn <- mkDialogClosure dia_fn
failIf (== -1) "DialogBoxParam" $
c_DialogBoxParam inst template (maybePtr mb_parent) c_dia_fn init_val
-foreign import stdcall "windows.h DialogBoxParamW"
+foreign import WINDOWS_CCONV "windows.h DialogBoxParamW"
c_DialogBoxParam :: HINSTANCE -> DTemplate -> HWND -> FunPtr DialogProc -> LPARAM -> IO Int
dialogBoxIndirect :: HINSTANCE -> DTemplateMem -> Maybe HWND -> DialogProc -> IO Int
@@ -79,7 +81,7 @@ dialogBoxIndirectParam inst template mb_parent dia_fn init_val = do
c_dia_fn <- mkDialogClosure dia_fn
failIf (== -1) "DialogBoxIndirectParam" $
c_DialogBoxIndirectParam inst template (maybePtr mb_parent) c_dia_fn init_val
-foreign import stdcall "windows.h DialogBoxIndirectParamW"
+foreign import WINDOWS_CCONV "windows.h DialogBoxIndirectParamW"
c_DialogBoxIndirectParam :: HINSTANCE -> DTemplateMem -> HWND -> FunPtr DialogProc -> LPARAM -> IO Int
@@ -207,7 +209,7 @@ createDialogParam inst template mb_parent dia_fn init_val = do
c_dia_fn <- mkDialogClosure dia_fn
failIfNull "CreateDialogParam" $
c_CreateDialogParam inst template (maybePtr mb_parent) c_dia_fn init_val
-foreign import stdcall "windows.h CreateDialogParamW"
+foreign import WINDOWS_CCONV "windows.h CreateDialogParamW"
c_CreateDialogParam :: HINSTANCE -> DTemplate -> HWND -> FunPtr DialogProc -> LPARAM -> IO HWND
createDialogIndirect :: HINSTANCE -> DTemplateMem -> Maybe HWND -> DialogProc -> IO HWND
@@ -219,31 +221,31 @@ createDialogIndirectParam inst template mb_parent dia_fn init_val = do
c_dia_fn <- mkDialogClosure dia_fn
failIfNull "CreateDialogIndirectParam" $
c_CreateDialogIndirectParam inst template (maybePtr mb_parent) c_dia_fn init_val
-foreign import stdcall "windows.h CreateDialogIndirectParamW"
+foreign import WINDOWS_CCONV "windows.h CreateDialogIndirectParamW"
c_CreateDialogIndirectParam :: HINSTANCE -> DTemplateMem -> HWND -> FunPtr DialogProc -> LPARAM -> IO HWND
-foreign import stdcall "windows.h DefDlgProcW"
+foreign import WINDOWS_CCONV "windows.h DefDlgProcW"
defDlgProc :: HWND -> WindowMessage -> WPARAM -> LPARAM -> IO LRESULT
endDialog :: HWND -> Int -> IO ()
endDialog dlg res =
failIfFalse_ "EndDialog" $ c_EndDialog dlg res
-foreign import stdcall "windows.h EndDialog"
+foreign import WINDOWS_CCONV "windows.h EndDialog"
c_EndDialog :: HWND -> Int -> IO BOOL
-foreign import stdcall unsafe "windows.h GetDialogBaseUnits"
+foreign import WINDOWS_CCONV unsafe "windows.h GetDialogBaseUnits"
getDialogBaseUnits :: IO LONG
getDlgCtrlID :: HWND -> IO Int
getDlgCtrlID ctl =
failIfZero "GetDlgCtrlID" $ c_GetDlgCtrlID ctl
-foreign import stdcall unsafe "windows.h GetDlgCtrlID"
+foreign import WINDOWS_CCONV unsafe "windows.h GetDlgCtrlID"
c_GetDlgCtrlID :: HWND -> IO Int
getDlgItem :: HWND -> Int -> IO HWND
getDlgItem dlg item =
failIfNull "GetDlgItem" $ c_GetDlgItem dlg item
-foreign import stdcall unsafe "windows.h GetDlgItem"
+foreign import WINDOWS_CCONV unsafe "windows.h GetDlgItem"
c_GetDlgItem :: HWND -> Int -> IO HWND
getDlgItemInt :: HWND -> Int -> Bool -> IO Int
@@ -252,54 +254,54 @@ getDlgItemInt dlg item signed =
res <- c_GetDlgItemInt dlg item p_trans signed
failIfFalse_ "GetDlgItemInt" $ peek p_trans
return (fromIntegral res)
-foreign import stdcall "windows.h GetDlgItemInt"
+foreign import WINDOWS_CCONV "windows.h GetDlgItemInt"
c_GetDlgItemInt :: HWND -> Int -> Ptr Bool -> Bool -> IO UINT
getDlgItemText :: HWND -> Int -> Int -> IO String
getDlgItemText dlg item size =
allocaArray size $ \ p_buf -> do
_ <- failIfZero "GetDlgItemInt" $ c_GetDlgItemText dlg item p_buf size
peekTString p_buf
-foreign import stdcall "windows.h GetDlgItemTextW"
+foreign import WINDOWS_CCONV "windows.h GetDlgItemTextW"
c_GetDlgItemText :: HWND -> Int -> LPTSTR -> Int -> IO Int
getNextDlgGroupItem :: HWND -> HWND -> BOOL -> IO HWND
getNextDlgGroupItem dlg ctl previous =
failIfNull "GetNextDlgGroupItem" $ c_GetNextDlgGroupItem dlg ctl previous
-foreign import stdcall unsafe "windows.h GetNextDlgGroupItem"
+foreign import WINDOWS_CCONV unsafe "windows.h GetNextDlgGroupItem"
c_GetNextDlgGroupItem :: HWND -> HWND -> BOOL -> IO HWND
getNextDlgTabItem :: HWND -> HWND -> BOOL -> IO HWND
getNextDlgTabItem dlg ctl previous =
failIfNull "GetNextDlgTabItem" $ c_GetNextDlgTabItem dlg ctl previous
-foreign import stdcall unsafe "windows.h GetNextDlgTabItem"
+foreign import WINDOWS_CCONV unsafe "windows.h GetNextDlgTabItem"
c_GetNextDlgTabItem :: HWND -> HWND -> BOOL -> IO HWND
-foreign import stdcall "windows.h IsDialogMessageW"
+foreign import WINDOWS_CCONV "windows.h IsDialogMessageW"
isDialogMessage :: HWND -> LPMSG -> IO BOOL
mapDialogRect :: HWND -> LPRECT -> IO ()
mapDialogRect dlg p_rect =
failIfFalse_ "MapDialogRect" $ c_MapDialogRect dlg p_rect
-foreign import stdcall unsafe "windows.h MapDialogRect"
+foreign import WINDOWS_CCONV unsafe "windows.h MapDialogRect"
c_MapDialogRect :: HWND -> LPRECT -> IO Bool
-- No MessageBox* funs in here just yet.
-foreign import stdcall "windows.h SendDlgItemMessageW"
+foreign import WINDOWS_CCONV "windows.h SendDlgItemMessageW"
sendDlgItemMessage :: HWND -> Int -> WindowMessage -> WPARAM -> LPARAM -> IO LONG
setDlgItemInt :: HWND -> Int -> UINT -> BOOL -> IO ()
setDlgItemInt dlg item value signed =
failIfFalse_ "SetDlgItemInt" $ c_SetDlgItemInt dlg item value signed
-foreign import stdcall "windows.h SetDlgItemInt"
+foreign import WINDOWS_CCONV "windows.h SetDlgItemInt"
c_SetDlgItemInt :: HWND -> Int -> UINT -> BOOL -> IO Bool
setDlgItemText :: HWND -> Int -> String -> IO ()
setDlgItemText dlg item str =
withTString str $ \ c_str ->
failIfFalse_ "SetDlgItemText" $ c_SetDlgItemText dlg item c_str
-foreign import stdcall "windows.h SetDlgItemTextW"
+foreign import WINDOWS_CCONV "windows.h SetDlgItemTextW"
c_SetDlgItemText :: HWND -> Int -> LPCTSTR -> IO Bool
#{enum WindowStyle,
@@ -89,6 +89,8 @@ import Foreign
import Foreign.C
#include "Win32Aux.h"
+##include "windows_cconv.h"
+
#include <windows.h>
----------------------------------------------------------------
@@ -212,32 +214,32 @@ setBITMAP = pokeBITMAP
deleteBitmap :: HBITMAP -> IO ()
deleteBitmap bitmap =
failIfFalse_ "DeleteBitmap" $ c_DeleteBitmap bitmap
-foreign import stdcall unsafe "windows.h DeleteObject"
+foreign import WINDOWS_CCONV unsafe "windows.h DeleteObject"
c_DeleteBitmap :: HBITMAP -> IO Bool
createBitmap :: INT -> INT -> UINT -> UINT -> Maybe LPVOID -> IO HBITMAP
createBitmap w h planes bits mb_color_data =
failIfNull "CreateBitmap" $
c_CreateBitmap w h planes bits (maybePtr mb_color_data)
-foreign import stdcall unsafe "windows.h CreateBitmap"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateBitmap"
c_CreateBitmap :: INT -> INT -> UINT -> UINT -> LPVOID -> IO HBITMAP
createBitmapIndirect :: LPBITMAP -> IO HBITMAP
createBitmapIndirect p_bm =
failIfNull "CreateBitmapIndirect" $ c_CreateBitmapIndirect p_bm
-foreign import stdcall unsafe "windows.h CreateBitmapIndirect"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateBitmapIndirect"
c_CreateBitmapIndirect :: LPBITMAP -> IO HBITMAP
createCompatibleBitmap :: HDC -> Int32 -> Int32 -> IO HBITMAP
createCompatibleBitmap dc w h =
failIfNull "CreateCompatibleBitmap" $ c_CreateCompatibleBitmap dc w h
-foreign import stdcall unsafe "windows.h CreateCompatibleBitmap"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateCompatibleBitmap"
c_CreateCompatibleBitmap :: HDC -> Int32 -> Int32 -> IO HBITMAP
createDIBPatternBrushPt :: LPVOID -> ColorFormat -> IO HBRUSH
createDIBPatternBrushPt bm usage =
failIfNull "CreateDIBPatternBrushPt" $ c_CreateDIBPatternBrushPt bm usage
-foreign import stdcall unsafe "windows.h CreateDIBPatternBrushPt"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateDIBPatternBrushPt"
c_CreateDIBPatternBrushPt :: LPVOID -> ColorFormat -> IO HBRUSH
----------------------------------------------------------------
@@ -249,7 +251,7 @@ getBitmapDimensionEx bm =
allocaSIZE $ \ p_size -> do
failIfFalse_ "GetBitmapDimensionEx" $ c_GetBitmapDimensionEx bm p_size
peekSIZE p_size
-foreign import stdcall unsafe "windows.h GetBitmapDimensionEx"
+foreign import WINDOWS_CCONV unsafe "windows.h GetBitmapDimensionEx"
c_GetBitmapDimensionEx :: HBITMAP -> Ptr SIZE -> IO Bool
setBitmapDimensionEx :: HBITMAP -> SIZE -> IO SIZE
@@ -258,15 +260,15 @@ setBitmapDimensionEx bm (cx,cy) =
failIfFalse_ "SetBitmapDimensionEx" $ do
c_SetBitmapDimensionEx bm cx cy p_size
peekSIZE p_size
-foreign import stdcall unsafe "windows.h SetBitmapDimensionEx"
+foreign import WINDOWS_CCONV unsafe "windows.h SetBitmapDimensionEx"
c_SetBitmapDimensionEx :: HBITMAP -> LONG -> LONG -> Ptr SIZE -> IO Bool
getBitmapInfo :: HBITMAP -> IO BITMAP
getBitmapInfo bm =
allocaBytes (fromIntegral sizeofBITMAP) $ \ p_bm -> do
failIfFalse_ "GetBitmapInfo" $ c_GetBitmapInfo bm sizeofBITMAP p_bm
peekBITMAP p_bm
-foreign import stdcall unsafe "windows.h GetObjectW"
+foreign import WINDOWS_CCONV unsafe "windows.h GetObjectW"
c_GetBitmapInfo :: HBITMAP -> DWORD -> LPBITMAP -> IO Bool
----------------------------------------------------------------
@@ -398,20 +400,20 @@ getDIBits :: HDC -> HBITMAP -> INT -> INT -> Maybe LPVOID -> LPBITMAPINFO -> Col
getDIBits dc bm start nlines mb_bits info usage =
failIfZero "GetDIBits" $
c_GetDIBits dc bm start nlines (maybePtr mb_bits) info usage
-foreign import stdcall unsafe "windows.h GetDIBits"
+foreign import WINDOWS_CCONV unsafe "windows.h GetDIBits"
c_GetDIBits :: HDC -> HBITMAP -> INT -> INT -> LPVOID -> LPBITMAPINFO -> ColorFormat -> IO INT
setDIBits :: HDC -> HBITMAP -> INT -> INT -> LPVOID -> LPBITMAPINFO -> ColorFormat -> IO INT
setDIBits dc bm start nlines bits info use =
failIfZero "SetDIBits" $ c_SetDIBits dc bm start nlines bits info use
-foreign import stdcall unsafe "windows.h SetDIBits"
+foreign import WINDOWS_CCONV unsafe "windows.h SetDIBits"
c_SetDIBits :: HDC -> HBITMAP -> INT -> INT -> LPVOID -> LPBITMAPINFO -> ColorFormat -> IO INT
createDIBitmap :: HDC -> LPBITMAPINFOHEADER -> DWORD -> LPVOID -> LPBITMAPINFO -> ColorFormat -> IO HBITMAP
createDIBitmap dc hdr option init_val info usage =
failIfNull "CreateDIBitmap" $
c_CreateDIBitmap dc hdr option init_val info usage
-foreign import stdcall unsafe "windows.h CreateDIBitmap"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateDIBitmap"
c_CreateDIBitmap :: HDC -> LPBITMAPINFOHEADER -> DWORD -> LPVOID -> LPBITMAPINFO -> ColorFormat -> IO HBITMAP
----------------------------------------------------------------
@@ -20,6 +20,8 @@ module Graphics.Win32.GDI.Brush where
import System.Win32.Types
import Graphics.Win32.GDI.Types
+##include "windows_cconv.h"
+
#include <windows.h>
----------------------------------------------------------------
@@ -29,25 +31,25 @@ import Graphics.Win32.GDI.Types
createSolidBrush :: COLORREF -> IO HBRUSH
createSolidBrush color =
failIfNull "CreateSolidBrush" $ c_CreateSolidBrush color
-foreign import stdcall unsafe "windows.h CreateSolidBrush"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateSolidBrush"
c_CreateSolidBrush :: COLORREF -> IO HBRUSH
createHatchBrush :: HatchStyle -> COLORREF -> IO HBRUSH
createHatchBrush style color =
failIfNull "CreateHatchBrush" $ c_CreateHatchBrush style color
-foreign import stdcall unsafe "windows.h CreateHatchBrush"
+foreign import WINDOWS_CCONV unsafe "windows.h CreateHatchBrush"
c_CreateHatchBrush :: HatchStyle -> COLORREF -> IO HBRUSH
createPatternBrush :: HBITMAP -> IO HBRUSH
createPatternBrush bitmap =
failIfNull "CreatePatternBrush" $ c_CreatePatternBrush bitmap
-foreign import stdcall unsafe "windows.h CreatePatternBrush"
+foreign import WINDOWS_CCONV unsafe "windows.h CreatePatternBrush"
c_CreatePatternBrush :: HBITMAP -> IO HBRUSH
deleteBrush :: HBRUSH -> IO ()
deleteBrush brush =
failIfFalse_ "DeleteBrush" $ c_DeleteBrush brush
-foreign import stdcall unsafe "windows.h DeleteObject"
+foreign import WINDOWS_CCONV unsafe "windows.h DeleteObject"
c_DeleteBrush :: HBRUSH -> IO Bool
----------------------------------------------------------------
@@ -67,7 +69,7 @@ type StockBrush = INT
getStockBrush :: StockBrush -> IO HBRUSH
getStockBrush sb =
failIfNull "GetStockBrush" $ c_GetStockBrush sb
-foreign import stdcall unsafe "windows.h GetStockObject"
+foreign import WINDOWS_CCONV unsafe "windows.h GetStockObject"
c_GetStockBrush :: StockBrush -> IO HBRUSH
----------------------------------------------------------------
Oops, something went wrong.

0 comments on commit bda29f7

Please sign in to comment.