1818
1919namespace FlashpointSecurePlayer {
2020 public partial class WebBrowserMode : Form {
21+ private bool canShowToolbar = true ;
22+
23+ private bool CanShowToolbar {
24+ get {
25+ return canShowToolbar ;
26+ }
27+
28+ set {
29+ canShowToolbar = value ;
30+
31+ if ( canShowToolbar ) {
32+ ShowToolbar ( ) ;
33+ } else {
34+ toolBarToolStrip . Visible = false ;
35+ }
36+ }
37+ }
38+
39+ private void ShowToolbar ( ) {
40+ // this is checked in LowLevelMouseProc because
41+ // otherwise plugins such as Viscape which
42+ // create their own window can steal the
43+ // mouse move event
44+ // it cannot happen in PreFilterMessage!
45+ // our window may not even get these messages
46+ // all that matters is the mouse position, regardless
47+ // of if our window is active
48+ Point toolBarToolStripMousePosition = toolBarToolStrip . PointToClient ( MousePosition ) ;
49+
50+ if ( toolBarToolStrip . Visible ) {
51+ if ( ! toolBarToolStrip . ClientRectangle . Contains ( toolBarToolStripMousePosition ) ) {
52+ // the standard layout when the mouse is not in the toolbar rectangle
53+ // if in fullscreen, ensure toolbar is invisible
54+ // if not in fullscreen, ensure toolbar is visible
55+ toolBarToolStrip . Visible = ! Fullscreen ;
56+ }
57+ } else {
58+ if ( toolBarToolStripMousePosition . Y == 0
59+ && toolBarToolStrip . ClientRectangle . Contains ( toolBarToolStripMousePosition ) ) {
60+ // mouse in toolbar rectangle
61+ // if in fullscreen, show toolbar if we can
62+ // if not in fullscreen, ensure toolbar is visible
63+ toolBarToolStrip . Visible = CanShowToolbar || ! Fullscreen ;
64+ }
65+ }
66+ }
67+
2168 private readonly HookProc lowLevelMouseProc ;
2269 private IntPtr mouseHook = IntPtr . Zero ;
2370
@@ -27,26 +74,7 @@ private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) {
2774 // always confirm the message first so we don't do unnecessary work
2875 if ( wParam . ToInt32 ( ) == WM_MOUSEMOVE ) {
2976 if ( Fullscreen ) {
30- // this is checked in LowLevelMouseProc because
31- // otherwise plugins such as Viscape which
32- // create their own window can steal the
33- // mouse move event
34- // it cannot happen in PreFilterMessage!
35- // our window may not even get these messages
36- // all that matters is the mouse position, regardless
37- // of if our window is active
38- Point toolBarToolStripMousePosition = toolBarToolStrip . PointToClient ( MousePosition ) ;
39-
40- if ( toolBarToolStrip . Visible ) {
41- if ( ! toolBarToolStrip . ClientRectangle . Contains ( toolBarToolStripMousePosition ) ) {
42- toolBarToolStrip . Visible = false ;
43- }
44- } else {
45- if ( toolBarToolStripMousePosition . Y == 0
46- && toolBarToolStrip . ClientRectangle . Contains ( toolBarToolStripMousePosition ) ) {
47- toolBarToolStrip . Visible = true ;
48- }
49- }
77+ ShowToolbar ( ) ;
5078 }
5179 }
5280 }
@@ -56,7 +84,7 @@ private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) {
5684 return CallNextHookEx ( mouseHook , nCode , wParam , lParam ) ;
5785 }
5886
59- public WINDOWPLACEMENT WindowPlacement {
87+ private WINDOWPLACEMENT WindowPlacement {
6088 get {
6189 if ( ! IsHandleCreated || Handle == IntPtr . Zero ) {
6290 throw new InvalidOperationException ( "Handle is null." ) ;
@@ -128,7 +156,7 @@ private bool ExitFullscreenLabelTimer {
128156 // be very careful modifying this property
129157 // it is very picky about the order things happen
130158 // and likes to cause bugs if you're not careful changing it
131- public bool Fullscreen {
159+ private bool Fullscreen {
132160 get {
133161 return fullscreen ;
134162 }
@@ -687,6 +715,8 @@ private void WebBrowserMode_FormClosing(object sender, FormClosingEventArgs e) {
687715 }
688716
689717 private void WebBrowserMode_Activated ( object sender , EventArgs e ) {
718+ CanShowToolbar = true ;
719+
690720 if ( messageFilter != null ) {
691721 Application . AddMessageFilter ( messageFilter ) ;
692722 }
@@ -735,6 +765,7 @@ private void WebBrowserMode_Deactivate(object sender, EventArgs e) {
735765 // if we own the window above us in the z-order
736766 if ( Handle == GetWindow ( previousWindow , GW . GW_OWNER ) ) {
737767 // the new window is a dialog that prevents focus to this window
768+ CanShowToolbar = false ;
738769 return ;
739770 }
740771 }
0 commit comments