u_vc_statusbar.sru 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. $PBExportHeader$u_vc_statusbar.sru
  2. $PBExportComments$状态栏对象 - 可视定制用户对象
  3. forward
  4. global type u_vc_statusbar from userobject
  5. end type
  6. type rect from structure within u_vc_statusbar
  7. end type
  8. end forward
  9. type RECT from structure
  10. long left
  11. long top
  12. long right
  13. long bottom
  14. end type
  15. global type u_vc_statusbar from userobject
  16. integer width = 850
  17. integer height = 72
  18. userobjects objecttype = externalvisual!
  19. long backcolor = 0
  20. string classname = "msctls_statusbar32"
  21. string libraryname = "comctl32.dll"
  22. string text = "none"
  23. long style = 1174405120
  24. end type
  25. global u_vc_statusbar u_vc_statusbar
  26. type prototypes
  27. function long SendMessageLong( long hWindow, uint Msg, ulong wParam, Ref long Parts[] ) Library 'user32' alias for 'SendMessageA'
  28. function long SendMessageString( long hWindow, uint Msg, ulong wParam, Ref string szText ) Library 'user32' alias for 'SendMessageA;Ansi'
  29. function long SendMessageRect( long hWindow, uint Msg, ulong wParam, Ref RECT lpRect ) Library 'user32' alias for 'SendMessageA;Ansi'
  30. end prototypes
  31. type variables
  32. // Status Bar Messages
  33. Constant Private Long WM_USER = 1024
  34. Constant Private Long SB_SETTEXT = (WM_USER+1)
  35. Constant Private Long SB_GETTEXT = (WM_USER+2)
  36. Constant Private Long SB_GETTEXTLENGTH = (WM_USER+3)
  37. Constant Private Long SB_SETPARTS = (WM_USER+4)
  38. Constant Private Long SB_GETPARTS = (WM_USER+6)
  39. Constant Private Long SB_GETBORDERS = (WM_USER+7)
  40. Constant Private Long SB_SETMINHEIGHT = (WM_USER+8)
  41. Constant Private Long SB_SIMPLE = (WM_USER+9)
  42. Constant Private Long SB_GETRECT = (WM_USER+10)
  43. // Status Bar Types
  44. Constant Private Long SBT_NOBORDERS = 256
  45. Constant Private Long SBT_POPOUT = 512
  46. Constant Private Long SBT_RTLREADING = 1024
  47. Constant Private Long SBT_OWNERDRAW = 4096
  48. end variables
  49. forward prototypes
  50. public subroutine of_gettext (readonly integer aipart, ref string astext)
  51. public function long of_getparts (ref long alparts[])
  52. public function boolean of_setparts (long alparts[])
  53. public function boolean of_settext (readonly integer aipart, string astext)
  54. public function boolean of_setsimple (readonly boolean absimple)
  55. public subroutine of_setminheight (readonly long alMinHeight)
  56. public function integer of_gettextlength (readonly long alpart)
  57. public function boolean of_getrect (readonly long alPart, ref long alTop, ref long alLeft, ref long alRight, ref long alBottom)
  58. public function boolean of_getborders (ref long alHorizontalWidth, ref long alVerticalWidth, integer alSeperatorWidth)
  59. end prototypes
  60. public subroutine of_gettext (readonly integer aipart, ref string astext);//===================================================================
  61. // Function: uo_StatusBar::of_GetText()
  62. //-------------------------------------------------------------------
  63. // Description:The SB_GETTEXT message retrieves the text from the
  64. // specified part of a status window.
  65. //-------------------------------------------------------------------
  66. // Parameters: wParam = (WPARAM) iPart
  67. // lParam = (LPARAM) (LPSTR) szText
  68. //
  69. // iPart
  70. // Zero-based index of the part from which to retrieve text.
  71. // szText
  72. // Pointer to the buffer that receives the text.
  73. // This parameter is a null-terminated string.
  74. //-------------------------------------------------------------------
  75. // Returns: Returns a 32-bit value that consists of two 16-bit values.
  76. // The low word specifies the length, in characters, of the text.
  77. // The high word specifies the type of operation used to
  78. // draw the text. The type can be one of the following values:
  79. //
  80. // VALUE MEANING
  81. // -------------- ------------------------------------------------
  82. // 0 The text is drawn with a border to appear lower
  83. // than the plane of the window.
  84. // SBT_NOBORDERS The text is drawn without borders.
  85. // SBT_POPOUT The text is drawn with a border to appear higher
  86. // than the plane of window.
  87. // SBT_RTLREADING Displays text using right-to-left reading order
  88. // on Hebrew or Arabic systems.
  89. //
  90. // If the text has the SBT_OWNERDRAW drawing type, this message
  91. // returns the 32-bit value associated with the text instead of
  92. // the length and operation type.
  93. //-------------------------------------------------------------------
  94. // ?1997 Microsoft Corporation. All rights reserved.
  95. //===================================================================
  96. // Allocate space for buffer
  97. asText = Space(255)
  98. SendMessageString( Handle(This), SB_GETTEXT, aiPart, asText )
  99. RETURN
  100. end subroutine
  101. public function long of_getparts (ref long alparts[]);//===================================================================
  102. // Function: uo_StatusBar::of_GetParts()
  103. //-------------------------------------------------------------------
  104. // Description:The SB_GETPARTS message retrieves a count of the
  105. // parts in a status window. The message also retrieves
  106. // the coordinate of the right edge of the specified
  107. // number of parts.
  108. //-------------------------------------------------------------------
  109. // Parameters: wParam = (WPARAM) nParts
  110. // lParam = (LPARAM) (LPINT) aRightCoord
  111. //
  112. // nParts
  113. // Number of parts for which to retrieve coordinates.
  114. // If this parameter is greater than the number of parts in the
  115. // window, the message retrieves coordinates for existing parts only.
  116. // aRightCoord
  117. // Pointer to an integer array that has the same number of elements
  118. // as parts specified by nParts. Each element in the array receives
  119. // the client coordinate of the right edge of the corresponding part.
  120. // If an element is set to - 1, the position of the right edge for
  121. // that part extends to the right edge of the window. To retrieve
  122. // the current number of parts, set this parameter to zero.
  123. //-------------------------------------------------------------------
  124. // Returns: Returns the number of parts in the window if successful,
  125. // or zero otherwise.
  126. //-------------------------------------------------------------------
  127. // ?1997 Microsoft Corporation. All rights reserved.
  128. //===================================================================
  129. long llCountParts, llParts[]
  130. llCountParts = SendMessageLong( Handle(This), SB_GETPARTS, 255, llParts[] )
  131. IF llCountParts > 0 THEN
  132. alParts = llParts
  133. END IF
  134. RETURN llCountParts
  135. end function
  136. public function boolean of_setparts (long alparts[]);//===================================================================
  137. // Function: uo_StatusBar::of_SetParts()
  138. //-------------------------------------------------------------------
  139. // Description:The SB_SETPARTS message sets the number of parts
  140. // in a status window and the coordinate of the right
  141. // edge of each part.
  142. //-------------------------------------------------------------------
  143. // Parameters: wParam = (WPARAM) nParts
  144. // lParam = (LPARAM) (LPINT) aWidths
  145. //
  146. // nParts
  147. // Number of parts to set. The number of parts cannot be greater
  148. // than 255.
  149. // aWidths
  150. // Pointer to an integer array that has the same number of
  151. // elements as parts specified by nParts. Each element in the
  152. // array specifies the position, in client coordinates, of the
  153. // right edge of the corresponding part. If an element is - 1,
  154. // the position of the right edge for that part extends to the
  155. // right edge of the window.
  156. //-------------------------------------------------------------------
  157. // Returns: If the operation succeeds, the return value is TRUE.
  158. // If the operation fails, the return value is FALSE.
  159. //-------------------------------------------------------------------
  160. // ?1997 Microsoft Corporation. All rights reserved.
  161. //===================================================================
  162. long llCountParts
  163. boolean lbSetParts = FALSE
  164. llCountParts = UpperBound( alParts[] )
  165. IF llCountParts > 0 THEN
  166. lbSetParts = (SendMessageLong( Handle(This), SB_SETPARTS, llCountParts, alParts[] ) <> 0)
  167. END IF
  168. RETURN lbSetParts
  169. end function
  170. public function boolean of_settext (readonly integer aipart, string astext);//===================================================================
  171. // Function: uo_StatusBar::of_SetText()
  172. //-------------------------------------------------------------------
  173. // Description:The SB_SETTEXT message sets the text in the specified
  174. // part of a status window.
  175. // The message invalidates the portion of the window that
  176. // has changed, causing it to display the new text when
  177. // the window next receives the WM_PAINT message.
  178. //-------------------------------------------------------------------
  179. // Parameters: wParam = (WPARAM) iPart | uType
  180. // lParam = (LPARAM) (LPSTR) szText
  181. //
  182. // iPart
  183. // Zero-based index of the part to set. If this value is 255,
  184. // the status window is assumed to be a simple window having only
  185. // one part.
  186. // uType
  187. // Type of drawing operation.
  188. // This parameter can be one of the following values:
  189. //
  190. // VALUE MEANING
  191. // -------------- --------------------------------------------------
  192. // 0 The text is drawn with a border to appear lower
  193. // than the plane of the window.
  194. // SBT_NOBORDERS The text is drawn without borders.
  195. // SBT_OWNERDRAW The text is drawn by the parent window.
  196. // SBT_POPOUT The text is drawn with a border to appear higher
  197. // than the plane of the window.
  198. // SBT_RTLREADING Displays text using right-to-left reading order
  199. // on Hebrew or Arabic systems.
  200. // szText
  201. // Pointer to a null-terminated string that specifies the text to set.
  202. // If uType is SBT_OWNERDRAW, this parameter represents 32 bits of
  203. // data. The parent window must interpret the data and draw the text
  204. // when it receives the WM_DRAWITEM message.
  205. //-------------------------------------------------------------------
  206. // Returns: If the operation succeeds, the return value is TRUE.
  207. // If the operation fails, the return value is FALSE.
  208. //-------------------------------------------------------------------
  209. // ?1997 Microsoft Corporation. All rights reserved.
  210. //===================================================================
  211. RETURN (SendMessageString( Handle(This), SB_SETTEXT, aiPart, asText ) <> 0)
  212. end function
  213. public function boolean of_setsimple (readonly boolean absimple);//===================================================================
  214. // Function: uo_StatusBar::of_SetSimple()
  215. //-------------------------------------------------------------------
  216. // Description:The SB_SIMPLE message specifies whether a status
  217. // window displays simple text or displays all window
  218. // parts set by a previous SB_SETPARTS message.
  219. //
  220. // NOTE: If the status window is being changed from nonsimple to
  221. // simple, or vice versa, the window is immediately redrawn.
  222. //-------------------------------------------------------------------
  223. // Parameters: wParam = (WPARAM) (BOOL) fSimple
  224. // lParam = 0
  225. //
  226. //fSimple
  227. // Display type flag. If this parameter is TRUE, the window
  228. // displays simple text. If it is FALSE, it displays
  229. // multiple parts.
  230. //-------------------------------------------------------------------
  231. // Returns: Returns TRUE if set was successful.
  232. // Returns FALSE if an error occurs.
  233. //-------------------------------------------------------------------
  234. // ?1997 Microsoft Corporation. All rights reserved.
  235. //===================================================================
  236. long llSimple
  237. // Convert boolean to 'C' style boolean (NON-ZERO = TRUE)
  238. IF abSimple THEN
  239. llSimple = 1
  240. ELSE
  241. llSimple = 0
  242. END IF
  243. RETURN (Send( Handle(This), SB_SIMPLE, llSimple, 0 ) > 0)
  244. end function
  245. public subroutine of_setminheight (readonly long alMinHeight);//===================================================================
  246. // Function: uo_StatusBar::of_SetMinHeight()
  247. //-------------------------------------------------------------------
  248. // Description:The SB_SETMINHEIGHT message sets the minimum height
  249. // of a status window抯 drawing area.
  250. //
  251. // NOTE: The minimum height is the sum of wParam and twice the width,
  252. // in pixels, of the vertical border of the status window.
  253. // An application must send the WM_SIZE message to the status
  254. // window to redraw the window. The wParam and lParam parameters
  255. // of the WM_SIZE message should be set to zero.
  256. //-------------------------------------------------------------------
  257. // Parameters: wParam = (WPARAM) minHeight
  258. // lParam = 0
  259. //
  260. //minHeight
  261. // Minimum height, in pixels, of the window.
  262. //-------------------------------------------------------------------
  263. // Returns: <none>
  264. //-------------------------------------------------------------------
  265. // ?1997 Microsoft Corporation. All rights reserved.
  266. //===================================================================
  267. Send( Handle(This), SB_SETMINHEIGHT, alMinHeight, 0 )
  268. RETURN
  269. end subroutine
  270. public function integer of_gettextlength (readonly long alpart);//===================================================================
  271. // Function: uo_StatusBar::of_GetTextLength()
  272. //-------------------------------------------------------------------
  273. // Description:The SB_GETTEXTLENGTH message retrieves the length,
  274. // in characters, of the text from the specified part
  275. // of a status window.
  276. //-------------------------------------------------------------------
  277. // Parameters: wParam = (WPARAM) iPart
  278. // lParam = 0
  279. //
  280. // iPart
  281. // Zero-based index of the part from which to retrieve text.
  282. //-------------------------------------------------------------------
  283. // Returns: Returns a 32-bit value that consists of two 16-bit values.
  284. // The low word specifies the length, in characters, of the text.
  285. // The high word specifies the type of operation used to draw
  286. // the text. The type can be one of the following values:
  287. //
  288. // VALUE MEANING
  289. // -------------- --------------------------------------------------
  290. // 0 The text is drawn with a border to appear lower
  291. // than the plane of the window.
  292. // SBT_NOBORDERS The text is drawn without borders.
  293. // SBT_OWNERDRAW The text is drawn by the parent window.
  294. // SBT_POPOUT The text is drawn with a border to appear higher
  295. // than the plane of the window.
  296. // SBT_RTLREADING Displays text using right-to-left reading order
  297. // on Hebrew or Arabic systems.
  298. //-------------------------------------------------------------------
  299. // ?1997 Microsoft Corporation. All rights reserved.
  300. //===================================================================
  301. long llLength
  302. llLength = Send( Handle(This), SB_GETTEXTLENGTH, alPart, 0 )
  303. RETURN IntLow( llLength )
  304. end function
  305. public function boolean of_getrect (readonly long alPart, ref long alTop, ref long alLeft, ref long alRight, ref long alBottom);//===================================================================
  306. // Function: uo_StatusBar::of_GetRect()
  307. //-------------------------------------------------------------------
  308. // Description:The SB_GETRECT message retrieves the bounding
  309. // rectangle of a part in a status window.
  310. //-------------------------------------------------------------------
  311. // Parameters: wParam = (WPARAM) iPart
  312. // lParam = (LPARAM) (LPRECT) lprc
  313. //
  314. // iPart
  315. // Zero-based index of the part whose bounding rectangle is to be
  316. // retrieved.
  317. // lprc
  318. // Pointer to a RECT structure that receives the bounding rectangle.
  319. //-------------------------------------------------------------------
  320. // Returns: If the operation succeeds, the return value is TRUE.
  321. // If the operation fails, the return value is FALSE.
  322. //-------------------------------------------------------------------
  323. // ?1997 Microsoft Corporation. All rights reserved.
  324. //===================================================================
  325. boolean lbGetRect = FALSE
  326. RECT lRECT
  327. lbGetRect = ( SendMessageRect( Handle(This), SB_GETRECT, alPart, lRECT ) <> 0 )
  328. IF lbGetRect THEN
  329. alTop = lRECT.Top
  330. alLeft = lRECT.Left
  331. alRight = lRECT.Right
  332. alBottom = lRECT.Bottom
  333. END IF
  334. RETURN lbGetRect
  335. end function
  336. public function boolean of_getborders (ref long alHorizontalWidth, ref long alVerticalWidth, integer alSeperatorWidth);//===================================================================
  337. // Function: uo_StatusBar::of_GetParts()
  338. //-------------------------------------------------------------------
  339. // Description:The SB_GETBORDERS message retrieves the current
  340. // widths of the horizontal and vertical borders of a
  341. // status window.
  342. //
  343. // NOTE: The borders determine the spacing between the outside edge
  344. // of the window and the rectangles within the window that
  345. // contain text.
  346. // The borders also determine the spacing between rectangles.
  347. //-------------------------------------------------------------------
  348. // Parameters: wParam = 0
  349. // lParam = (LPARAM) (LPINT) aBorders;
  350. //
  351. // aBorders
  352. // Pointer to an integer array that has three elements.
  353. // The first element receives the width of the horizontal border,
  354. // the second receives the width of the vertical border,
  355. // and the third receives the width of the border between rectangles.
  356. //-------------------------------------------------------------------
  357. // Returns: If the operation succeeds, the return value is TRUE.
  358. // If the operation fails, the return value is FALSE.
  359. //-------------------------------------------------------------------
  360. // ?1997 Microsoft Corporation. All rights reserved.
  361. //===================================================================
  362. long llBorders[]
  363. boolean lbGetBorders = FALSE
  364. // Initialise Unbounded array to correct size.
  365. llBorders[3] = 0
  366. llBorders[2] = 0
  367. llBorders[1] = 0
  368. lbGetBorders = ( SendMessageLong( Handle(This), SB_GETBORDERS, 0, llBorders[] ) <> 0)
  369. IF lbGetBorders THEN
  370. alHorizontalWidth = llBorders[1]
  371. alVerticalWidth = llBorders[2]
  372. alSeperatorWidth = llBorders[3]
  373. END IF
  374. RETURN lbGetBorders
  375. end function
  376. on u_vc_statusbar.create
  377. end on
  378. on u_vc_statusbar.destroy
  379. end on