Module: Kernel

Defined in:
lib/autocad/message_box.rb

Overview

msgbox_yesno('Do you want to continue?') do |y| if y puts 'proceeding with ...' else puts 'cancelled ...' end end

msgbox('We are finished here')

loop do puts WinAPI.get_text_of_active_window sleep 1 end

Class Method Summary collapse

Class Method Details

.L(str) ⇒ Object



75
76
77
# File 'lib/autocad/message_box.rb', line 75

def L(str)
  str.encode("UTF-16LE")
end

.msgbox(content, title: "Alert") ⇒ Object



92
93
94
# File 'lib/autocad/message_box.rb', line 92

def msgbox(content, title: "Alert")
  WinAPI::MessageBoxW(0, L(content), L(title), WinAPI::MB::BTN::OK)
end

.msgbox_yesno(content, title: "Alert") {|result| ... } ⇒ Object

msg_box_yesno("Do you want to continue") do |y| if y puts "proceeding" else puts "cancelled" end end

Yields:

  • (result)


87
88
89
90
# File 'lib/autocad/message_box.rb', line 87

def msgbox_yesno(content, title: "Alert")
  result = WinAPI::MessageBoxW(0, L(content), L(title), WinAPI::MB::BTN::YESNO) == WinAPI::MB::YES
  yield(result)
end