본문 바로가기
카테고리 없음

CATIA 64bit VBA Userform 창 크기 변경

by fimm 2016. 5. 16.
3DEXPERIENCE (CATIA V6)에 있는 VBA는 64bit로 변경되어서 그런지, VBA 버전이 올라가서 그런지,
기존 V5에서 사용하던 창크기 변경이 작동되지 않는 문제가 있다.

구글링해서 코드를 아래처럼 수정해봤더니 제대로 작동한다.


Option Explicit

Private Declare PtrSafe Function SetWindowLongPtr Lib "USER32" Alias "SetWindowLongPtrA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr

Private Declare PtrSafe Function GetWindowLongPtr Lib "USER32" Alias "GetWindowLongPtrA" (ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr

Private Declare PtrSafe Function FindWindowLongPtr Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr



Private Sub UserForm_Initialize()

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim hWnd As LongPtr
Dim Ret As LongPtr

    hWnd = FindWindowLongPtr(vbNullString, Me.Caption)  ''' // 현재유저폼의 핸들값을 얻어온다
    Ret = GetWindowLongPtr(hWnd, -16) ''' // 현재 생성된 윈도우 속성을 얻어온다

    Ret = Ret Or (&H10000) ''' // 최대화버튼 생성
    Ret = Ret Or (&H20000) ''' // 최소화버튼 생성
    Ret = Ret Or (&H40000) ''' // 크기조정이 가능하게 생성

    Call SetWindowLongPtr(hWnd, -16, Ret)  ''' // 속성변경
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

End Sub