Archive for 6月, 2012
-
Hello, Win32 API(ClojureCLR) World!
Posted on 6月 21st, 2012 by cx20
Win32 API(ClojureCLR)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
ClojureCLR には Win32 API を直接呼び出す機能は実装されていないが、C# を経由することで、Win32 API を呼び出すことが可能となっている。ソースコード(C#)
using System; using System.Runtime.InteropServices; namespace Win32Lib { public class Win32 { [DllImport("user32.dll", CharSet=CharSet.Auto)] public extern static uint MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType); } }
コンパイル方法(C#)
C:¥> csc /target:library Win32Lib.cs
ソースコード(ClojureCLR)
(System.Reflection.Assembly/LoadFrom "Win32Lib.dll") (Win32Lib.Win32/MessageBox 0 "Hello, Win32 API(ClojureCLR) World!" "Hello, World!", 0 )
実行方法
C:¥> Clojure.Main hello.clj
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API(ClojureCLR) World! --------------------------- OK ---------------------------
-
Hello, Win32 API(IronScheme) World!
Posted on 6月 20th, 2012 by cx20
Win32 API(IronScheme)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
以下は IronScheme による Win32 API 呼出し例となっている。ソースコード
(import (rnrs) (ironscheme clr) ) (define msgbox (pinvoke-call user32 MessageBox int (intptr string string int))) (msgbox 0 "Hello, Win32 API(IronScheme) World!" "Hello, World!" 0 )
実行方法
C:¥> isc hello.ss
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API(IronScheme) World! --------------------------- OK ---------------------------
-
Hello, Win32 API(IronRuby) World!
Posted on 6月 19th, 2012 by cx20
Win32 API(IronRuby)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
IronRuby には Win32 API を直接呼び出す機能は実装されていないが、C# を経由することで、Win32 API を呼び出すことが可能となっている。ソースコード(C#)
using System; using System.Runtime.InteropServices; namespace Win32Lib { public class Win32 { [DllImport("user32.dll", CharSet=CharSet.Auto)] public extern static uint MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType); } }
コンパイル方法(C#)
C:¥> csc /target:library Win32Lib.cs
ソースコード(IronRuby)
require 'System' require 'Win32Lib' include System include Win32Lib Win32.MessageBox( IntPtr.Zero, "Hello, Win32 API(IronRuby) World!", "Hello, World!", 0 )
実行方法
C:¥> ir hello.rb
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API(IronRuby) World! --------------------------- OK ---------------------------
-
Hello, Win32 API(IronPython) World!
Posted on 6月 18th, 2012 by cx20
Win32 API(IronPython)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
以下は IronPython にて clrtype ライブラリを使用した Win32 API の呼出し例である。ソースコード
import clr import clrtype import System from System.Reflection import BindingFlags class Win32(object): __metaclass__ = clrtype.ClrClass from System.Runtime.InteropServices import DllImportAttribute DllImport = clrtype.attribute(DllImportAttribute) @staticmethod @DllImport("user32.dll") @clrtype.accepts(System.IntPtr, System.String, System.String, System.UInt32) @clrtype.returns(System.Int32) def MessageBox(hwnd, text, caption, type): raise RuntimeError("Runtime Error") Win32.MessageBox(System.IntPtr.Zero, "Hello, Win32 API(IronPython) World!", "Hello, World!", 0)
実行方法
C:¥> ipy hello.py
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API(IronPython) World! --------------------------- OK ---------------------------
-
Hello, Windows Forms(UWSC) World!
Posted on 6月 17th, 2012 by cx20
Windows Forms(UWSC)
Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
以下は UWSC における Windows フォーム の例となっている。
UWSC 自体は .NET 対応言語ではないが、v4.6b より追加された PowerShell() 関数により、PowerShell 経由で Windows フォームが利用できるようになっている。ソースコード(UWSC + PowerShell)
Option Explicit Main() Procedure Main() PowerShell( helloBlock, True, True ) FEnd TextBlock helloBlock [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $form = New-Object Windows.Forms.Form $form.Size = New-Object Drawing.Size 640,480 $form.Text = "Hello, World!" $label1 = New-Object Windows.Forms.Label $label1.Size = New-Object Drawing.Size 320, 20 $label1.Text = "Hello, Windows Forms(UWSC) World!" $form.Controls.Add( $label1 ) $form.ShowDialog() EndTextBlock
ソースコード(UWSC + PowerShell + C#)
Option Explicit Main() Procedure Main() PowerShell( helloBlock, True, True ) FEnd TextBlock helloBlock $source = @" using System; using System.Drawing; using System.Windows.Forms; public class HelloForm : Form { public HelloForm() { this.Size = new Size( 640, 480 ); this.Text = "Hello, World!"; Label label1 = new Label(); label1.Size = new Size( 320, 20 ); label1.Text = "Hello, Windows Forms(UWSC) World!"; this.Controls.Add( label1 ); } [STAThread] public static void Main() { HelloForm form = new HelloForm(); Application.Run(form); } } "@ Add-Type -Language CSharp -TypeDefinition $source -ReferencedAssemblies ("System.Drawing", "System.Windows.Forms" ) [HelloForm]::Main() EndTextBlock
ソースコード(UWSC + PowerShell + VB.NET)
Option Explicit Main() Procedure Main() PowerShell( helloBlock, True, True ) FEnd TextBlock helloBlock $source = @" Imports System Imports System.Drawing Imports System.Windows.Forms Public Class HelloForm Inherits Form Public Sub New() Me.Size = New Size( 640, 480 ) Me.Text = "Hello, World!" Dim label1 As New Label label1.Size = New Size( 320, 20 ) label1.Text = "Hello, Windows Forms(UWSC) World!" Me.Controls.Add( label1 ) End Sub <STAThread> _ Shared Sub Main() Dim form As New HelloForm() Application.Run(form) End Sub End Class "@ Add-Type -Language VisualBasic -TypeDefinition $source -ReferencedAssemblies ("System.Drawing", "System.Windows.Forms" ) [HelloForm]::Main() EndTextBlock
実行方法
C:¥> uwsc /K hello.uws
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Windows Forms(UWSC) World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, Windows Forms(Oxygene) World!
Posted on 6月 16th, 2012 by cx20
Windows Forms(Oxygene)
Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
以下は Oxygene における Windows フォーム の例となっている。ソースコード
namespace hello; interface uses System, System.Drawing, System.Windows.Forms; type HelloForm = class(System.Windows.Forms.Form) public constructor; class method Main(args: array of String): Integer; end; implementation constructor HelloForm; var label1: Label; begin self.Size := new Size( 640, 480 ); self.Text := "Hello, World!"; label1 := new Label(); label1.Size := new Size( 320, 20 ); label1.Text := "Hello, Windows Forms(Oxygene) World!"; self.Controls.Add( label1 ); end; [STAThread] class method HelloForm.Main(args: array of String): Integer; begin using form := new HelloForm do Application.Run(form); end; end.
実行方法
C:¥> oxygene Hello.pas ^ -type:winexe ^ -ref:System.dll;System.Drawing.dll;System.Windows.Forms.dll
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Windows Forms(Oxygene) World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, Windows Forms(Nemerle) World!
Posted on 6月 15th, 2012 by cx20
Windows Forms(Nemerle)
Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
以下は Nemerle における Windows フォーム の例となっている。ソースコード
using System.Drawing; using System.Windows.Forms; class HelloForm : Form { public this() { Size = Size( 640, 480 ); Text = "Hello, World"; def label1 = Label(); label1.Size = Size( 320, 20 ); label1.Text = "Hello, Windows Forms(Nemerle) World!"; Controls.Add( label1 ); } public static Main() : void { def form = HelloForm(); Application.Run( form ); } }
実行方法
C:¥> ncc -o hello -target:winexe -r:System.Windows.Forms hello.n
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Windows Forms(Nemerle) World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, Windows Forms(Boo) World!
Posted on 6月 14th, 2012 by cx20
Windows Forms(Boo)
Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
以下は Boo における Windows フォーム の例となっている。ソースコード
import System import System.Drawing import System.Windows.Forms class HelloForm( Form ): def constructor(): super() self.Size = Size( 640, 480 ) self.Text = "Hello, World!" label1 = Label() label1.Size = Size( 320, 20 ) label1.Text = "Hello, Windows Forms(Boo) World!" self.Controls.Add( label1 ) [STAThread] def Main(argv as (string)): form = HelloForm() Application.Run( form )
実行方法
C:¥> booc -target:winexe Hello.boo
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Windows Forms(Boo) World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, Windows Forms(Cobra) World!
Posted on 6月 13th, 2012 by cx20
Windows Forms(Cobra)
Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
以下は Cobra における Windows フォーム の例となっている。ソースコード
use System.Windows.Forms use System.Drawing class HelloForm inherits Form cue init base.init .size = Size( 640, 480 ) .text = "Hello, World" label1 = Label() label1.size = Size( 320, 20 ) label1.text = "Hello, Windows Forms(Cobra) World!" .controls.add( label1 ) class Program def main is shared has STAThread form = HelloForm() Application.run( form )
実行方法
C:¥> cobra -target:winexe -compile Hello.cobra
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Windows Forms(Cobra) World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, Windows Forms(Phalanger) World!
Posted on 6月 12th, 2012 by cx20
Windows Forms(Phalanger)
Windows フォーム(Windows Forms)は .NET Framework におけるユーザーインターフェイス基盤である。Windows アプリケーションにおけるウィンドウやダイアログに対応する。
以下は Phalanger における Windows フォーム の例となっている。ソースコード
<? use System; use SystemWindowsForms; use SystemDrawing; class HelloForm extends SystemWindowsFormsForm { public function __construct() { $this->Size = new SystemDrawingSize( 640, 480 ); $this->Text = 'Hello, World!'; $label1 = new SystemWindowsFormsLabel(); $label1->Size = new SystemDrawingSize( 320, 20 ); $label1->Text = 'Hello, Windows Forms(Phalanger) World!'; $this->Controls->Add( $label1 ); } static function Main() { FormsApplication::Run(new HelloForm()); } } ?>
ソースコード(アプリケーション設定ファイル)
<?xml version="1.0" encoding="utf-8"?> <configuration> <phpNet> <classLibrary> <add assembly="mscorlib" /> <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </classLibrary> </phpNet> </configuration>
実行方法
C:¥> phpc /pure /target:winexe Hello.php
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Windows Forms(Phalanger) World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+