Seite 1 von 1

Vb-Miniaturansicht -> Purebasic

Verfasst: 21.03.2006 11:17
von roherter
Kennt sich hier jemand mit VB aus würde diesen Code nach Purebasic übersetzen!

Code: Alles auswählen

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2006 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'var for exposed property
Private m_lvInitialView As Long

'windows version constants
Private Const VER_PLATFORM_WIN32_NT As Long = 2
Private Const OSV_LENGTH As Long = 76
Private Const OSVEX_LENGTH As Long = 88
Public OSV_VERSION_LENGTH As Long 'our const to hold appropriate OSV length

Private Type OSVERSIONINFO
  OSVSize         As Long
  dwVerMajor      As Long
  dwVerMinor      As Long
  dwBuildNumber   As Long
  PlatformID      As Long
  szCSDVersion    As String * 128
End Type

'windows messages & notifications etc
Private Const WM_COMMAND = &H111
Public Const WM_NOTIFY As Long = &H4E&
Public Const WM_INITDIALOG As Long = &H110
Public Const CDN_FIRST As Long = -601
Public Const CDN_INITDONE As Long = (CDN_FIRST - &H0&)
Public Const MAX_PATH As Long = 260

'openfilename constants
Public Const OFN_ENABLEHOOK As Long = &H20
Public Const OFN_EXPLORER As Long = &H80000
Public Const OFN_ENABLESIZING As Long = &H800000
Public Const OFN_EX_NOPLACESBAR As Long = &H1

'constants for listview view state
'provided by Brad Martinez
Public Const SHVIEW_ICON As Long = &H7029
Public Const SHVIEW_LIST As Long = &H702B
Public Const SHVIEW_REPORT As Long = &H702C
Public Const SHVIEW_THUMBNAIL As Long = &H702D
Public Const SHVIEW_TILE As Long = &H702E

'this is the version 5+ definition of
'the OPENFILENAME structure containing
'three additional members providing
'additional options on Windows 2000
'or later. The SetOSVersion routine
'will assign either OSV_LENGTH (76)
'or OSVEX_LENGTH (88) to the OSV_VERSION_LENGTH
'variable declared above. This variable, rather
'than Len(OFN) is used to assign the required
'value to the OPENFILENAME structure's nStructSize
'member which tells the OS if extended features
'- primarily the Places Bar - are supported.
Public Type OPENFILENAME
  nStructSize       As Long
  hwndOwner         As Long
  hInstance         As Long
  sFilter           As String
  sCustomFilter     As String
  nMaxCustFilter    As Long
  nFilterIndex      As Long
  sFile             As String
  nMaxFile          As Long
  sFileTitle        As String
  nMaxTitle         As Long
  sInitialDir       As String
  sDialogTitle      As String
  flags             As Long
  nFileOffset       As Integer
  nFileExtension    As Integer
  sDefFileExt       As String
  nCustData         As Long
  fnHook            As Long
  sTemplateName     As String
  pvReserved        As Long
  dwReserved        As Long
  flagsEx           As Long
End Type

Public OFN As OPENFILENAME

'defined As Any to support either the
'OSVERSIONINFO or OSVERSIONINFOEX structure
Private Declare Function GetVersionEx Lib "kernel32" _
   Alias "GetVersionExA" _
  (lpVersionInformation As Any) As Long
  
Public Declare Function GetOpenFileName Lib "comdlg32.dll" _
   Alias "GetOpenFileNameA" _
  (pOpenfilename As OPENFILENAME) As Long

Private Declare Function FindWindowEx Lib "user32" _
   Alias "FindWindowExA" _
  (ByVal hWndParent As Long, _
   ByVal hWndChildAfter As Long, _
   ByVal lpClassName As String, _
   ByVal lpWindowName As String) As Long

Private Declare Function GetParent Lib "user32" _
  (ByVal hwnd As Long) As Long

Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" _
   (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long



Public Function FARPROC(pfn As Long) As Long
  
  'A dummy procedure that receives and returns
  'the return value of the AddressOf operator.
 
  'Obtain and set the address of the callback
  'This workaround is needed as you can't assign
  'AddressOf directly to a member of a user-
  'defined type, but you can assign it to another
  'long and use that (as returned here)

  FARPROC = pfn

End Function


Public Function IsWin2000Plus() As Boolean

  'returns True if running Windows 2000 or later
   Dim osv As OSVERSIONINFO

   osv.OSVSize = Len(osv)

   If GetVersionEx(osv) = 1 Then
   
      IsWin2000Plus = (osv.PlatformID = VER_PLATFORM_WIN32_NT) And _
                      (osv.dwVerMajor = 5 And osv.dwVerMinor >= 0)
  
   End If

End Function


Public Property Let OFN_SetInitialView(ByVal initview As Long)

   m_lvInitialView = initview
   
End Property


Public Function OFNHookProc(ByVal hwnd As Long, _
                            ByVal uMsg As Long, _
                            ByVal wParam As Long, _
                            ByVal lParam As Long) As Long

   Dim hWndParent As Long
   Dim hwndLv As Long
   Static bLvSetupDone As Boolean
   
   Select Case uMsg
      Case WM_INITDIALOG
        'Initdialog is set when the dialog
        'has been created and is ready to
        'be displayed, so set our flag
        'to prevent re-executing the code
        'in the wm_notify message. This is
        'required as the dialog receives a
        'number of WM_NOTIFY messages throughout
        'the life of the dialog. If this is not
        'done, and the user chooses a different
        'view, on the next WM_NOTIFY message
        'the listview would be reset to the
        'initial view, probably ticking off
        'the user. The variable is declared
        'static to preserve values between
        'calls; it will be automatically reset
        'on subsequent showing of the dialog.
         bLvSetupDone = False
         
        'other WM_INITDIALOG code here, such
        'as caption or button changing, or
        'centering the dialog.
      
      Case WM_NOTIFY
               
            If bLvSetupDone = False Then
               
             'hwnd is the handle to the dialog
             'hwndParent is the handle to the common control
             'hwndLv is the handle to the listview itself
               hWndParent = GetParent(hwnd)
               hwndLv = FindWindowEx(hWndParent, 0, "SHELLDLL_DefView", vbNullChar)
               
               If hwndLv > 0 Then
                  Call SendMessage(hwndLv, WM_COMMAND, ByVal m_lvInitialView, ByVal 0&)
                 
                 'since we found the lv hwnd, assume the
                 'command was received and set the flag
                 'to prevent recalling this routine
                  bLvSetupDone = True
               End If  'hwndLv

            End If  'bLvSetupDone

         Case Else
         
   End Select

End Function


Public Sub SetOSVersion()
  
   Select Case IsWin2000Plus()
      Case True
         OSV_VERSION_LENGTH = OSVEX_LENGTH '5.0+ structure size
      
      Case Else
         OSV_VERSION_LENGTH = OSV_LENGTH 'pre-5.0 structure size
   End Select

End Sub

Vielleicht kann mir dabei ja jemand helfen!

Verfasst: 21.03.2006 21:13
von roherter
danke und was bedeutet dann das &H???


Vielleicht kannste dir das mal anschauen Hallodri(oder alle anderen) es soll eigentlich die thumbnail vorschau erzeugen!
Geht aber irgendwie nicht!

Code: Alles auswählen

 
 Enumeration
#loll
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #ExplorerList_0
EndEnumeration

Global m_lvInitialView=$702D 
Global hwnd
Procedure OFN(WindowID, Message, wParam, lParam)
 
    Result = #PB_ProcessPureBasicEvents
 Static bLvSetupDone = #False
  Select Message
    Case #WM_INITDIALOG
      bLvSetupDone = #False
     
    Case #WM_NOTIFY
      If Not bLvSetupDone
     hWndParent = GetParent_(WindowID)
    
        hwndLv = FindWindowEx_(hWndParent, 0, @"SHELLDLL_DefView", 0)
        If hwndLv > 0
          SendMessage_(hwndLv, #WM_COMMAND, m_lvInitialView, 0)
          bLvSetupDone = #True
        EndIf
      EndIf
     
  EndSelect 
       

    ProcedureReturn Result
EndProcedure 

   hwnd= OpenWindow(#Window_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu  | #PB_Window_SizeGadget | #PB_Window_TitleBar ) 
 
    If hwnd
    If CreateGadgetList(WindowID(#Window_0))
      ExplorerListGadget(#ExplorerList_0, 100, 80, 260, 160, "")
      
    EndIf
  EndIf





SetWindowCallback(@OFN())
Repeat ; Start of the event loop
  
  Event = WaitWindowEvent() ; This line waits until an event is received from Windows
  
  WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
  
  GadgetID = EventGadget() ; Is it a gadget event?
  
  EventType = EventType() ; The event type
  
  ;You can place code here, and use the result as parameters for the procedures
  
  If Event = #PB_Event_Gadget
    
    If GadgetID = #ExplorerList_0
      
    EndIf
    
  EndIf
  
Until Event = #PB_Event_CloseWindow ; End of the event loop

End
;

Verfasst: 21.03.2006 21:19
von yuma
&H bedeutet, dass es sich um einen Hexwert handelt..

z.B. &h1a -> 26 dezimal 8)

Gruß
Yuma

Verfasst: 21.03.2006 21:27
von edel

Code: Alles auswählen

      ExplorerListGadget(#ExplorerList_0, 100, 80, 260, 160, "")
      style = getwindowlong_(GadgetID(#ExplorerList_0),#GWL_STYLE) 
      setwindowlong_(GadgetID(#ExplorerList_0),#GWL_STYLE,(style & ~ #LVS_REPORT) | #LVS_ICON)
Bin mir nicht ganz sicher was du meinst.

Verfasst: 21.03.2006 21:45
von roherter
ich meine sowas wie die miniaturansicht unter windows wo dann kleine Bilder angezeigt werden als vorschau!
Das wars leider nicht Trotzdem danke!

Kannst du mir was emphelen wo ich mehr zu dem thema finde(damit ich mal so schlau werde wie du :allright: )?