fzeet 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/examples/Dialog/ColorDialog.rbw +21 -0
  2. data/examples/Dialog/FileDialog.rbw +47 -0
  3. data/examples/Dialog/FindReplaceDialog.rbw +38 -0
  4. data/examples/Dialog/FontDialog.rbw +33 -0
  5. data/examples/Dialog/PrintDialog.rbw +31 -0
  6. data/examples/Dialog/ShellFileDialog.rbw +43 -0
  7. data/examples/Version.rbw +5 -1
  8. data/lib/fzeet/Common.rb +6 -1
  9. data/lib/fzeet/Dialog/ColorDialog.rb +44 -0
  10. data/lib/fzeet/Dialog/Common.rb +84 -0
  11. data/lib/fzeet/Dialog/FileDialog.rb +83 -27
  12. data/lib/fzeet/Dialog/FindReplaceDialog.rb +105 -0
  13. data/lib/fzeet/Dialog/FontDialog.rb +39 -0
  14. data/lib/fzeet/Dialog/PrintDialog.rb +75 -0
  15. data/lib/fzeet/Dialog/ShellFileDialog.rb +133 -0
  16. data/lib/fzeet/Dialog.rb +5 -1
  17. data/lib/fzeet/windows/com.rb +16 -1
  18. data/lib/fzeet/windows/comdlg/ColorDialog.rb +34 -0
  19. data/lib/fzeet/windows/comdlg/Common.rb +37 -1
  20. data/lib/fzeet/windows/comdlg/FileDialog.rb +37 -0
  21. data/lib/fzeet/windows/comdlg/FindReplaceDialog.rb +50 -0
  22. data/lib/fzeet/windows/comdlg/FontDialog.rb +78 -0
  23. data/lib/fzeet/windows/comdlg/PrintDialog.rb +198 -0
  24. data/lib/fzeet/windows/comdlg.rb +4 -0
  25. data/lib/fzeet/windows/gdi.rb +3 -0
  26. data/lib/fzeet/windows/shell/{FolderDialog.rb → BrowseForFolder.rb} +11 -0
  27. data/lib/fzeet/windows/shell/Common.rb +56 -0
  28. data/lib/fzeet/windows/shell/FileDialog.rb +78 -0
  29. data/lib/fzeet/windows/shell.rb +2 -1
  30. data/lib/fzeet/windows/user/Message.rb +1 -0
  31. data/lib/fzeet/windows.rb +1 -0
  32. metadata +24 -6
  33. data/examples/Dialog/FileAndFolderDialog.rbw +0 -34
  34. data/lib/fzeet/Dialog/FolderDialog.rb +0 -45
@@ -0,0 +1,75 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ class PageSetupDialog
5
+ def initialize(opts = {})
6
+ _opts = {
7
+
8
+ }
9
+ badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
10
+ _opts.merge!(opts)
11
+
12
+ @struct = Windows::PAGESETUPDLG.new
13
+
14
+ @struct[:lStructSize] = @struct.size
15
+ @struct[:hInstance] = Windows.GetModuleHandle(nil)
16
+ @struct[:Flags] = Fzeet.flags(0, :psd_)
17
+ end
18
+
19
+ attr_reader :struct
20
+
21
+ def show(window = Application.window)
22
+ @struct[:hwndOwner] = window.handle
23
+
24
+ DialogResult.new((Windows.PageSetupDlg(@struct) == 0) ? Windows::IDCANCEL : Windows::IDOK)
25
+ end
26
+ end
27
+
28
+ class PrintDialog
29
+ def initialize(opts = {})
30
+ _opts = {
31
+
32
+ }
33
+ badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
34
+ _opts.merge!(opts)
35
+
36
+ @struct = Windows::PRINTDLG.new
37
+
38
+ @struct[:lStructSize] = 66
39
+ @struct[:hInstance] = Windows.GetModuleHandle(nil)
40
+ @struct[:Flags] = Fzeet.flags([:returndc, :usedevmodecopiesandcollate], :pd_)
41
+ end
42
+
43
+ attr_reader :struct
44
+
45
+ def show(window = Application.window)
46
+ @struct[:hwndOwner] = window.handle
47
+
48
+ DialogResult.new((Windows.PrintDlg(@struct) == 0) ? Windows::IDCANCEL : Windows::IDOK)
49
+ end
50
+ end
51
+
52
+ class PrintDialogEx
53
+ def initialize(opts = {})
54
+ _opts = {
55
+
56
+ }
57
+ badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
58
+ _opts.merge!(opts)
59
+
60
+ @struct = Windows::PRINTDLGEX.new
61
+
62
+ @struct[:lStructSize] = @struct.size
63
+ @struct[:hInstance] = Windows.GetModuleHandle(nil)
64
+ @struct[:Flags] = Fzeet.flags([:returndc, :usedevmodecopiesandcollate], :pd_)
65
+ end
66
+
67
+ attr_reader :struct
68
+
69
+ def show(window = Application.window)
70
+ @struct[:hwndOwner] = window.handle
71
+
72
+ DialogResult.new((Windows.PrintDlgEx(@struct) != Windows::S_OK) ? Windows::IDCANCEL : Windows::IDOK)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,133 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module ShellFileDialogMethods
5
+ def Show(*args)
6
+ raise "#{self}.#{__method__} failed." if
7
+ Windows.FAILED(result = vtbl[:Show].call(self, *args)) &&
8
+ result != Windows.HRESULT_FROM_WIN32(Windows::ERROR_CANCELLED) - 0x1_0000_0000
9
+
10
+ result
11
+ end
12
+
13
+ def path
14
+ result = nil
15
+
16
+ FFI::MemoryPointer.new(:pointer) { |psi|
17
+ next unless GetResult(psi) == Windows::S_OK
18
+
19
+ si = Windows::ShellItem.new(psi.read_pointer)
20
+
21
+ begin
22
+ FFI::MemoryPointer.new(:pointer) { |pwcs|
23
+ next unless si.GetDisplayName(Windows::SIGDN_FILESYSPATH, pwcs) == Windows::S_OK
24
+
25
+ wcs = pwcs.read_pointer
26
+
27
+ begin
28
+ result = Windows.WCSTOMBS(wcs)
29
+ ensure
30
+ Windows.CoTaskMemFree(wcs)
31
+ end
32
+ }
33
+ ensure
34
+ si.Release
35
+ end
36
+ }
37
+
38
+ result
39
+ end
40
+
41
+ def paths
42
+ result = []
43
+
44
+ FFI::MemoryPointer.new(:pointer) { |psia|
45
+ next unless GetResults(psia) == Windows::S_OK
46
+
47
+ sia = Windows::ShellItemArray.new(psia.read_pointer)
48
+
49
+ begin
50
+ FFI::MemoryPointer.new(:ulong) { |pc|
51
+ next unless sia.GetCount(pc) == Windows::S_OK
52
+
53
+ pc.read_long.times { |i|
54
+ FFI::MemoryPointer.new(:pointer) { |psi|
55
+ next unless sia.GetItemAt(i, psi) == Windows::S_OK
56
+
57
+ si = Windows::ShellItem.new(psi.read_pointer)
58
+
59
+ begin
60
+ FFI::MemoryPointer.new(:pointer) { |pwcs|
61
+ next unless si.GetDisplayName(Windows::SIGDN_FILESYSPATH, pwcs) == Windows::S_OK
62
+
63
+ wcs = pwcs.read_pointer
64
+
65
+ begin
66
+ result << Windows.WCSTOMBS(wcs)
67
+ ensure
68
+ Windows.CoTaskMemFree(wcs)
69
+ end
70
+ }
71
+ ensure
72
+ si.Release
73
+ end
74
+ }
75
+ }
76
+ }
77
+ ensure
78
+ sia.Release
79
+ end
80
+ }
81
+
82
+ result
83
+ end
84
+
85
+ def show(window = Application.window)
86
+ DialogResult.new((Show(window.handle) == Windows::S_OK) ? Windows::IDOK : Windows::IDCANCEL)
87
+ end
88
+ end
89
+
90
+ class ShellFileOpenDialog < Windows::FileOpenDialog
91
+ include ShellFileDialogMethods
92
+
93
+ def initialize(opts = {})
94
+ super()
95
+
96
+ begin
97
+ yield self
98
+ ensure
99
+ Release()
100
+ end if block_given?
101
+ end
102
+ end
103
+
104
+ class ShellFileSaveDialog < Windows::FileSaveDialog
105
+ include ShellFileDialogMethods
106
+
107
+ def initialize(opts = {})
108
+ super()
109
+
110
+ begin
111
+ yield self
112
+ ensure
113
+ Release()
114
+ end if block_given?
115
+ end
116
+ end
117
+
118
+ class ShellFolderDialog < Windows::FileOpenDialog
119
+ include ShellFileDialogMethods
120
+
121
+ def initialize(opts = {})
122
+ super()
123
+
124
+ SetOptions(Windows::FOS_PICKFOLDERS)
125
+
126
+ begin
127
+ yield self
128
+ ensure
129
+ Release()
130
+ end if block_given?
131
+ end
132
+ end
133
+ end
data/lib/fzeet/Dialog.rb CHANGED
@@ -1,2 +1,6 @@
1
1
  require_relative 'Dialog/FileDialog'
2
- require_relative 'Dialog/FolderDialog'
2
+ require_relative 'Dialog/ShellFileDialog' if Fzeet::Windows::WINVER.AtLeastWindowsVista?
3
+ require_relative 'Dialog/FontDialog'
4
+ require_relative 'Dialog/ColorDialog'
5
+ require_relative 'Dialog/FindReplaceDialog'
6
+ require_relative 'Dialog/PrintDialog'
@@ -20,12 +20,18 @@ module Fzeet
20
20
  E_ACCESSDENIED = 0x80070005 - 0x1_0000_0000
21
21
  E_PENDING = 0x8000000A - 0x1_0000_0000
22
22
 
23
+ FACILITY_WIN32 = 7
24
+
25
+ ERROR_CANCELLED = 1223
26
+
23
27
  def SUCCEEDED(hr) hr >= 0 end
24
28
  def FAILED(hr) hr < 0 end
29
+ def HRESULT_FROM_WIN32(x) (x <= 0) ? x : (x & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000 end
25
30
 
26
31
  module_function \
27
32
  :SUCCEEDED,
28
- :FAILED
33
+ :FAILED,
34
+ :HRESULT_FROM_WIN32
29
35
 
30
36
  def DetonateHresult(name, *args)
31
37
  failed = FAILED(result = send(name, *args)) and raise "#{name} failed (hresult #{format('%#08x', result)})."
@@ -264,5 +270,14 @@ module Fzeet
264
270
  ]
265
271
 
266
272
  Unknown = COM::Instance[IUnknown]
273
+
274
+ IObjectWithSite = COM::Interface[IUnknown,
275
+ GUID['FC4801A3-2BA9-11CF-A229-00AA003D7352'],
276
+
277
+ SetSite: [[:pointer], :long],
278
+ GetSite: [[:pointer, :pointer], :ulong]
279
+ ]
280
+
281
+ ObjectWithSite = COM::Callback[IObjectWithSite]
267
282
  end
268
283
  end
@@ -0,0 +1,34 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module Windows
5
+ CCERR_CHOOSECOLORCODES = 0x5000
6
+
7
+ CC_RGBINIT = 0x00000001
8
+ CC_FULLOPEN = 0x00000002
9
+ CC_PREVENTFULLOPEN = 0x00000004
10
+ CC_SHOWHELP = 0x00000008
11
+ CC_ENABLEHOOK = 0x00000010
12
+ CC_ENABLETEMPLATE = 0x00000020
13
+ CC_ENABLETEMPLATEHANDLE = 0x00000040
14
+ CC_SOLIDCOLOR = 0x00000080
15
+ CC_ANYCOLOR = 0x00000100
16
+
17
+ callback :CCHOOKPROC, [:pointer, :uint, :uint, :long], :uint
18
+
19
+ class CHOOSECOLOR < FFI::Struct
20
+ layout \
21
+ :lStructSize, :ulong,
22
+ :hwndOwner, :pointer,
23
+ :hInstance, :pointer,
24
+ :rgbResult, :ulong,
25
+ :lpCustColors, :pointer,
26
+ :Flags, :ulong,
27
+ :lCustData, :long,
28
+ :lpfnHook, :CCHOOKPROC,
29
+ :lpTemplateName, :pointer
30
+ end
31
+
32
+ attach_function :ChooseColor, :ChooseColorA, [:pointer], :int
33
+ end
34
+ end
@@ -1,9 +1,45 @@
1
- require_relative '../common'
1
+ require_relative '../user'
2
+ require_relative '../com'
2
3
 
3
4
  module Fzeet
4
5
  module Windows
5
6
  ffi_lib 'comdlg32'
6
7
  ffi_convention :stdcall
7
8
 
9
+ CDERR_DIALOGFAILURE = 0xFFFF
10
+ CDERR_GENERALCODES = 0x0000
11
+ CDERR_STRUCTSIZE = 0x0001
12
+ CDERR_INITIALIZATION = 0x0002
13
+ CDERR_NOTEMPLATE = 0x0003
14
+ CDERR_NOHINSTANCE = 0x0004
15
+ CDERR_LOADSTRFAILURE = 0x0005
16
+ CDERR_FINDRESFAILURE = 0x0006
17
+ CDERR_LOADRESFAILURE = 0x0007
18
+ CDERR_LOCKRESFAILURE = 0x0008
19
+ CDERR_MEMALLOCFAILURE = 0x0009
20
+ CDERR_MEMLOCKFAILURE = 0x000A
21
+ CDERR_NOHOOK = 0x000B
22
+ CDERR_REGISTERMSGFAIL = 0x000C
23
+
24
+ attach_function :CommDlgExtendedError, [], :ulong
25
+
26
+ CDM_FIRST = WM_USER + 100
27
+ CDM_LAST = WM_USER + 200
28
+
29
+ CDN_FIRST = 0x1_0000_0000 - 601
30
+ CDN_LAST = 0x1_0000_0000 - 699
31
+
32
+ LBSELCHSTRING = 'commdlg_LBSelChangedNotify'
33
+ SHAREVISTRING = 'commdlg_ShareViolation'
34
+ FILEOKSTRING = 'commdlg_FileNameOK'
35
+ COLOROKSTRING = 'commdlg_ColorOK'
36
+ SETRGBSTRING = 'commdlg_SetRGBColor'
37
+ HELPMSGSTRING = 'commdlg_help'
38
+ FINDMSGSTRING = 'commdlg_FindReplace'
39
+
40
+ CD_LBSELNOITEMS = -1
41
+ CD_LBSELCHANGE = 0
42
+ CD_LBSELSUB = 1
43
+ CD_LBSELADD = 2
8
44
  end
9
45
  end
@@ -2,6 +2,11 @@ require_relative 'Common'
2
2
 
3
3
  module Fzeet
4
4
  module Windows
5
+ FNERR_FILENAMECODES = 0x3000
6
+ FNERR_SUBCLASSFAILURE = 0x3001
7
+ FNERR_INVALIDFILENAME = 0x3002
8
+ FNERR_BUFFERTOOSMALL = 0x3003
9
+
5
10
  OFN_READONLY = 0x00000001
6
11
  OFN_OVERWRITEPROMPT = 0x00000002
7
12
  OFN_HIDEREADONLY = 0x00000004
@@ -66,5 +71,37 @@ module Fzeet
66
71
 
67
72
  attach_function :GetOpenFileName, :GetOpenFileNameA, [:pointer], :int
68
73
  attach_function :GetSaveFileName, :GetSaveFileNameA, [:pointer], :int
74
+
75
+ CDM_GETSPEC = CDM_FIRST + 0x0000
76
+ CDM_GETFILEPATH = CDM_FIRST + 0x0001
77
+ CDM_GETFOLDERPATH = CDM_FIRST + 0x0002
78
+ CDM_GETFOLDERIDLIST = CDM_FIRST + 0x0003
79
+ CDM_SETCONTROLTEXT = CDM_FIRST + 0x0004
80
+ CDM_HIDECONTROL = CDM_FIRST + 0x0005
81
+ CDM_SETDEFEXT = CDM_FIRST + 0x0006
82
+
83
+ CDN_INITDONE = CDN_FIRST - 0x0000
84
+ CDN_SELCHANGE = CDN_FIRST - 0x0001
85
+ CDN_FOLDERCHANGE = CDN_FIRST - 0x0002
86
+ CDN_SHAREVIOLATION = CDN_FIRST - 0x0003
87
+ CDN_HELP = CDN_FIRST - 0x0004
88
+ CDN_FILEOK = CDN_FIRST - 0x0005
89
+ CDN_TYPECHANGE = CDN_FIRST - 0x0006
90
+ CDN_INCLUDEITEM = CDN_FIRST - 0x0007
91
+
92
+ class OFNOTIFY < FFI::Struct
93
+ layout \
94
+ :hdr, NMHDR,
95
+ :lpOFN, :pointer,
96
+ :pszFile, :pointer
97
+ end
98
+
99
+ class OFNOTIFYEX < FFI::Struct
100
+ layout \
101
+ :hdr, NMHDR,
102
+ :lpOFN, :pointer,
103
+ :psf, :pointer,
104
+ :pidl, :pointer
105
+ end
69
106
  end
70
107
  end
@@ -0,0 +1,50 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module Windows
5
+ FRERR_FINDREPLACECODES = 0x4000
6
+ FRERR_BUFFERLENGTHZERO = 0x4001
7
+
8
+ FR_DOWN = 0x00000001
9
+ FR_WHOLEWORD = 0x00000002
10
+ FR_MATCHCASE = 0x00000004
11
+ FR_FINDNEXT = 0x00000008
12
+ FR_REPLACE = 0x00000010
13
+ FR_REPLACEALL = 0x00000020
14
+ FR_DIALOGTERM = 0x00000040
15
+ FR_SHOWHELP = 0x00000080
16
+ FR_ENABLEHOOK = 0x00000100
17
+ FR_ENABLETEMPLATE = 0x00000200
18
+ FR_NOUPDOWN = 0x00000400
19
+ FR_NOMATCHCASE = 0x00000800
20
+ FR_NOWHOLEWORD = 0x00001000
21
+ FR_ENABLETEMPLATEHANDLE = 0x00002000
22
+ FR_HIDEUPDOWN = 0x00004000
23
+ FR_HIDEMATCHCASE = 0x00008000
24
+ FR_HIDEWHOLEWORD = 0x00010000
25
+ FR_RAW = 0x00020000
26
+ FR_MATCHDIAC = 0x20000000
27
+ FR_MATCHKASHIDA = 0x40000000
28
+ FR_MATCHALEFHAMZA = 0x80000000
29
+
30
+ callback :FRHOOKPROC, [:pointer, :uint, :uint, :long], :uint
31
+
32
+ class FINDREPLACE < FFI::Struct
33
+ layout \
34
+ :lStructSize, :ulong,
35
+ :hwndOwner, :pointer,
36
+ :hInstance, :pointer,
37
+ :Flags, :ulong,
38
+ :lpstrFindWhat, :pointer,
39
+ :lpstrReplaceWith, :pointer,
40
+ :wFindWhatLen, :ushort,
41
+ :wReplaceWithLen, :ushort,
42
+ :lCustData, :long,
43
+ :lpfnHook, :FRHOOKPROC,
44
+ :lpTemplateName, :pointer,
45
+ end
46
+
47
+ attach_function :FindText, :FindTextA, [:pointer], :pointer
48
+ attach_function :ReplaceText, :ReplaceTextA, [:pointer], :pointer
49
+ end
50
+ end
@@ -0,0 +1,78 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module Windows
5
+ CFERR_CHOOSEFONTCODES = 0x2000
6
+ CFERR_NOFONTS = 0x2001
7
+ CFERR_MAXLESSTHANMIN = 0x2002
8
+
9
+ CF_SCREENFONTS = 0x00000001
10
+ CF_PRINTERFONTS = 0x00000002
11
+ CF_BOTH = CF_SCREENFONTS | CF_PRINTERFONTS
12
+ CF_SHOWHELP = 0x00000004
13
+ CF_ENABLEHOOK = 0x00000008
14
+ CF_ENABLETEMPLATE = 0x00000010
15
+ CF_ENABLETEMPLATEHANDLE = 0x00000020
16
+ CF_INITTOLOGFONTSTRUCT = 0x00000040
17
+ CF_USESTYLE = 0x00000080
18
+ CF_EFFECTS = 0x00000100
19
+ CF_APPLY = 0x00000200
20
+ CF_ANSIONLY = 0x00000400
21
+ CF_SCRIPTSONLY = CF_ANSIONLY
22
+ CF_NOVECTORFONTS = 0x00000800
23
+ CF_NOOEMFONTS = CF_NOVECTORFONTS
24
+ CF_NOSIMULATIONS = 0x00001000
25
+ CF_LIMITSIZE = 0x00002000
26
+ CF_FIXEDPITCHONLY = 0x00004000
27
+ CF_WYSIWYG = 0x00008000
28
+ CF_FORCEFONTEXIST = 0x00010000
29
+ CF_SCALABLEONLY = 0x00020000
30
+ CF_TTONLY = 0x00040000
31
+ CF_NOFACESEL = 0x00080000
32
+ CF_NOSTYLESEL = 0x00100000
33
+ CF_NOSIZESEL = 0x00200000
34
+ CF_SELECTSCRIPT = 0x00400000
35
+ CF_NOSCRIPTSEL = 0x00800000
36
+ CF_NOVERTFONTS = 0x01000000
37
+ CF_INACTIVEFONTS = 0x02000000
38
+
39
+ callback :CFHOOKPROC, [:pointer, :uint, :uint, :long], :uint
40
+
41
+ SIMULATED_FONTTYPE = 0x8000
42
+ PRINTER_FONTTYPE = 0x4000
43
+ SCREEN_FONTTYPE = 0x2000
44
+ BOLD_FONTTYPE = 0x0100
45
+ ITALIC_FONTTYPE = 0x0200
46
+ REGULAR_FONTTYPE = 0x0400
47
+ PS_OPENTYPE_FONTTYPE = 0x10000
48
+ TT_OPENTYPE_FONTTYPE = 0x20000
49
+ TYPE1_FONTTYPE = 0x40000
50
+ SYMBOL_FONTTYPE = 0x80000
51
+
52
+ class CHOOSEFONT < FFI::Struct
53
+ layout \
54
+ :lStructSize, :ulong,
55
+ :hwndOwner, :pointer,
56
+ :hDC, :pointer,
57
+ :lpLogFont, :pointer,
58
+ :iPointSize, :int,
59
+ :Flags, :ulong,
60
+ :rgbColors, :ulong,
61
+ :lCustData, :long,
62
+ :lpfnHook, :CFHOOKPROC,
63
+ :lpTemplateName, :pointer,
64
+ :hInstance, :pointer,
65
+ :lpszStyle, :pointer,
66
+ :nFontType, :ushort,
67
+ :___MISSING_ALIGNMENT__, :ushort,
68
+ :nSizeMin, :int,
69
+ :nSizeMax, :int
70
+ end
71
+
72
+ attach_function :ChooseFont, :ChooseFontA, [:pointer], :int
73
+
74
+ WM_CHOOSEFONT_GETLOGFONT = WM_USER + 1
75
+ WM_CHOOSEFONT_SETLOGFONT = WM_USER + 101
76
+ WM_CHOOSEFONT_SETFLAGS = WM_USER + 102
77
+ end
78
+ end
@@ -0,0 +1,198 @@
1
+ require_relative 'Common'
2
+
3
+ module Fzeet
4
+ module Windows
5
+ PDERR_PRINTERCODES = 0x1000
6
+ PDERR_SETUPFAILURE = 0x1001
7
+ PDERR_PARSEFAILURE = 0x1002
8
+ PDERR_RETDEFFAILURE = 0x1003
9
+ PDERR_LOADDRVFAILURE = 0x1004
10
+ PDERR_GETDEVMODEFAIL = 0x1005
11
+ PDERR_INITFAILURE = 0x1006
12
+ PDERR_NODEVICES = 0x1007
13
+ PDERR_NODEFAULTPRN = 0x1008
14
+ PDERR_DNDMMISMATCH = 0x1009
15
+ PDERR_CREATEICFAILURE = 0x100A
16
+ PDERR_PRINTERNOTFOUND = 0x100B
17
+ PDERR_DEFAULTDIFFERENT = 0x100C
18
+
19
+ PSD_DEFAULTMINMARGINS = 0x00000000
20
+ PSD_INWININIINTLMEASURE = 0x00000000
21
+ PSD_MINMARGINS = 0x00000001
22
+ PSD_MARGINS = 0x00000002
23
+ PSD_INTHOUSANDTHSOFINCHES = 0x00000004
24
+ PSD_INHUNDREDTHSOFMILLIMETERS = 0x00000008
25
+ PSD_DISABLEMARGINS = 0x00000010
26
+ PSD_DISABLEPRINTER = 0x00000020
27
+ PSD_NOWARNING = 0x00000080
28
+ PSD_DISABLEORIENTATION = 0x00000100
29
+ PSD_RETURNDEFAULT = 0x00000400
30
+ PSD_DISABLEPAPER = 0x00000200
31
+ PSD_SHOWHELP = 0x00000800
32
+ PSD_ENABLEPAGESETUPHOOK = 0x00002000
33
+ PSD_ENABLEPAGESETUPTEMPLATE = 0x00008000
34
+ PSD_ENABLEPAGESETUPTEMPLATEHANDLE = 0x00020000
35
+ PSD_ENABLEPAGEPAINTHOOK = 0x00040000
36
+ PSD_DISABLEPAGEPAINTING = 0x00080000
37
+ PSD_NONETWORKBUTTON = 0x00200000
38
+
39
+ callback :PAGESETUPHOOK, [:pointer, :uint, :uint, :long], :uint
40
+ callback :PAGEPAINTHOOK, [:pointer, :uint, :uint, :long], :uint
41
+
42
+ class PAGESETUPDLG < FFI::Struct
43
+ layout \
44
+ :lStructSize, :ulong,
45
+ :hwndOwner, :pointer,
46
+ :hDevMode, :pointer,
47
+ :hDevNames, :pointer,
48
+ :Flags, :ulong,
49
+ :ptPaperSize, POINT,
50
+ :rtMinMargin, RECT,
51
+ :rtMargin, RECT,
52
+ :hInstance, :pointer,
53
+ :lCustData, :long,
54
+ :lpfnPageSetupHook, :PAGESETUPHOOK,
55
+ :lpfnPagePaintHook, :PAGEPAINTHOOK,
56
+ :lpPageSetupTemplateName, :pointer,
57
+ :hPageSetupTemplate, :pointer
58
+ end
59
+
60
+ attach_function :PageSetupDlg, :PageSetupDlgA, [:pointer], :int
61
+
62
+ WM_PSD_PAGESETUPDLG = WM_USER
63
+ WM_PSD_FULLPAGERECT = WM_USER + 1
64
+ WM_PSD_MINMARGINRECT = WM_USER + 2
65
+ WM_PSD_MARGINRECT = WM_USER + 3
66
+ WM_PSD_GREEKTEXTRECT = WM_USER + 4
67
+ WM_PSD_ENVSTAMPRECT = WM_USER + 5
68
+ WM_PSD_YAFULLPAGERECT = WM_USER + 6
69
+
70
+ DN_DEFAULTPRN = 0x0001
71
+
72
+ class DEVNAMES < FFI::Struct
73
+ layout \
74
+ :wDriverOffset, :ushort,
75
+ :wDeviceOffset, :ushort,
76
+ :wOutputOffset, :ushort,
77
+ :wDefault, :ushort
78
+ end
79
+
80
+ PD_ALLPAGES = 0x00000000
81
+ PD_SELECTION = 0x00000001
82
+ PD_PAGENUMS = 0x00000002
83
+ PD_NOSELECTION = 0x00000004
84
+ PD_NOPAGENUMS = 0x00000008
85
+ PD_COLLATE = 0x00000010
86
+ PD_PRINTTOFILE = 0x00000020
87
+ PD_PRINTSETUP = 0x00000040
88
+ PD_NOWARNING = 0x00000080
89
+ PD_RETURNDC = 0x00000100
90
+ PD_RETURNIC = 0x00000200
91
+ PD_RETURNDEFAULT = 0x00000400
92
+ PD_SHOWHELP = 0x00000800
93
+ PD_ENABLEPRINTHOOK = 0x00001000
94
+ PD_ENABLESETUPHOOK = 0x00002000
95
+ PD_ENABLEPRINTTEMPLATE = 0x00004000
96
+ PD_ENABLESETUPTEMPLATE = 0x00008000
97
+ PD_ENABLEPRINTTEMPLATEHANDLE = 0x00010000
98
+ PD_ENABLESETUPTEMPLATEHANDLE = 0x00020000
99
+ PD_USEDEVMODECOPIES = 0x00040000
100
+ PD_USEDEVMODECOPIESANDCOLLATE = 0x00040000
101
+ PD_DISABLEPRINTTOFILE = 0x00080000
102
+ PD_HIDEPRINTTOFILE = 0x00100000
103
+ PD_NONETWORKBUTTON = 0x00200000
104
+ PD_CURRENTPAGE = 0x00400000
105
+ PD_NOCURRENTPAGE = 0x00800000
106
+ PD_EXCLUSIONFLAGS = 0x01000000
107
+ PD_USELARGETEMPLATE = 0x10000000
108
+
109
+ callback :PRINTHOOKPROC, [:pointer, :uint, :uint, :long], :uint
110
+ callback :SETUPHOOKPROC, [:pointer, :uint, :uint, :long], :uint
111
+
112
+ class PRINTDLG < FFI::Struct
113
+ layout \
114
+ :lStructSize, :ulong, # Set to 66 explicitly, NOT to struct.size
115
+ :hwndOwner, :pointer,
116
+ :hDevMode, :pointer,
117
+ :hDevNames, :pointer,
118
+ :hDC, :pointer,
119
+ :Flags, :ulong,
120
+ :nFromPage, :ushort,
121
+ :nToPage, :ushort,
122
+ :nMinPage, :ushort,
123
+ :nMaxPage, :ushort,
124
+ :nCopies, :ushort,
125
+ :hInstance, :pointer, 34,
126
+ :lCustData, :long, 38,
127
+ :lpfnPrintHook, :PRINTHOOKPROC, 42,
128
+ :lpfnSetupHook, :SETUPHOOKPROC, 46,
129
+ :lpPrintTemplateName, :pointer, 50,
130
+ :lpSetupTemplateName, :pointer, 54,
131
+ :hPrintTemplate, :pointer, 58,
132
+ :hSetupTemplate, :pointer, 62
133
+ end
134
+
135
+ attach_function :PrintDlg, :PrintDlgA, [:pointer], :int
136
+
137
+ #PD_EXCL_COPIESANDCOLLATE = DM_COPIES | DM_COLLATE
138
+
139
+ class PRINTPAGERANGE < FFI::Struct
140
+ layout \
141
+ :nFromPage, :ulong,
142
+ :nToPage, :ulong
143
+ end
144
+
145
+ IPrintDialogCallback = COM::Interface[IUnknown,
146
+ GUID['5852A2C3-6530-11D1-B6A3-0000F8757BF9'],
147
+
148
+ InitDone: [[], :long],
149
+ SelectionChange: [[], :long],
150
+ HandleMessage: [[:pointer, :uint, :uint, :long, :pointer], :long]
151
+ ]
152
+
153
+ PrintDialogCallback = COM::Callback[IPrintDialogCallback]
154
+
155
+ IPrintDialogServices = COM::Interface[IUnknown,
156
+ GUID['509AAEDA-5639-11D1-B6A1-0000F8757BF9'],
157
+
158
+ GetCurrentDevMode: [[:pointer, :pointer], :long],
159
+ GetCurrentPrinterName: [[:buffer_out, :pointer], :long],
160
+ GetCurrentPortName: [[:buffer_out, :pointer], :long]
161
+ ]
162
+
163
+ PrintDialogServices = COM::Instance[IPrintDialogServices]
164
+
165
+ START_PAGE_GENERAL = 0xffffffff
166
+
167
+ PD_RESULT_CANCEL = 0
168
+ PD_RESULT_PRINT = 1
169
+ PD_RESULT_APPLY = 2
170
+
171
+ class PRINTDLGEX < FFI::Struct
172
+ layout \
173
+ :lStructSize, :ulong,
174
+ :hwndOwner, :pointer,
175
+ :hDevMode, :pointer,
176
+ :hDevNames, :pointer,
177
+ :hDC, :pointer,
178
+ :Flags, :ulong,
179
+ :Flags2, :ulong,
180
+ :ExclusionFlags, :ulong,
181
+ :nPageRanges, :ulong,
182
+ :nMaxPageRanges, :ulong,
183
+ :lpPageRanges, :pointer,
184
+ :nMinPage, :ulong,
185
+ :nMaxPage, :ulong,
186
+ :nCopies, :ulong,
187
+ :hInstance, :pointer,
188
+ :lpPrintTemplateName, :pointer,
189
+ :lpCallback, :pointer,
190
+ :nPropertyPages, :ulong,
191
+ :lphPropertyPages, :pointer,
192
+ :nStartPage, :ulong,
193
+ :dwResultAction, :ulong
194
+ end
195
+
196
+ attach_function :PrintDlgEx, :PrintDlgExA, [:pointer], :long
197
+ end
198
+ end