Sha256: f341cfc8417135df2d1e1b2a6bd0a6083593f0a645a0e78c49053b03c1be6177

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 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.11 lib/dde/dde_string.rb