GXS.FullScreenViewer.pas 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. //
  2. // The graphics engine GLXEngine. The unit of GXScene for Delphi
  3. //
  4. unit GXS.FullScreenViewer;
  5. (* A cross-platform full-screen viewer *)
  6. interface
  7. {$I Stage.Defines.inc}
  8. uses
  9. Winapi.Messages,
  10. Winapi.Windows,
  11. System.Classes,
  12. System.SysUtils,
  13. FMX.Types,
  14. FMX.Forms,
  15. FMX.Controls,
  16. FMX.Menus,
  17. GXS.Scene,
  18. GXS.Context,
  19. GXS.SceneViewer,
  20. GXS.WinContext,
  21. GXS.ImageUtils,
  22. GXS.Screen;
  23. type
  24. TgxScreenDepth = (sd8bits, sd16bits, sd24bits, sd32bits);
  25. { A FullScreen viewer.
  26. This non visual viewer will, when activated, use the full screen as rendering
  27. surface. It will also switch/restore videomode depending on the required
  28. width/height.
  29. This is performed by creating an underlying TForm and using its surface
  30. for rendering OpenGL, "decent" ICDs will automatically use PageFlipping
  31. instead of BlockTransfer (slower buffer flipping mode used for windowed
  32. OpenGL).
  33. Note: if you terminate the application either via a kill or in the IDE,
  34. the original resolution isn't restored. }
  35. TgxFullScreenViewer = class(TgxNonVisualViewer)
  36. private
  37. FFormIsOwned: Boolean;
  38. FForm: TForm;
  39. FOwnDC: THandle; // in VCL HWND;
  40. FScreenDepth: TgxScreenDepth;
  41. FActive: Boolean;
  42. FSwitchedResolution: Boolean;
  43. FManualRendering: Boolean;
  44. FUpdateCount: Integer;
  45. FOnMouseDown: TMouseEvent;
  46. FOnMouseUp: TMouseEvent;
  47. FOnMouseMove: TMouseMoveEvent;
  48. FOnMouseWheel: TMouseWheelEvent; // in VCL TMouseWheelEvent;
  49. FOnMouseWheelDown: TMouseWheelEvent; // in VCL TMouseWheelUpDownEvent;
  50. FOnMouseWheelUp: TMouseWheelEvent; // in VCL TMouseWheelUpDownEvent;
  51. FOnClick, FOnDblClick: TNotifyEvent;
  52. FOnKeyDown: TKeyEvent;
  53. FOnKeyUp: TKeyEvent;
  54. FOnKeyPress: TKeyEvent; // In VCL TKeyPressEvent;
  55. FOnClose: TCloseEvent;
  56. FOnCloseQuery: TCloseQueryEvent;
  57. FStayOnTop: Boolean;
  58. FVSync: TgxSyncMode;
  59. FRefreshRate: Integer;
  60. { TODO : E2003 Undeclared identifier: 'TCursor' }
  61. (*FCursor: TCursor;*)
  62. FPopupMenu: TPopupMenu;
  63. procedure SetScreenDepth(const val: TgxScreenDepth);
  64. procedure SetActive(const val: Boolean);
  65. procedure SetOnMouseDown(const val: TMouseEvent);
  66. procedure SetOnMouseUp(const val: TMouseEvent);
  67. procedure SetOnMouseMove(const val: TMouseMoveEvent);
  68. procedure SetOnMouseWheel(const val: TMouseWheelEvent);
  69. procedure SetOnMouseWheelDown(const val: TMouseWheelEvent); //in VCL TMouseWheelUpDownEvent
  70. procedure SetOnMouseWheelUp(const val: TMouseWheelEvent); //in VCL TMouseWheelUpDownEvent
  71. procedure SetOnClick(const val: TNotifyEvent);
  72. procedure SetOnDblClick(const val: TNotifyEvent);
  73. procedure SetOnCloseQuery(const val: TCloseQueryEvent);
  74. procedure SetOnClose(const val: TCloseEvent);
  75. procedure SetOnKeyUp(const val: TKeyEvent);
  76. procedure SetOnKeyDown(const val: TKeyEvent);
  77. procedure SetOnKeyPress(const val: TKeyEvent); // in VCL TKeyPressEvent
  78. procedure SetStayOnTop(const val: Boolean);
  79. { TODO : E2003 Undeclared identifier: 'TCursor' }
  80. (*procedure SetCursor(const val: TCursor);*)
  81. procedure SetPopupMenu(const val: TPopupMenu);
  82. procedure SetForm(aVal: TForm);
  83. procedure SetManualRendering(const val: Boolean);
  84. protected
  85. function GetHandle: TWindowHandle;
  86. procedure DoBeforeRender(Sender: TObject);
  87. procedure DoBufferChange(Sender: TObject); override;
  88. procedure DoBufferStructuralChange(Sender: TObject); override;
  89. procedure Startup;
  90. procedure Shutdown;
  91. procedure BindFormEvents;
  92. procedure DoCloseQuery(Sender: TObject; var CanClose: Boolean);
  93. procedure DoPaint(Sender: TObject);
  94. procedure DoActivate(Sender: TObject);
  95. procedure DoDeactivate(Sender: TObject);
  96. procedure DoFormDestroy(Sender: TObject);
  97. public
  98. constructor Create(AOwner: TComponent); override;
  99. destructor Destroy; override;
  100. procedure Render(baseObject: TgxBaseSceneObject = nil); override;
  101. { Adjusts property so that current resolution will be used.
  102. Call this method if you want to make sure video mode isn't switched. }
  103. procedure UseCurrentResolution;
  104. procedure BeginUpdate;
  105. procedure EndUpdate;
  106. { Activates/deactivates full screen mode. }
  107. property Active: Boolean read FActive write SetActive;
  108. procedure ReActivate;
  109. { Read access to the underlying form handle.
  110. Returns 0 (zero) if the viewer is not active or has not yet
  111. instantiated its form. }
  112. property Handle: TWindowHandle read GetHandle;
  113. procedure Notification(AComponent: TComponent;
  114. Operation: TOperation); override;
  115. function LastFrameTime: Single;
  116. function FramesPerSecond: Single;
  117. function FramesPerSecondText(decimals: Integer = 1): String;
  118. procedure ResetPerformanceMonitor;
  119. property RenderDC: THandle read FOwnDC; //HWND
  120. published
  121. property Form: TForm read FForm write SetForm;
  122. property ManualRendering: Boolean read FManualRendering
  123. write SetManualRendering;
  124. // It is not used in UNIX
  125. { Requested ScreenDepth. }
  126. property ScreenDepth: TgxScreenDepth read FScreenDepth write SetScreenDepth
  127. default sd32bits;
  128. { Specifies if the underlying form is "fsStayOnTop".
  129. The benefit of StayOnTop is that it hides the windows bar and
  130. other background windows. The "fsStayOnTop" is automatically
  131. switched off/on when the underlying form loses/gains focus.
  132. It is recommended not to use StayOnTop while running in the IDE
  133. or during the debugging phase. }
  134. property StayOnTop: Boolean read FStayOnTop write SetStayOnTop
  135. default False;
  136. { Specifies if the refresh should be synchronized with the VSync signal.
  137. If the underlying OpenGL ICD does not support the WGL_EXT_swap_control
  138. extension, this property is ignored. }
  139. property VSync: TgxSyncMode read FVSync write FVSync default vsmSync;
  140. { Screen refresh rate.
  141. Use zero for system default. This property allows you to work around
  142. the winxp bug that limits uses a refresh rate of 60hz when changeing
  143. resolution. it is however suggested to give the user the opportunity
  144. to adjust it instead of having a fixed value (expecially beyond
  145. 75hz or for resolutions beyond 1024x768).
  146. the value will be automatically clamped to the highest value
  147. *reported* compatible with the monitor. }
  148. property RefreshRate: Integer read FRefreshRate write FRefreshRate;
  149. { TODO : E2003 Undeclared identifier: 'TCursor' }
  150. (*property Cursor: TCursor read FCursor write SetCursor default crDefault;*)
  151. property PopupMenu: TPopupMenu read FPopupMenu write SetPopupMenu;
  152. property OnClose: TCloseEvent read FOnClose write SetOnClose;
  153. property OnKeyUp: TKeyEvent read FOnKeyUp write SetOnKeyUp;
  154. property OnKeyDown: TKeyEvent read FOnKeyDown write SetOnKeyDown;
  155. property OnKeyPress: TKeyEvent read FOnKeyPress write SetOnKeyPress;
  156. property OnCloseQuery: TCloseQueryEvent read FOnCloseQuery
  157. write SetOnCloseQuery;
  158. property OnClick: TNotifyEvent read FOnClick write SetOnClick;
  159. property OnDblClick: TNotifyEvent read FOnDblClick write SetOnDblClick;
  160. property OnMouseDown: TMouseEvent read FOnMouseDown write SetOnMouseDown;
  161. property OnMouseUp: TMouseEvent read FOnMouseUp write SetOnMouseUp;
  162. property OnMouseMove: TMouseMoveEvent read FOnMouseMove
  163. write SetOnMouseMove;
  164. property OnMouseWheel: TMouseWheelEvent read FOnMouseWheel
  165. write SetOnMouseWheel;
  166. property OnMouseWheelDown: TMouseWheelEvent read FOnMouseWheelDown
  167. write SetOnMouseWheelDown;
  168. property OnMouseWheelUp: TMouseWheelEvent read FOnMouseWheelUp
  169. write SetOnMouseWheelUp;
  170. end;
  171. procedure Register;
  172. // ------------------------------------------------------------------
  173. implementation
  174. // ------------------------------------------------------------------
  175. const
  176. cScreenDepthToBPP: array [sd8bits .. sd32bits] of Integer = (8, 16, 24, 32);
  177. procedure Register;
  178. begin
  179. RegisterComponents('GXScene', [TgxFullScreenViewer]);
  180. end;
  181. // ------------------
  182. // ------------------ TgxFullScreenViewer ------------------
  183. // ------------------
  184. constructor TgxFullScreenViewer.Create(AOwner: TComponent);
  185. begin
  186. inherited Create(AOwner);
  187. Width := 800;
  188. Height := 600;
  189. FScreenDepth := sd32bits;
  190. FVSync := vsmSync;
  191. { TODO : E2003 Undeclared identifier: 'TCursor' }
  192. (*FCursor := crDefault;*)
  193. Buffer.ViewerBeforeRender := DoBeforeRender;
  194. end;
  195. destructor TgxFullScreenViewer.Destroy;
  196. begin
  197. Active := False;
  198. inherited Destroy;
  199. end;
  200. procedure TgxFullScreenViewer.DoBeforeRender(Sender: TObject);
  201. begin
  202. SetupVSync(VSync);
  203. end;
  204. procedure TgxFullScreenViewer.DoBufferChange(Sender: TObject);
  205. begin
  206. if Assigned(FForm) and (not Buffer.Rendering) then
  207. begin
  208. Buffer.Render;
  209. end;
  210. end;
  211. procedure TgxFullScreenViewer.DoBufferStructuralChange(Sender: TObject);
  212. begin
  213. if Active and (FUpdateCount = 0) then
  214. ReActivate
  215. end;
  216. procedure TgxFullScreenViewer.Render(baseObject: TgxBaseSceneObject = nil);
  217. begin
  218. Buffer.Render(baseObject);
  219. end;
  220. procedure TgxFullScreenViewer.BeginUpdate;
  221. begin
  222. Inc(FUpdateCount);
  223. end;
  224. procedure TgxFullScreenViewer.EndUpdate;
  225. begin
  226. Dec(FUpdateCount);
  227. if FUpdateCount = 0 then
  228. begin
  229. if Active then
  230. DoBufferStructuralChange(Self)
  231. end
  232. else if FUpdateCount < 0 then
  233. begin
  234. FUpdateCount := 0;
  235. Assert(False, 'Unbalanced Begin/EndUpdate');
  236. end;
  237. end;
  238. procedure TgxFullScreenViewer.ReActivate;
  239. begin
  240. Shutdown;
  241. Startup;
  242. end;
  243. procedure TgxFullScreenViewer.Notification(AComponent: TComponent;
  244. Operation: TOperation);
  245. begin
  246. if (Operation = opRemove) and (Buffer <> nil) then
  247. begin
  248. if (AComponent = Buffer.Camera) then
  249. Buffer.Camera := nil;
  250. Active := False;
  251. if (AComponent = FForm) then
  252. begin
  253. Active := False;
  254. Form := nil;
  255. end;
  256. end;
  257. inherited Notification(AComponent, Operation);
  258. end;
  259. function TgxFullScreenViewer.LastFrameTime: Single;
  260. begin
  261. Result := Buffer.LastFrameTime;
  262. end;
  263. function TgxFullScreenViewer.FramesPerSecond: Single;
  264. begin
  265. Result := Buffer.FramesPerSecond;
  266. end;
  267. function TgxFullScreenViewer.FramesPerSecondText(decimals: Integer): String;
  268. begin
  269. Result := Format('%.*f FPS', [decimals, Buffer.FramesPerSecond]);
  270. end;
  271. procedure TgxFullScreenViewer.ResetPerformanceMonitor;
  272. begin
  273. Buffer.ResetPerformanceMonitor;
  274. end;
  275. procedure TgxFullScreenViewer.UseCurrentResolution;
  276. begin
  277. BeginUpdate;
  278. try
  279. Width := Trunc(Screen.Width);
  280. Height := Trunc(Screen.Height);
  281. case GetCurrentColorDepth of
  282. 24: ScreenDepth := sd24bits;
  283. 16: ScreenDepth := sd16bits;
  284. 8: ScreenDepth := sd8bits;
  285. else
  286. // highest depth possible otherwise
  287. ScreenDepth := sd32bits;
  288. end;
  289. finally
  290. EndUpdate;
  291. end;
  292. end;
  293. procedure TgxFullScreenViewer.SetActive(const val: Boolean);
  294. begin
  295. if val <> FActive then
  296. begin
  297. // Alt+Tab delayed until better times
  298. // {$IFDEF MSWindows}
  299. // Application.OnDeactivate:=DoDeActivate;
  300. // Application.OnActivate:=DoActivate;
  301. // {$ENDIF}
  302. if val then
  303. Startup
  304. else
  305. Shutdown;
  306. end;
  307. end;
  308. procedure TgxFullScreenViewer.Startup;
  309. var
  310. res: TResolution;
  311. begin
  312. if FActive then
  313. Exit;
  314. if FForm = nil then
  315. begin
  316. FFormIsOwned := True;
  317. FForm := TForm.Create(nil);
  318. FForm.Show();
  319. end
  320. else
  321. FFormIsOwned := False;
  322. with FForm do
  323. begin
  324. If BorderStyle <> TFmxFormBorderStyle.None then
  325. BorderStyle := TFmxFormBorderStyle.None;
  326. { TODO : E2003 Undeclared identifier: 'Cursor' }
  327. (*Cursor := Self.Cursor;*)
  328. PopupMenu := Self.PopupMenu;
  329. Left := 0;
  330. Top := 0;
  331. ClientWidth := Self.Width;
  332. ClientHeight := Self.Height;
  333. BindFormEvents;
  334. res := GetIndexFromResolution(Width, Height,
  335. cScreenDepthToBPP[ScreenDepth]);
  336. if res = 0 then
  337. raise Exception.Create('Unsupported video mode');
  338. if StayOnTop then
  339. FormStyle := TFormStyle.StayOnTop
  340. else
  341. FormStyle := TFormStyle.Normal;
  342. { TODO : E2010 Incompatible types: 'HWND' and 'TWindowHandle' }
  343. (*
  344. SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and
  345. not WS_CAPTION);
  346. *)
  347. // WindowState:=wsMaximized;
  348. // Switch video mode
  349. if (Screen.Width <> Width) or (Screen.Height <> Height) or
  350. (GetCurrentColorDepth <> cScreenDepthToBPP[ScreenDepth]) then
  351. begin
  352. SetFullscreenMode(res, FRefreshRate);
  353. FSwitchedResolution := True;
  354. end;
  355. // Hides Taskbar + Windows 7 Button
  356. ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_HIDE);
  357. ShowWindow(FindWindow('BUTTON', nil), SW_HIDE);
  358. // Show;
  359. end;
  360. Buffer.Resize(0, 0, Width, Height);
  361. { TODO : E2010 Incompatible types: 'HWND' and 'TWindowHandle' }
  362. (*FOwnDC := GetDC(FForm.Handle);*)
  363. Buffer.CreateRC(FOwnDC, False);
  364. // Linux Unicode
  365. {$IFDEF Linux}
  366. GrabMouseToForm(FForm);
  367. {$ENDIF}
  368. // todo
  369. FActive := True;
  370. end;
  371. procedure TgxFullScreenViewer.Shutdown;
  372. begin
  373. if not FActive then
  374. Exit;
  375. Assert(FForm <> nil);
  376. Buffer.DestroyRC;
  377. with FForm do
  378. begin
  379. { TODO : E2003 Undeclared identifier: 'crDefault' }
  380. (*Cursor := crDefault;*)
  381. PopupMenu := nil;
  382. end;
  383. // Restore Taskbar + Windows 7 Button
  384. ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_SHOWNA);
  385. ShowWindow(FindWindow('BUTTON', nil), SW_SHOWNA);
  386. // attempt that, at the very least...
  387. if FSwitchedResolution then
  388. RestoreDefaultMode;
  389. FActive := False;
  390. if FFormIsOwned then
  391. FreeAndNil(FForm);
  392. end;
  393. procedure TgxFullScreenViewer.BindFormEvents;
  394. begin
  395. if Assigned(FForm) then
  396. with FForm do
  397. begin
  398. OnMouseDown := FOnMouseDown;
  399. OnMouseUp := FOnMouseUp;
  400. OnMouseMove := FOnMouseMove;
  401. OnMouseWheel := FOnMouseWheel;
  402. OnMouseWheelDown := FOnMouseWheelDown;
  403. OnMouseWheelUp := FOnMouseWheelUp;
  404. OnClick := FOnClick;
  405. OnDblClick := FOnDblClick;
  406. OnCloseQuery := DoCloseQuery;
  407. OnClose := FOnClose;
  408. OnKeyUp := FOnKeyUp;
  409. OnKeyDown := FOnKeyDown;
  410. OnKeyPress := FOnKeyPress;
  411. { TODO : E2009 Incompatible types: 'Parameter lists differ' }
  412. (*OnPaint := DoPaint;*)
  413. OnDestroy := DoFormDestroy;
  414. end;
  415. end;
  416. procedure TgxFullScreenViewer.DoCloseQuery(Sender: TObject;
  417. var CanClose: Boolean);
  418. begin
  419. if Assigned(FOnCloseQuery) then
  420. FOnCloseQuery(Sender, CanClose);
  421. CanClose := True;
  422. // if CanClose then Shutdown;
  423. end;
  424. procedure TgxFullScreenViewer.DoPaint(Sender: TObject);
  425. begin
  426. If not ManualRendering then
  427. if Form <> nil then
  428. Render;
  429. end;
  430. procedure TgxFullScreenViewer.DoActivate(Sender: TObject);
  431. begin
  432. (* If not Active and (Form <> nil) then begin
  433. Startup;
  434. end; *)
  435. end;
  436. procedure TgxFullScreenViewer.DoDeactivate(Sender: TObject);
  437. begin
  438. (* If Active and (Form <> nil) then begin
  439. Shutdown;
  440. Form.Height:=0;
  441. Form.Width:=0;
  442. end; *)
  443. end;
  444. procedure TgxFullScreenViewer.DoFormDestroy(Sender: TObject);
  445. begin
  446. Active := False;
  447. end;
  448. procedure TgxFullScreenViewer.SetScreenDepth(const val: TgxScreenDepth);
  449. begin
  450. if FScreenDepth <> val then
  451. begin
  452. FScreenDepth := val;
  453. DoBufferStructuralChange(Self);
  454. end;
  455. end;
  456. procedure TgxFullScreenViewer.SetStayOnTop(const val: Boolean);
  457. begin
  458. if val <> FStayOnTop then
  459. begin
  460. FStayOnTop := val;
  461. DoBufferStructuralChange(Self);
  462. end;
  463. end;
  464. procedure TgxFullScreenViewer.SetOnCloseQuery(const val: TCloseQueryEvent);
  465. begin
  466. FOnCloseQuery := val; // this one uses a special binding
  467. end;
  468. procedure TgxFullScreenViewer.SetOnClose(const val: TCloseEvent);
  469. begin
  470. If Form <> nil then
  471. Form.OnClose := val;
  472. FOnClose := val;
  473. end;
  474. procedure TgxFullScreenViewer.SetOnKeyPress(const val: TKeyEvent); //VCL - TKeyPressEvent
  475. begin
  476. If Form <> nil then
  477. Form.OnKeyDown := val;
  478. FOnKeyPress := val;
  479. end;
  480. procedure TgxFullScreenViewer.SetOnKeyUp(const val: TKeyEvent);
  481. begin
  482. If Form <> nil then
  483. Form.OnKeyUp := val;
  484. FOnKeyUp := val;
  485. end;
  486. procedure TgxFullScreenViewer.SetOnKeyDown(const val: TKeyEvent);
  487. begin
  488. If Form <> nil then
  489. Form.OnKeyDown := val;
  490. FOnKeyDown := val;
  491. end;
  492. procedure TgxFullScreenViewer.SetOnMouseWheel(const val: TMouseWheelEvent);
  493. begin
  494. If Form <> nil then
  495. Form.OnMouseWheel := val;
  496. FOnMouseWheel := val;
  497. end;
  498. procedure TgxFullScreenViewer.SetOnMouseWheelDown
  499. (const val: TMouseWheelEvent);
  500. begin
  501. If Form <> nil then
  502. Form.OnMouseWheel := val;
  503. FOnMouseWheelDown := val;
  504. end;
  505. procedure TgxFullScreenViewer.SetOnMouseWheelUp(const val: TMouseWheelEvent);
  506. begin
  507. If Form <> nil then
  508. Form.OnMouseWheel := val;
  509. FOnMouseWheelUp := val;
  510. end;
  511. procedure TgxFullScreenViewer.SetOnClick(const val: TNotifyEvent);
  512. begin
  513. If Form <> nil then
  514. { TODO : E2003 Undeclared identifier: 'OnClick' }
  515. (*Form.OnClick := val;*)
  516. FOnClick := val;
  517. end;
  518. procedure TgxFullScreenViewer.SetOnDblClick(const val: TNotifyEvent);
  519. begin
  520. If Form <> nil then
  521. { TODO : E2003 Undeclared identifier: 'OnDblClick' }
  522. (*Form.OnDblClick := val;*)
  523. FOnDblClick := val;
  524. end;
  525. procedure TgxFullScreenViewer.SetOnMouseMove(const val: TMouseMoveEvent);
  526. begin
  527. If Form <> nil then
  528. Form.OnMouseMove := val;
  529. FOnMouseMove := val;
  530. end;
  531. procedure TgxFullScreenViewer.SetOnMouseDown(const val: TMouseEvent);
  532. begin
  533. If Form <> nil then
  534. Form.OnMouseDown := val;
  535. FOnMouseDown := val;
  536. end;
  537. procedure TgxFullScreenViewer.SetOnMouseUp(const val: TMouseEvent);
  538. begin
  539. If Form <> nil then
  540. Form.OnMouseUp := val;
  541. FOnMouseUp := val;
  542. end;
  543. (*
  544. procedure TgxFullScreenViewer.SetCursor(const val: TCursor);
  545. begin
  546. if val <> FCursor then
  547. begin
  548. FCursor := val;
  549. if Form <> nil then
  550. FForm.Cursor := val;
  551. end;
  552. end;
  553. *)
  554. procedure TgxFullScreenViewer.SetPopupMenu(const val: TPopupMenu);
  555. begin
  556. if val <> FPopupMenu then
  557. begin
  558. FPopupMenu := val;
  559. if Assigned(FForm) then
  560. { TODO : E2003 Undeclared identifier: 'PopupMenu' }
  561. (*FForm.PopupMenu := val;*)
  562. end;
  563. end;
  564. procedure TgxFullScreenViewer.SetForm(aVal: TForm);
  565. begin
  566. FForm := aVal;
  567. end;
  568. procedure TgxFullScreenViewer.SetManualRendering(const val: Boolean);
  569. begin
  570. if FManualRendering <> val then
  571. FManualRendering := val;
  572. end;
  573. function TgxFullScreenViewer.GetHandle: TWindowHandle;
  574. begin
  575. if Form <> nil then
  576. Result := FForm.Handle
  577. else
  578. Result := nil;
  579. end;
  580. // ------------------------------------------------------------------
  581. initialization
  582. // ------------------------------------------------------------------
  583. RegisterClasses([TgxFullScreenViewer]);
  584. finalization
  585. // Restore Taskbar + Windows 7 Button
  586. ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_SHOWNA);
  587. ShowWindow(FindWindow('BUTTON', nil), SW_SHOWNA);
  588. end.