Dim ThisTime As INFO, BeforeTime As INFO
Private Sub Form_Load()
Dim temp As String
ThisTime.StartTime = Format(Now, "hh:mm:ss")
Call ReadBeforeStatus(BeforeTime)
BeforeTime.lpwndpl.length = Len(BeforeTime.lpwndpl)
Call GetWindowPlacement(Me.hWnd, BeforeTime.lpwndpl)
Call SetWindowPlacement(Me.hWnd, BeforeTime.lpwndpl)
Me.Label4(0).Caption = BeforeTime.lpwndpl.rcNormalPosition.Left
Me.Label4(1).Caption = BeforeTime.lpwndpl.rcNormalPosition.Top
temp = ""
Select Case BeforeTime.lpwndpl.showCmd
Case SW_HIDE: temp = "非表示"
Case SW_MINIMIZE: temp = "アイコン化状態"
Case SW_RESTORE, SW_SHOWNORMAL: temp = "アクティブ状態"
Case SW_SHOW: temp = "アクティブ状態"
Case SW_SHOWMAXIMIZED: temp = "アクティブ & 最大化状態"
Case SW_SHOWMINIMIZED: temp = "アクティブ & 最小化状態"
Case SW_SHOWMINNOACTIVE: temp = "最小化状態"
Case SW_NOACTIVATE: temp = "非アクティブ状態"
End Select
Me.Label4(2).Caption = temp
Me.Label4(3).Caption = BeforeTime.StartTime
Me.Label4(4).Caption = BeforeTime.EndTime
Me.Label4(5).Caption = ThisTime.StartTime
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
ThisTime.EndTime = Format(Now, "hh:mm:ss")
Call SaveStatus(ThisTime)
End Sub
Private Sub Form_Unload(Cancel As Integer)
ThisTime.EndTime = Format(Now, "hh:mm:ss")
Call SaveStatus(ThisTime)
End Sub
Private Sub ReadBeforeStatus(param As INFO)
Dim temp As String, rc As Long
With param.lpwndpl
.flags = GetPrivateProfileInt("WindowPlacement", "flags", .flags, _
"WinAPI_Archive_Sample_12.ini")
.showCmd = GetPrivateProfileInt("WindowPlacement", "showCmd", _
.showCmd, "WinAPI_Archive_Sample_12.ini")
.ptMinPosition.x = GetPrivateProfileInt("WindowPlacement", "ptMinPosition.X", _
.ptMinPosition.x, "WinAPI_Archive_Sample_12.ini")
.ptMinPosition.y = GetPrivateProfileInt("WindowPlacement", "ptMinPosition.Y", _
.ptMinPosition.y, "WinAPI_Archive_Sample_12.ini")
.ptMaxPosition.x = GetPrivateProfileInt("WindowPlacement", "ptMaxPosition.X", _
.ptMaxPosition.x, "WinAPI_Archive_Sample_12.ini")
.ptMaxPosition.y = GetPrivateProfileInt("WindowPlacement", "ptMaxPosition.Y", _
.ptMaxPosition.y, "WinAPI_Archive_Sample_12.ini")
.rcNormalPosition.Left = GetPrivateProfileInt("WindowPlacement","rcNormalPosition.Left", _
.rcNormalPosition.Left, "WinAPI_Archive_Sample_12.ini")
.rcNormalPosition.Top = GetPrivateProfileInt("WindowPlacement","rcNormalPosition.Top", _
.rcNormalPosition.Top, "WinAPI_Archive_Sample_12.ini")
.rcNormalPosition.Right = GetPrivateProfileInt("WindowPlacement","rcNormalPosition.Right", _
.rcNormalPosition.Right, "WinAPI_Archive_Sample_12.ini")
.rcNormalPosition.Bottom = GetPrivateProfileInt("WindowPlacement","rcNormalPosition.Bottom", _
.rcNormalPosition.Bottom, "WinAPI_Archive_Sample_12.ini")
End With
With param
temp = String(260, Chr(0))
rc = GetPrivateProfileString("Time", "StartTime", vbNullString, temp, Len(temp), _
"WinAPI_Archive_Sample_12.ini")
.StartTime = Mid(temp, 1, rc)
temp = String(260, Chr(0))
rc = GetPrivateProfileString("Time", "EndTime", vbNullString, temp, Len(temp), _
"WinAPI_Archive_Sample_12.ini")
.EndTime = Mid(temp, 1, rc)
End With
End Sub
Private Sub SaveStatus(param As INFO)
Dim temp As String
param.lpwndpl.length = Len(lpwndpl)
Call GetWindowPlacement(Me.hWnd, param.lpwndpl)
With param.lpwndpl
temp = "flags=" & .flags & vbNullChar
temp = temp & "showCmd=" & .showCmd & vbNullChar
temp = temp & "ptMinPosition.X=" & .ptMinPosition.x & vbNullChar
temp = temp & "ptMinPosition.Y=" & .ptMinPosition.y & vbNullChar
temp = temp & "ptMaxPosition.X=" & .ptMaxPosition.x & vbNullChar
temp = temp & "ptMaxPosition.Y=" & .ptMaxPosition.y & vbNullChar
temp = temp & "rcNormalPosition.Left=" & .rcNormalPosition.Left & vbNullChar
temp = temp & "rcNormalPosition.Top=" & .rcNormalPosition.Top & vbNullChar
temp = temp & "rcNormalPosition.Right=" & .rcNormalPosition.Right & vbNullChar
temp = temp & "rcNormalPosition.Bottom=" & .rcNormalPosition.Bottom & vbNullChar & vbNullChar
Call WritePrivateProfileSection("WindowPlacement", temp, "WinAPI_Archive_Sample_12.ini")
End With
With param
temp = "StartTime=" & .StartTime & vbNullChar
temp = temp & "EndTime=" & .EndTime & vbNullChar & vbNullChar
Call WritePrivateProfileSection("Time", temp, "WinAPI_Archive_Sample_12.ini")
End With
End Sub |