中国开发网: 论坛: 程序员情感CBD: 贴子 79684
JoJo
我靠,不容易啊,花了我一个多小时。Eiffel#(Eiffel for .net)的HelloWorld
indexing
description : "[
Summary description for MAIN_FORM
]"
date : "2005年1月11日 9:56:07"
revision : "1.0.0"

class
MAIN_FORM

inherit
WINFORMS_FORM
undefine
finalize,
get_hash_code,
equals,
to_string
redefine
dispose_boolean
end

ANY
redefine
default_create
end

create
default_create

feature {NONE} -- Initialization

default_create is
do
-- | Required for Windows.Forms Class Composition Designer support

initialize_component

-- | TODO: Add any constructor code after `initialize_component' call
end

feature {NONE} -- Access

components: SYSTEM_DLL_ICONTAINER
-- Required for Windows Form Designer support
my_button: WINFORMS_BUTTON
-- System.WIndows.Forms.Button

feature {NONE} -- Basic Operations

set_my_button_prop is
local
b_width: INTEGER
b_height: INTEGER
b_left: INTEGER
b_top: INTEGER
do
b_width := 100
b_height := 24
b_left := (client_size.Width - b_width) // 2 --缺乏帮助,蒙了半天才知道//是整除
b_top := (client_size.Height - b_height) // 2
my_button.set_size (create {DRAWING_SIZE}.make (b_width, b_height))
my_button.set_tab_index (1)
my_button.set_anchor (feature {WINFORMS_ANCHOR_STYLES}.left | feature {WINFORMS_ANCHOR_STYLES}.right)
my_button.set_location (create {DRAWING_POINT}.make (b_left, b_top))
my_button.set_text ("Hello, World")
my_button.set_accessible_name ("DefaultAction")
my_button.add_click (create {EVENT_HANDLER}.make (Current, $on_my_button_clicked))
end

initialize_component is
-- Required for Windows Forms Designer support, do not modify with Text Editor
local
f_width: INTEGER
f_height: INTEGER
do
f_width := 320
f_height := 240

create {SYSTEM_DLL_SYSTEM_CONTAINER} components.make
create {WINFORMS_BUTTON} my_button.make

suspend_layout
set_size (create {DRAWING_SIZE}.make (f_width,f_height))
set_text ("MAIN_FORM")

set_my_button_prop

controls.add (my_button)

resume_layout_boolean (False)
end

feature {MAIN_FORM} -- Basic Operations

dispose_boolean (is_disposing: BOOLEAN) is
-- Clean up any resources being used
do
if is_disposing then
if components /= Void then
components.dispose
end
end
Precursor {WINFORMS_FORM} (is_disposing)
end

on_my_button_clicked (sender: SYSTEM_OBJECT; args: EVENT_ARGS) is
local
msg: STRING
res: WINFORMS_DIALOG_RESULT
do
msg := "Hello, Eiffel."
res := feature {WINFORMS_MESSAGE_BOX}.show (msg)
end

end -- class MAIN_FORM

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录