Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created April 3, 2012 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/2296043 to your computer and use it in GitHub Desktop.
Save kumatti1/2296043 to your computer and use it in GitHub Desktop.
Option Explicit
'UserFormモジュール
Private Declare Function FreeLibrary& Lib "Kernel32.dll" (ByVal hModule&)
Private Declare Function LoadLibraryW& Lib "Kernel32.dll" (ByVal lpFileName&)
Private Declare Function WindowFromAccessibleObject& Lib "Oleacc.dll" (ByVal pacc&, ByVal phwnd&)
Private Declare Function GetTopWindow& Lib "User32.dll" (ByVal hWnd&)
Private Declare Function GetModuleHandleW& Lib "Kernel32.dll" (ByVal lpModuleName&)
Private Declare Function GetWindowLongW& Lib "User32.dll" (ByVal hWnd&, ByVal nIndex&)
Private Declare Function SetWindowLongW& Lib "User32.dll" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
Const GWL_STYLE = -16
Const WS_CLIPCHILDREN = &H2000000
Private UIribbon As UIRibbonFramework 'IUIFramework
Private UIApp As Class1 'IUIApplication実装
Private hDll&
Private Sub UserForm_Initialize()
Dim hStyle&, h&, s$
Set UIribbon = New UIRibbonFramework
Set UIApp = New Class1
WindowFromAccessibleObject ObjPtr(Me), VarPtr(h)
'フリッカー対策
hStyle = GetWindowLongW(h, GWL_STYLE)
SetWindowLongW h, GWL_STYLE, hStyle Or WS_CLIPCHILDREN
UIribbon.Initialize h, UIApp
hDll = LoadLibraryW(StrPtr("dllへのパス"))
UIribbon.LoadUI hDll, StrPtr("APPLICATION_RIBBON")
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
UIribbon.Destroy
FreeLibrary hDll
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment