Sha256: c2c3c511b9d40d6536c7a5a22261551e3f91bc1d284fb8556ed66780c8dd7381

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module DDE

  # Class encapsulates DDE string. In addition to normal string behavior,
  # it also has *handle* that can be passed to dde functions
  class DdeString < String
    include Win::DDE

    attr_accessor :handle, # string handle passable to DDEML functions
                  :instance_id, # instance id of DDE app that created this DdeString
                  :code_page, # Windows code page for this string (CP_WINANSI or CP_WINUNICODE)
                  :name # ORIGINAL string used to create this DdeString

    # Given the DDE application instance_id, you cane create DdeStrings
    # either from regular string or from known DdeString handle
    def initialize(instance_id, string_or_handle, code_page=CP_WINANSI)
      @instance_id = instance_id
      @code_page = code_page

      begin
        if string_or_handle.is_a? String
          @name = string_or_handle
          error unless @handle = dde_create_string_handle(@instance_id, @name, @code_page)
        else
          @handle = string_or_handle
          error unless @name = dde_query_string(@instance_id, @handle, @code_page)
        end
      rescue => e
      end
      raise DDE::Errors::StringError, "Failed to initialize DDE string: #{e} #{e.backtrace.join("\n")}" unless @handle && @name && !e
      super @name
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dde-0.2.9 lib/dde/dde_string.rb