[API]
PROPSHEETHEADER
PROPSHEETPAGE
CreatePropertySheetPageA
CreatePropertySheetPageW
PropertySheetA
PropertySheetW
Public IsDlgButtonChecked
Public CheckDlgButton

[INCLUDE]
LoadResEx_Dialog_Shared
LocalAllocFromString

[CODE]
Public Function LoadResEx_PagedDialog(ByVal hWndOwner As Long, ByVal ResDialogID As Long, ByVal ResDialogIDLast As Long, ByVal ResDialogIDStep As Long, Optional ByVal CallBackProc As Long, Optional ByVal CaptionID As Long = -1&) As Long ', Optional ByVal CallBackProcInit As Long)
  Dim xLong1 As Long
  Dim xMaxDialogPages As Long
  Dim xChar1 As String
  Dim xType1 As PROPSHEETHEADER
  Dim xLongA1() As Long
  Dim xLongA2() As Long
  Dim xTypeA1() As PROPSHEETPAGE

  xMaxDialogPages = (ResDialogIDLast - ResDialogID) \ ResDialogIDStep
  ReDim xLongA1(xMaxDialogPages)
  ReDim xLongA2(xMaxDialogPages)
  ReDim xTypeA1(xMaxDialogPages)
  
  xMaxDialogPages = 0&
  For xLong1 = ResDialogID To ResDialogIDLast Step ResDialogIDStep
    xChar1 = LoadResEx_Data("#" + CStr(xLong1), "#5", True)
    
    
    If Not Len(xChar1) = 0& Then
      HackDialogResource ResDialogID, xChar1
      
      xLongA1(xMaxDialogPages) = LocalAlloc(0&, Len(xChar1))
      If Not xLongA1(xMaxDialogPages) = 0& Then
        Call RtlMoveMemory(ByVal xLongA1(xMaxDialogPages), ByVal xChar1, Len(xChar1))
        With xTypeA1(xMaxDialogPages)
          .Size = Len(xTypeA1(0))
            .Flags = &H1&
          .hInstance = App.hInstance
          .pfnDlgProc = CallBackProc
          .pResource = xLongA1(xMaxDialogPages)
          
          If IsUnicode Then
            xLongA2(xMaxDialogPages) = CreatePropertySheetPageW(xTypeA1(xMaxDialogPages))
            Else
            xLongA2(xMaxDialogPages) = CreatePropertySheetPageA(xTypeA1(xMaxDialogPages))
            End If
          If xLongA2(xMaxDialogPages) = 0& Then
            Call LocalFree(xLongA1(xMaxDialogPages))
            Else
            xMaxDialogPages = xMaxDialogPages + 1&
            End If
          End With
        End If
      End If
    Next
  If Not xMaxDialogPages = 0& Then
    ReDim Preserve xTypeA1(xMaxDialogPages - 1&)
    With xType1
      .dwSize = Len(xType1)
      .nPages = xMaxDialogPages
      .hInstance = App.hInstance
      .hWndParent = hWndOwner
      .phpage = VarPtr(xLongA2(0))
      End With
    If CaptionID = -1& Then CaptionID = ResDialogID
    
    xType1.pszCaption = LocalAllocFromString(LoadResEx_String(CaptionID))
    If IsUnicode Then
      LoadResEx_PagedDialog = PropertySheetW(xType1)
      Else
      LoadResEx_PagedDialog = PropertySheetA(xType1)
      End If
    If Not xType1.pszCaption = 0& Then
      Call LocalFree(xType1.pszCaption)
      End If
    For xLong1 = 0& To xMaxDialogPages - 1&
      Call LocalFree(xLongA1(xLong1))
      Next
    End If
  End Function
