我正在开发一个F#控制台应用程序。在属性中,我将应用程序的输出类型设置为Windows应用程序以隐藏控制台。我也创建了一个表单来代替它。目前我只有一个没有控件的简单表单。为了制作表格,我添加了对System.Windows.Forms
和System.Drawing
的引用,并将它们与System.Runtime.InteropServices
一起打开。在F#中扩展Aero Glass(PInvoke)
我不知道该怎么做的部分是扩展气动玻璃。有很多关于如何在C#中使用Exaples的例子。例如,这里是API调用和利润结构:
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
}
[DllImport("dwmapi.dll")]
pubic static extend int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
从Form_Load事件的API调用:
MARGINS margins = new MARGINS();
margins.cxLeftWidth = 0;
margins.cxRightWidth = 100;
margins.cyTopHeight = 0;
margins.cyBottomHeight = 0;
int result = DwmExtendFrameIntoClientArea(this.Handle, ref margins);
这是我已经走到这一步,在F#:
的API调用和利润结构:
[<StructLayout(LayoutKind.Sequential)>]
type MARGINS =
struct
val cxLeftWidth : int
val cxRightWidth : int
val cyTopHeight : int
val cyBottomHeigh t: int
new(left, right, top, bottom) = { cxLeftWidth = left; cxRightWidth = right; cyTopHeight = top; cyBottomHeigh = bottom } (*Is there any other way to do this?*)
end
[<DllImport("dwmapi.dll")>]
extend int DwmExtendFrameIntoClientArea(IntPtr hWnd, (*I need help here*))
从Form_Load事件的API调用:
let margins = new MARGINS(0, 100, 0, 0); (*Is there any other way to do this?*)
let result : int = DwmExtendFrameIntoClientArea(this.Handle, (*I need help here*))
我一直在四处搜寻,但在F#中找不到像使用ref
这样的参数。我知道在C#中编写代码要容易得多,但编写int F#代码后面的代码会更容易,因为它是一种功能性编程语言,我正在编写的整个程序都是围绕函数定向的。我知道这是纯粹的装饰,但请帮助。
`[]`从我理解的这是结构的默认设置,是否正确? –
2014-08-08 16:15:57