system.win32.bmx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. SuperStrict
  2. Import BRL.System
  3. Import "system.win32.c"
  4. Import "-lshell32"
  5. Import "-lcomctl32"
  6. Const WM_BBSYNCOP:Int=$7001 'wp=function, lp=arg
  7. Extern
  8. Function bbSystemStartup()
  9. Function bbSystemPoll()
  10. Function bbSystemWait()
  11. Function bbSystemMoveMouse( x:Int,y:Int )
  12. Function bbSystemSetMouseVisible( visible:Int )
  13. Function bbSystemNotify( text$,serious:Int )
  14. Function bbSystemConfirm:Int( text$,serious:Int )
  15. Function bbSystemProceed:Int( text$,serious:Int )
  16. Function bbSystemRequestFile$( text$,exts$,defext:Int,save:Int,file$,dir$ )
  17. Function bbSystemRequestDir$( text$,dir$ )
  18. Function bbOpenURL:Int( url$ )
  19. Function bbSystemEmitOSEvent( hwnd:Byte Ptr,msg:Int,WParam:WParam,LParam:LParam,source:Object )
  20. Function bbSystemPostSyncOp( syncOp( syncInfo:Object,asyncRet:Int ),syncInfo:Object,asyncRet:Int )
  21. Function bbSystemStartAsyncOp( asyncOp( asyncInfo:Int ),asyncInfo:Int,syncOp( syncInfo:Object,asyncRet:Int ),syncInfo:Object )
  22. Function bbSystemDesktopWidth:Int()
  23. Function bbSystemDesktopHeight:Int()
  24. Function bbSystemDesktopDepth:Int()
  25. Function bbSystemDesktopHertz:Int()
  26. End Extern
  27. Type TWin32SystemDriver Extends TSystemDriver
  28. Method New()
  29. bbSystemStartup
  30. End Method
  31. Method Poll()
  32. bbSystemPoll()
  33. End Method
  34. Method Wait()
  35. bbSystemWait()
  36. End Method
  37. Method MoveMouse( x:Int,y:Int )
  38. bbSystemMoveMouse x,y
  39. End Method
  40. Method SetMouseVisible( visible:Int )
  41. bbSystemSetMouseVisible visible
  42. End Method
  43. Method Notify( text$,serious:Int )
  44. bbSystemNotify text,serious
  45. End Method
  46. Method Confirm:Int( text$,serious:Int )
  47. Return bbSystemConfirm( text,serious )
  48. End Method
  49. Method Proceed:Int( text$,serious:Int )
  50. Return bbSystemProceed( text,serious )
  51. End Method
  52. Method RequestFile$( text$,exts$,save:Int,path$ )
  53. Local file$,dir$
  54. path=path.Replace( "/","\" )
  55. Local i:Int=path.FindLast( "\" )
  56. If i<>-1
  57. dir=path[..i]
  58. file=path[i+1..]
  59. Else
  60. file=path
  61. EndIf
  62. ' calculate default index of extension in extension list from path name
  63. Local ext$,defext:Int,p:Int,q:Int
  64. p=path.Find(".")
  65. If (p>-1)
  66. ext=","+path[p+1..].toLower()+","
  67. Local exs$=exts.toLower()
  68. exs=exs.Replace(":",":,")
  69. exs=exs.Replace(";",",;")
  70. p=exs.find(ext)
  71. If p>-1
  72. Local q:Int=-1
  73. defext=1
  74. While True
  75. q=exs.find(";",q+1)
  76. If q>p Exit
  77. If q=-1 defext=0;Exit
  78. defext:+1
  79. Wend
  80. EndIf
  81. EndIf
  82. If exts
  83. If exts.Find(":")=-1
  84. exts="Files~0*."+exts
  85. Else
  86. exts=exts.Replace(":","~0*.")
  87. EndIf
  88. exts=exts.Replace(";","~0")
  89. exts=exts.Replace(",",";*.")+"~0"
  90. EndIf
  91. Return bbSystemRequestFile( text,exts,defext,save,file,dir )
  92. End Method
  93. Method RequestDir$( text$,dir$ )
  94. dir=dir.Replace( "/","\" )
  95. Return bbSystemRequestDir( text,dir )
  96. End Method
  97. Method OpenURL:Int( url$ )
  98. Return bbOpenURL( url )
  99. End Method
  100. Method DesktopWidth:Int()
  101. Return bbSystemDesktopWidth()
  102. End Method
  103. Method DesktopHeight:Int()
  104. Return bbSystemDesktopHeight()
  105. End Method
  106. Method DesktopDepth:Int()
  107. Return bbSystemDesktopDepth()
  108. End Method
  109. Method DesktopHertz:Int()
  110. Return bbSystemDesktopHertz()
  111. End Method
  112. Method Name:String()
  113. Return "Win32SystemDriver"
  114. End Method
  115. End Type