안녕하세요! HappyBono 인사드립니다.
대부분의 앱들에서 제공하는 팝업 알림 기능에 단점이 존재한다면, 게임이나 영상물 등의 미디어 컨텐츠를 즐기거나, Microsoft PowerPoint (파워포인트) 앱에서 제공하는 슬라이드 쇼 기능으로 발표 중인 경우, 화면에 팝업 알림이 표시되면서 흐름이 끊기는 경우가 빈번합니다.
특히, 그래픽 카드를 이용한 게임 중에는 팝업 창을 닫거나, 제거하려고 [닫기 (X)] 버튼을 누르면, 창의 포커스가 바탕화면에 위치한 관계로, 즐기던 게임은 최소화되고 바탕 화면으로 전환됩니다. 이로 인하여, 사용자 경험에는 좋지 않은 영향을 끼칠 수 있는데요,
아래와 같이, 다른 프로그램이 전체 화면 [Full-Screen] 으로 실행 중인지 여부를 확인할 수 있는 방법을 구현해보았고, 이를 통해 팝업 창을 표시하기 전, 실행 환경을 감지하여 팝업 창 표시 여부에 대한 조건을 지정해줄 수 있습니다.
Imports System.Runtime.InteropServices
Module FullScreenAppsModule
<StructLayout(LayoutKind.Sequential)>
Public Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure
<DllImport("user32.dll", SetLastError:=True)>
Public Function GetWindowThreadProcessId(ByVal hWnd As IntPtr, <Out> ByRef lpdwProcessId As UInteger) As UInteger
End Function
<DllImport("user32.dll")>
Private Function GetWindowRect(ByVal hWnd As HandleRef,
<[In], Out> ByRef rect As RECT) As Boolean
End Function
<DllImport("user32.dll")>
Private Function GetForegroundWindow() As IntPtr
End Function
Public Function IsForegroundFullScreen() As Boolean
Return IsForegroundFullScreen(Nothing)
End Function
Public Function IsForegroundFullScreen(ByVal screen As System.Windows.Forms.Screen) As Boolean
If screen Is Nothing Then
screen = System.Windows.Forms.Screen.PrimaryScreen
End If
Dim rect As RECT = New RECT()
Dim hWnd As IntPtr = CType(GetForegroundWindow(), IntPtr)
GetWindowRect(New HandleRef(Nothing, hWnd), rect)
If screen.Bounds.Width = (rect.right - rect.left) AndAlso screen.Bounds.Height = (rect.bottom - rect.top) Then
Debug.WriteLine("Fullscreen apps are running.")
Return True
Else
Debug.WriteLine("Show Popup")
Return False
End If
End Function
End Module
위의 코드를 모듈에 넣고, 아래와 같이 IsForegroundFullScreen() 함수를 호출하셔서 사용하시면 됩니다.
If (My.Settings.FSCRFocusAssist AndAlso IsForegroundFullScreen()) Then
' fullscreen app open while focus assist enabled, only update if already open
If FrmNotify.Created Then
CalculateLevels()
AqiNotification.Show(
AqiNotiSyncRef.Aqi,
My.Settings.NotiAQI.Contains(CalcAirData.Aqi) AndAlso (incNotiCount.HasReachedTarget OrElse Not My.Settings.NotifyOnlyWhenAqiChange OrElse CalcAirData.AqiHasChanged))
Else
AqiNotification.Unready(AqiNotiSyncRef.Aqi)
End If
End If
도움이 되셨으면 좋겠습니다.
고맙습니다.