|
ネットで情報を集めていると、
SetWindowLong(A)
この関数は SetWindowLongPtr に取って代わられています。32ビット版と64ビット版の Windows で共通して利用できるコードを記述する場合には、 SetWindowLongPtr 関数を使用する必要があります。
引用元:
http://yokohama.cool.ne.jp/chokuto/urawaza/api/SetWindowLong.html
とありましたので、SetWindowLongPtrを使うことにしました。
下記は最初に省略したAPI関数宣言部を含めたコードです。
引用元:http://park11.wakwak.com/~miko/Excel_Note/03-01_gamen.htm#03-01-01
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Public Sub HideSysMenu()
Dim Ret As Long
Dim hWnd As Long
Dim Wnd_STYLE As Long
hWnd = GetActiveWindow()
Wnd_STYLE = GetWindowLong(hWnd, GWL_STYLE)
Wnd_STYLE = Wnd_STYLE And (Not WS_SYSMENU)
Ret = SetWindowLong(hWnd, GWL_STYLE, Wnd_STYLE)
Ret = DrawMenuBar(hWnd)
End Sub
Public Sub RestoreSysMenu()
Dim Ret As Long
Dim hWnd As Long
Dim Wnd_STYLE As Long
hWnd = GetActiveWindow()
Wnd_STYLE = GetWindowLong(hWnd, GWL_STYLE)
Wnd_STYLE = Wnd_STYLE Or WS_SYSMENU
Ret = SetWindowLong(hWnd, GWL_STYLE, Wnd_STYLE)
Ret = DrawMenuBar(hWnd)
End Sub
いま、このコードの
SetWindowLongとGetActiveWindowをそれぞれ
SetWindowLongPtrとGetActiveWindowPtrに代えてみたのですがうまくいきません。
どうしたらよろしいのでしょうか?
下記のコードが変更したものです。
(単純にPtrを後ろにつけてみました。)
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Declare Function GetWindowLongPtr Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongPtr Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long_PTR) As Long
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Public Sub HideSysMenu()
Dim Ret As Long
Dim hWnd As Long
Dim Wnd_STYLE As Long
hWnd = GetActiveWindow()
Wnd_STYLE = GetWindowLongPtr(hWnd, GWL_STYLE)
Wnd_STYLE = Wnd_STYLE And (Not WS_SYSMENU)
Ret = SetWindowLongPtr(hWnd, GWL_STYLE, Wnd_STYLE)
Ret = DrawMenuBar(hWnd)
End Sub
Public Sub RestoreSysMenu()
Dim Ret As Long
Dim hWnd As Long
Dim Wnd_STYLE As Long
hWnd = GetActiveWindow()
Wnd_STYLE = GetWindowLongPtr(hWnd, GWL_STYLE)
Wnd_STYLE = Wnd_STYLE Or WS_SYSMENU
Ret = SetWindowLongPtr(hWnd, GWL_STYLE, Wnd_STYLE)
Ret = DrawMenuBar(hWnd)
End Sub
よろしくお願いします。
|
|