LoginSignup
0
0

More than 1 year has passed since last update.

【Win32API】ShowWindow をイイカンジに定義して使う

Last updated at Posted at 2022-08-14

Win32API をイイカンジに使いたい

定義

ShowWindow を VBAで定義するとこんな感じになる。

Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal nCmdShow As LongPtr) As LongPtr
Private Const SW_SHOWNORMAL    As Integer = 1
Private Const SW_SHOWMINIMIZED As Integer = 2
Private Const SW_SHOWMAXIMIZED As Integer = 3

使いやすくする

このままでは使いにくいので使いやすいようにラップする。heyYo

Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal nCmdShow As LongPtr) As LongPtr
Private Const SW_SHOWNORMAL    As Integer = 1
Private Const SW_SHOWMINIMIZED As Integer = 2
Private Const SW_SHOWMAXIMIZED As Integer = 3

Public Sub ShowWindowNormal()
  Call ShowWindow(Application.hwnd, SW_SHOWNORMAL)
End Sub

Public Sub ShowWindowMin()
  Call ShowWindow(Application.hwnd, SW_SHOWMINIMIZED)
End Sub

Public Sub ShowWindowMax()
  Call ShowWindow(Application.hwnd, SW_SHOWMAXIMIZED)
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0