Jump to content

Help with DllCall


Recommended Posts

can anyone help me with this dllcall please?

#include <WindowsConstants.au3>

#Include <GUIConstantsEx.au3>
#Include <Memory.au3>

Opt("GUIOnEventMode", 1)

$Gui = GUICreate("Test Alpha", 750, 590, 191, 113,BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION))

$S_DLL = DllOpen(@ScriptDir & "\Listview.dll")
ConsoleWrite("Dll:"&$S_DLL & @CRLF)
Local $H
$ret = DllCall($S_dll, "long", "CreateListview", _
                "long", $Gui, _
                "long", 0, _
                "long", -1, _
                "long", -1, _
                "long", -1, _
                "long", 2+10+20)
$ret = HWnd ($ret[0])
ConsoleWrite("LV:"&$ret & @CRLF)
$Guiplist1 = $ret

LV_Icolumn($Guiplist1, "Name", 100)
LV_Icolumn($Guiplist1, "Score", 20)
LV_Icolumn($Guiplist1, "Kills", 20)
LV_Icolumn($Guiplist1, "Deaths", 20)
LV_Icolumn($Guiplist1, "NHD", 40)
LV_Icolumn($Guiplist1, "GUID", 70)
LV_Icolumn($Guiplist1, "Slot", 100)

LV_SItem($Guiplist1, "hmmm")

$ret = DllCall($S_dll, "long", "ShowListview", "long", $Guiplist1, "long", 8, "long", 120, "long", 363, "long", 431)

GUISetState()

GUISetOnEvent($Gui_EVENT_CLOSE, "Close", $Gui)

While 1
    Sleep(10)
WEnd

Func LV_Icolumn($V_HwND, $LV_Text, $LV_Width = 100)
    Local $S_STRUCTs = "char[128]"
    $S_STRUCT = DllStructCreate($S_STRUCTs)
    DllStructSetData($S_STRUCT, 1, $LV_Text)
    $ret = DllCall($S_dll, "long", "IColumn", "long", $V_HwND, "long", DllStructGetPtr($S_STRUCT,1), "long", $LV_Width, "long", 0)
    Return $ret[0]
EndFunc


Func LV_SItem($LV_HwND, $LV_Text)
;~  SItem(H,B,A)
;~  Creates a new row and inserts items into the new row
 
;~  H : Long - Handle to the Listviewcontrol
;~  B : Pointer to a memoryregion with stringadresses
;~  A : Long - Number of strings that are used in region B

    $Pointer = _MemGlobalAlloc(256 + 4)

    $strp = DllStructCreate("ptr",$Pointer)
    $str = DllStructCreate("char[256]",$strp)
    DllStructSetData($str,1, $LV_Text)
    DllStructSetData($str,2,"hello")
    
    $ret = DllCall($S_dll, "long", "SItem", "long", $LV_HwND, "ptr", DllStructGetPtr($strp), "long", 2)
    Return $ret[0]
EndFunc

here is the required dll: http://84.146.77.178:8080/Listview.dll

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
Share on other sites

Hi,

here is a workable solution. All Dll-Calls now in functions.

#include <WindowsConstants.au3>
#Include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)

$dllFolder = "your_Listview.dll_Folder "
Global $S_Dll = DllOpen($dllFolder & "\Listview.dll")


$Gui = GUICreate("Test Alpha", 750, 590, 191, 113, _            BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION))
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$hListView = _CreateListview($Gui, 0, -1, -1, -1)

LV_Icolumn($hListView, "Name", 50)
LV_Icolumn($hListView, "Score", 50)
LV_Icolumn($hListView, "Kills", 50)
LV_Icolumn($hListView, "Deaths", 50)
LV_Icolumn($hListView, "NHD", 50)
LV_Icolumn($hListView, "GUID", 50)
LV_Icolumn($hListView, "Slot", 50)

LV_SItem($hListView, "Col1_1|Col1_2|Col1_3|Col1_4|Col1_5||Col1_7")
LV_SItem($hListView, "Col2_1|||Col2_4||Col2_6|Col2_7")
LV_SItem($hListView, "Col3_1|Col3_2||Col3_4|Col3_5||Col3_7")

LV_Show($hListView, 8, 120, 363, 431)

GUISetState()

While 1
    Sleep(10)
WEnd

Func Close()
    DllCall($S_Dll, 'long', 'EraseListview', 'hwnd', $hListView)
    Exit
EndFunc

;~ F : Long - Handle des Fensters, in dem das Listview erstellt werden soll (z.B.:%HWND).
;~ I : Long - Instance Handle des Fensters F (z.B.%HINSTANCE).
;~ T : Long - Textfarbe für Itemtexte (oder -1 für default)
;~ H : Long - Hintergrundfarbe des Listviews (oder -1 für default)
;~ G : Long - Texthintergrundfarbe für Itemtexte (oder -1 für default)
;~ S : Long - Styles für das Listview (LVS_EX_STYLES)
;~ listview&=CreateListview(%hwnd,%hinstance,0,Rgb(255,255,255),-1,$31)
Func _CreateListview($hWnd, $hInstance=0, $ColorItemTxt=-1, $BackColorLV=-1, $BackColorItemTxt=-1, $STYLES=0)
    Local $ret = DllCall($S_Dll, 'long', "CreateListview", _
                        'hwnd', $hWnd, 'long', $hInstance, 'long', $ColorItemTxt, 'long', $BackColorLV, _
                        'long', $BackColorItemTxt, 'long', $STYLES)
    If @error Then
        Return @error
    Else
        Return $ret[0]
    EndIf
EndFunc

;~ IColumn(H,T,B,F)
;~ H : Long - Handle eines mit CreateListview() erstellten Listview Controls.
;~ T : Long - (Addresse auf einen) Text des Spaltenbuttons.
;~ B : Long - Breite der Spalte in Pixel
;~ F : Long - Textformatierungs-Flag
;~ 0 = linksbündig
;~ 1 = rechtsbündig
;~ 2 = zentriert
Func LV_Icolumn($hWnd, $LV_Text, $LV_Width = 100, $iAlign=0)
    Local $Buffer = DllStructCreate("char[128]")
    DllStructSetData($Buffer, 1, $LV_Text)
    Local $ret = DllCall($S_Dll, "long", "IColumn", "hwnd", $hWnd, "ptr", DllStructGetPtr($Buffer), "long", $LV_Width, "long", $iAlign)
    If @error Then
        Return @error
    Else
        Return $ret[0]
    EndIf
EndFunc

;~  SItem(H,B,A)
;~  Creates a new row and inserts items into the new row
;~  H : Long - Handle to the Listviewcontrol
;~  B : Pointer to a memoryregion with stringadresses
;~  A : Long - Number of strings that are used in region B
Func LV_SItem($hWnd, $LV_Text, $Delim=Default)
    If $Delim = Default Then $Delim = Opt('GUIDataSeparatorChar')
    Local $val = $LV_Text
    $val = StringSplit($LV_Text, $Delim)
    Local $iCount = $val[0]
    Local $aBuffer[$iCount], $strucPointer = ''
    For $i = 0 To $iCount -1
        $aBuffer[$i] = DllStructCreate('char[256]')
        DllStructSetData($aBuffer[$i], 1, $val[$i+1])
        $strucPointer &= 'ptr;'
    Next
    Local $Pointer = DllStructCreate(StringTrimRight($strucPointer, 1))
    For $i = 1 To $iCount
        DllStructSetData($Pointer, $i, DllStructGetPtr($aBuffer[$i-1]))
    Next
    Local $ret = DllCall($S_Dll, "long", "SItem", "hwnd", $hWnd, "ptr", DllStructGetPtr($Pointer), "long", $iCount)
    If @error Then
        Return @error
    Else
        Return $ret[0]
    EndIf
EndFunc

;~ ShowListview(H,X,Y,B,H) Zeigt ein Listview auf dem Bildschirm an, das mit CreateListview() erzeugt wurde.
;~ H : Long - Handle eines mit CreateListview() erstellten Listview Controls
;~ X : Long - X-Koordinate des Listviews
;~ Y : Long - Y-Koordinate des Listviews
;~ B : Long - Breite des Listviews
;~ H : Long - Höhe des Listviews
Func LV_Show($hWnd, $X, $Y, $Width, $Height)
    Local $ret = DllCall($S_Dll, "long", "ShowListview", _
                        "hwnd", $hListView, "long", $X, "long", $Y, "long", $Width, "long", $Height)
    If @error Then
        Return @error
    Else
        Return $ret[0]
    EndIf
EndFunc
Edited by BugFix

Best Regards BugFix  

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...