flatsb.pp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2007 by the Free Pascal development team
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. {$H+}
  13. {$inline on}
  14. unit FlatSB;
  15. interface
  16. uses
  17. ctypes,Windows;
  18. function InitializeFlatSB(hWnd: HWND): Bool; stdcall;
  19. procedure UninitializeFlatSB(hWnd: HWND); stdcall;
  20. function FlatSB_GetScrollProp(hwnd:HWND;propIndex : cint;p3 : LPINT):BOOL; stdcall;
  21. function FlatSB_SetScrollProp(p1: HWND; index : UINT; newValue: INT_PTR; p4: BOOL):BOOL; stdcall;
  22. var
  23. FlatSB_EnableScrollBar: function(hwnd:HWND;code : cint;p3 : UINT):BOOL; stdcall;
  24. FlatSB_ShowScrollBar: function(hwnd:HWND;code : cint;p3 : BOOL):BOOL; stdcall;
  25. FlatSB_GetScrollRange: function(hwnd:HWND;code : cint;var p3,p4 : cint):BOOL; stdcall;
  26. FlatSB_GetScrollInfo: function(hwnd:HWND;code : cint;var ScrollInfo : TSCROLLINFO):BOOL; stdcall;
  27. FlatSB_GetScrollPos: function(hwnd:HWND;code : cint):cint; stdcall;
  28. FlatSB_SetScrollPos: function(hWnd:HWND;nBar,nPos:cint;bRedraw:BOOL):cint; stdcall;
  29. FlatSB_SetScrollInfo: function(hWnd:HWND;BarFlag:cint;const ScrollInfo:TScrollInfo;Redraw:BOOL):cint; stdcall;
  30. FlatSB_SetScrollRange: function(hWnd: HWND; nBar,nMinPos,nMaxPos: cint; bRedraw: BOOL):cint; stdcall;
  31. implementation
  32. var
  33. Internal_FlatSB_GetScrollProp: function(hwnd:HWND;propIndex : cint;p3 : LPINT):BOOL; stdcall;
  34. Internal_FlatSB_SetScrollProp: function(p1: HWND; index : UINT; newValue: INT_PTR; p4: BOOL):BOOL; stdcall;
  35. Internal_InitializeFlatSB: function(hWnd: HWND): Bool; stdcall;
  36. Internal_UninitializeFlatSB: procedure(hWnd: HWND); stdcall;
  37. function FlatSB_GetScrollProp(hwnd:HWND;propIndex : cint;p3 : LPINT):BOOL; stdcall;
  38. begin
  39. Result:=Assigned(Internal_FlatSB_GetScrollProp) and Internal_FlatSB_GetScrollProp(hwnd,propIndex, p3);
  40. end;
  41. function FlatSB_SetScrollProp(p1: HWND; index : UINT; newValue: INT_PTR; p4: BOOL):BOOL; stdcall;
  42. begin
  43. Result:=Assigned(Internal_FlatSB_SetScrollProp) and Internal_FlatSB_SetScrollProp(p1,index,newValue,p4);
  44. end;
  45. function InitializeFlatSB(hWnd: HWND): Bool; stdcall;
  46. begin
  47. Result:=Assigned(Internal_InitializeFlatSB) and Internal_InitializeFlatSB(hWnd);
  48. end;
  49. procedure UninitializeFlatSB(hWnd: HWND); stdcall;
  50. begin
  51. if Assigned(Internal_UninitializeFlatSB) then
  52. Internal_UninitializeFlatSB(hWnd);
  53. end;
  54. var
  55. handle : THandle;
  56. begin
  57. handle:=GetModuleHandle('comctrl32.dll');
  58. if handle<>0 then
  59. begin
  60. pointer(Internal_InitializeFlatSB):=GetProcAddress(handle,'InitializeFlatSB');
  61. pointer(Internal_UninitializeFlatSB):=GetProcAddress(handle,'UninitializeFlatSB');
  62. pointer(Internal_FlatSB_GetScrollProp):=GetProcAddress(handle,'FlatSB_GetScrollProp');
  63. pointer(Internal_FlatSB_SetScrollProp):=GetProcAddress(handle,'FlatSB_SetScrollProp');
  64. pointer(FlatSB_EnableScrollBar):=GetProcAddress(handle,'FlatSB_EnableScrollBar');
  65. if not(assigned(FlatSB_EnableScrollBar)) then
  66. pointer(FlatSB_EnableScrollBar):=pointer(@EnableScrollBar);
  67. pointer(FlatSB_ShowScrollBar):=GetProcAddress(handle,'FlatSB_ShowScrollBar');
  68. if not(assigned(FlatSB_ShowScrollBar)) then
  69. pointer(FlatSB_ShowScrollBar):=pointer(@ShowScrollBar);
  70. pointer(FlatSB_GetScrollRange):=GetProcAddress(handle,'FlatSB_GetScrollRange');
  71. if not(assigned(FlatSB_GetScrollRange)) then
  72. pointer(FlatSB_GetScrollRange):=pointer(@GetScrollRange);
  73. pointer(FlatSB_GetScrollInfo):=GetProcAddress(handle,'FlatSB_GetScrollInfo');
  74. if not(assigned(FlatSB_GetScrollInfo)) then
  75. pointer(FlatSB_GetScrollInfo):=pointer(@GetScrollInfo);
  76. pointer(FlatSB_GetScrollPos):=GetProcAddress(handle,'FlatSB_GetScrollPos');
  77. if not(assigned(FlatSB_GetScrollPos)) then
  78. pointer(FlatSB_GetScrollPos):=pointer(@GetScrollPos);
  79. pointer(FlatSB_SetScrollPos):=GetProcAddress(handle,'FlatSB_SetScrollPos');
  80. if not(assigned(FlatSB_SetScrollPos)) then
  81. pointer(FlatSB_SetScrollPos):=pointer(@SetScrollPos);
  82. pointer(FlatSB_SetScrollInfo):=GetProcAddress(handle,'FlatSB_SetScrollInfo');
  83. if not(assigned(FlatSB_SetScrollInfo)) then
  84. pointer(FlatSB_SetScrollInfo):=pointer(@SetScrollInfo);
  85. pointer(FlatSB_SetScrollRange):=GetProcAddress(handle,'FlatSB_SetScrollRange');
  86. if not(assigned(FlatSB_SetScrollRange)) then
  87. pointer(FlatSB_SetScrollRange):=pointer(@SetScrollRange);
  88. end;
  89. end.