1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Oscar

Beiträge von Oscar

  • [offen] wNim wListCtrl sortieren - wie?

    • Oscar
    • 20. April 2023 um 08:40

    Ich habe mir das mit dem sortieren beim Listview mal in C++ angesehen.

    Man braucht gar nicht das Colum-Image ändern. Stattdessen handelt es sich um den Header des Listviews.

    Das Handle zum Header kann man ermitteln und dann die Sortierpfeile entsprechend anpassen (HDF_SORTUP und HDF_SORTDOWN).

    Hier mal als Beispielcode:

    Code
    import wNim, random, winim
    randomize()
    
    let app = App()
    let frame = Frame(title="ListviewSort", size=(640, 520))
    let panel = Panel(frame)
    
    let button = Button(panel, label="Sort", pos=(20, 420))
    
    let idPlaylist = ListCtrl(panel, style=wLcReport or wBorderSimple, pos=(10, 10), size=(600, 400))
    idPlaylist.font = Font(14, faceName="Arial", weight=wFontWeightNormal)
    idPlaylist.setBackgroundColor(0x00DDDDDD)
    idPlaylist.appendColumn("Interpret", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Titel", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Laufzeit", width=110, format=wListFormatRight)
    
    proc getItemTextString(self: wListCtrl, idx: int): seq[string] =
      let iCol = self.getColumnCount() # Anzahl der Spalten ermitteln
      for i in 0..iCol - 1: # Itemtext auslesen (alle Spalten)
        result.add(self.getItemText(idx, i))
    
    proc setItemTextString(self: wListCtrl, idx: int, sText: seq[string]): bool {.discardable.} =
      let iCol = self.getColumnCount() # Anzahl der Spalten ermitteln
      if iCol != sText.len: return false
      for i in 0..iCol - 1: # Itemtext ersetzen (alle Spalten)
        self.setItemText(idx, i, sText[i])
    
    # Ein paar Beispieldaten in das Listview eintragen
    idPlaylist.appendItem(["ZZ Down", "Gimme All", "03:53"])
    idPlaylist.appendItem(["Johnson Twins", "Bla bla", "04:16"])
    idPlaylist.appendItem(["Kniff Richard", "Yeah", "05:11"])
    idPlaylist.appendItem(["Roller Stones", "Gimme Shelter", "04:03"])
    idPlaylist.appendItem(["Ralph a Ville", "Moin", "03:46"])
    
    var
      iSortCol, iOldCol: int = -1
      bSortDir: bool = false
      bRanSort: bool = false
    
    # Callback-Funktion zum sortieren der Eintraege
    proc sortCmp(item1: int; item2: int; data: int): int =
      if bRanSort: return sample([-1, 1])
      result = cmp(idPlaylist.getItemText(item1, iSortCol), idPlaylist.getItemText(item2, iSortCol))
      if bSortDir: result *= -1
    
    # Funktion zum setzen des Sortierpfeils
    proc setSortArrow(self: wListCtrl, idx: int, arrow: int): bool {.discardable.} =
      var hdrItem: HDITEMA
      let header = HWND SendMessage(self.mHwnd, LVM_GETHEADER, 0, 0)
      if header != 0:
        hdrItem.mask = HDI_FORMAT
        if SendMessage(header, HDM_GETITEMA, idx, cast[LPARAM](&hdrItem)) != 0:
          case arrow:
            of 0:
              hdrItem.fmt = (hdrItem.fmt and not(HDF_SORTUP or HDF_SORTDOWN))
            of 1:
              hdrItem.fmt = (hdrItem.fmt and not(HDF_SORTUP)) or HDF_SORTDOWN
            of 2:
              hdrItem.fmt = (hdrItem.fmt and not(HDF_SORTDOWN)) or HDF_SORTUP 
            else:
              return false
          SendMessage(header, HDM_SETITEMA, idx, cast[LPARAM](&hdrItem))
          return true
      return false
    
    # Beim Klick auf ein Spalten-Header
    idPlaylist.wEvent_ListColClick do (event: wEvent):
      iSortCol = event.getColumn() # die Spalte ermitteln
      if iSortCol == iOldCol: # wenn die gleiche Spalte wie vorher
        bSortDir = not bSortDir # dann Sortier-Richtung umdrehen
      else: # ansonsten
        bSortDir = false # Sortier-Richtung auf aufsteigend setzen
        idPlaylist.setSortArrow(iOldCol, 0) # Pfeil von der alten Spalte entfernen
      iOldCol = iSortCol # die Spalte merken
      idPlaylist.setSortArrow(iSortCol, if bSortDir: 2 else: 1) # je nach Sortier-Richtung den Pfeil setzen
      idPlaylist.sortItemsByIndex(sortCmp) # und das Listview sortieren (Callback fuer den Vergleich)
    
    button.wEvent_Button do ():
      bRanSort = true
      idPlaylist.sortItemsByIndex(sortCmp) # und das Listview sortieren (Callback fuer den Vergleich)
      bRanSort = false
    
    frame.center()
    frame.show()
    app.mainLoop()
    Alles anzeigen

    Screenshot:

    sortierpfeil.png

  • [offen] wNim wListCtrl sortieren - wie?

    • Oscar
    • 18. April 2023 um 17:52
    Zitat von BugFix

    Hast du eine Einstellung entdeckt, dass man die Up/Down-Pfeile evtl. rechts vom Text im Header anordnen könnte?

    Hmm...das hat nichts mit den Sortier-Pfeilen zu tun. Das Problem liegt am Platz für den Checked-Haken.

    Der wird hier immer freigehalten, auch wenn der Modus gar nicht aktiv ist (idPlaylist.enableCheckBoxes(true) ist gar nicht vorhanden). Somit müsste die erste Spalte eigentlich ganz am Rand stehen, was aber nicht der Fall ist.

    Edit: Ein möglicher Workaround wäre, eine zusätzliche erste Spalte (mit Größe 0) einzufügen. So wird der Platz für den Checked-Haken auf Null gesetzt:

    Code
    import wNim, random
    randomize()
    
    let app = App()
    let frame = Frame(title="ListviewSort", size=(640, 520))
    let panel = Panel(frame)
    
    let button = Button(panel, label="Sort", pos=(20, 420))
    
    let idPlaylist = ListCtrl(panel, style=wLcReport or wBorderSimple or 0, pos=(10, 10), size=(600, 400))
    idPlaylist.font = Font(14, faceName="Arial", weight=wFontWeightNormal)
    idPlaylist.setBackgroundColor(0x00DDDDDD)
    idPlaylist.appendColumn("", width=0)
    idPlaylist.appendColumn("Interpret", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Titel", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Laufzeit", width=110, format=wListFormatRight)
    # idPlaylist.enableCheckBoxes(true)
    
    proc getItemTextString(self: wListCtrl, idx: int): seq[string] =
      let iCol = self.getColumnCount() # Anzahl der Spalten ermitteln
      for i in 0..iCol - 1: # Itemtext auslesen (alle Spalten)
        result.add(self.getItemText(idx, i))
    
    proc setItemTextString(self: wListCtrl, idx: int, sText: seq[string]): bool {.discardable.} =
      let iCol = self.getColumnCount() # Anzahl der Spalten ermitteln
      if iCol != sText.len: return false
      for i in 0..iCol - 1: # Itemtext ersetzen (alle Spalten)
        self.setItemText(idx, i, sText[i])
    
    # Ein paar Beispieldaten in das Listview eintragen
    idPlaylist.appendItem(["", "ZZ Down", "Gimme All", "03:53"])
    idPlaylist.appendItem(["", "Johnson Twins", "Bla bla", "04:16"])
    idPlaylist.appendItem(["", "Kniff Richard", "Yeah", "05:11"])
    idPlaylist.appendItem(["", "Roller Stones", "Gimme Shelter", "04:03"])
    idPlaylist.appendItem(["", "Ralph a Ville", "Moin", "03:46"])
    
    let hImgList = ImageList(16, 16) # Imagelist erstellen
    hImgList.add(Icon("shell32.dll,246")) # up-Icon
    hImgList.add(Icon("shell32.dll,247")) # down-Icon
    idPlaylist.setImageList(hImgList) # die Imagelist dem Listview zuordnen
    
    var
      iSortCol, iOldCol: int = -1
      bSortDir: bool = false
      bRanSort: bool = false
    
    # Callback-Funktion zum sortieren der Eintraege
    proc sortCmp(item1: int; item2: int; data: int): int =
      if bRanSort: return sample([-1, 1])
      result = cmp(idPlaylist.getItemText(item1, iSortCol), idPlaylist.getItemText(item2, iSortCol))
      if bSortDir: result *= -1
    
    # Beim Klick auf ein Spalten-Header
    idPlaylist.wEvent_ListColClick do (event: wEvent):
      iSortCol = event.getColumn() # die Spalte ermitteln
      if iSortCol == iOldCol: # wenn die gleiche Spalte wie vorher
        bSortDir = not bSortDir # dann Sortier-Richtung umdrehen
      else: # ansonsten
        bSortDir = false # Sortier-Richtung auf aufsteigend setzen
        idPlaylist.setColumnImage(iOldCol, -1) # und das vorherige Sortier-Image entfernen
      iOldCol = iSortCol # die Spalte merken
      idPlaylist.setColumnImage(iSortCol, if bSortDir: 1 else: 0) # Sortier-Image entsprechend der Richtung setzen
      idPlaylist.sortItemsByIndex(sortCmp) # und das Listview sortieren (Callback fuer den Vergleich)
    
    button.wEvent_Button do ():
      bRanSort = true
      idPlaylist.sortItemsByIndex(sortCmp) # und das Listview sortieren (Callback fuer den Vergleich)
      bRanSort = false
    
    frame.center()
    frame.show()
    app.mainLoop()
    Alles anzeigen
  • [offen] wNim wListCtrl sortieren - wie?

    • Oscar
    • 18. April 2023 um 13:43

    Noch etwas anderes: Hatten wir hier im Forum nicht mal ein Nim-Syntaxhighlighting?

  • [offen] wNim wListCtrl sortieren - wie?

    • Oscar
    • 18. April 2023 um 11:59
    Zitat von BugFix

    Aber wie soll ich Werte mit dieser Vorgabe vergleichen? Die Callback-Funktion verlangt Integer als Parameter und das Ergebnis ist auch Integer. Ich habe aber Textdaten in der Liste, die ich vergleichen möchte.

    Bei den Integerwerten für die Callback-Routine werden die Indexe der zu sortierenden LV-Einträge übergeben. Damit kannst Du dann den Itemtext auslesen und das Ergebnis des Vergleichs als Returnwert übergeben.

    Hier mal ein Beispiel:

    Code
    import wNim, random
    randomize()
    
    let app = App()
    let frame = Frame(title="ListviewSort", size=(640, 520))
    let panel = Panel(frame)
    
    let button = Button(panel, label="Sort", pos=(20, 420))
    
    let idPlaylist = ListCtrl(panel, style=wLcReport or wBorderSimple, pos=(10, 10), size=(600, 400))
    idPlaylist.font = Font(14, faceName="Arial", weight=wFontWeightNormal)
    idPlaylist.setBackgroundColor(0x00DDDDDD)
    idPlaylist.appendColumn("Interpret", width=200)
    idPlaylist.appendColumn("Titel", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Laufzeit", width=110, format=wListFormatRight)
    
    proc getItemTextString(self: wListCtrl, idx: int): seq[string] =
      let iCol = self.getColumnCount() # Anzahl der Spalten ermitteln
      for i in 0..iCol - 1: # Itemtext auslesen (alle Spalten)
        result.add(self.getItemText(idx, i))
    
    proc setItemTextString(self: wListCtrl, idx: int, sText: seq[string]): bool {.discardable.} =
      let iCol = self.getColumnCount() # Anzahl der Spalten ermitteln
      if iCol != sText.len: return false
      for i in 0..iCol - 1: # Itemtext ersetzen (alle Spalten)
        self.setItemText(idx, i, sText[i])
    
    # Ein paar Beispieldaten in das Listview eintragen
    idPlaylist.appendItem(["ZZ Down", "Gimme All", "03:53"])
    idPlaylist.appendItem(["Johnson Twins", "Bla bla", "04:16"])
    idPlaylist.appendItem(["Kniff Richard", "Yeah", "05:11"])
    idPlaylist.appendItem(["Roller Stones", "Gimme Shelter", "04:03"])
    idPlaylist.appendItem(["Ralph a Ville", "Moin", "03:46"])
    
    let hImgList = ImageList(16, 16) # Imagelist erstellen
    hImgList.add(Icon("shell32.dll,246")) # up-Icon
    hImgList.add(Icon("shell32.dll,247")) # down-Icon
    idPlaylist.setImageList(hImgList) # die Imagelist dem Listview zuordnen
    
    var
      iSortCol, iOldCol: int = -1
      bSortDir: bool = false
      bRanSort: bool = false
    
    # Callback-Funktion zum sortieren der Eintraege
    proc sortCmp(item1: int; item2: int; data: int): int =
      if bRanSort: return sample([-1, 1])
      result = cmp(idPlaylist.getItemText(item1, iSortCol), idPlaylist.getItemText(item2, iSortCol))
      if bSortDir: result *= -1
    
    # Beim Klick auf ein Spalten-Header
    idPlaylist.wEvent_ListColClick do (event: wEvent):
      iSortCol = event.getColumn() # die Spalte ermitteln
      if iSortCol == iOldCol: # wenn die gleiche Spalte wie vorher
        bSortDir = not bSortDir # dann Sortier-Richtung umdrehen
      else: # ansonsten
        bSortDir = false # Sortier-Richtung auf aufsteigend setzen
        idPlaylist.setColumnImage(iOldCol, -1) # und das vorherige Sortier-Image entfernen
      iOldCol = iSortCol # die Spalte merken
      idPlaylist.setColumnImage(iSortCol, if bSortDir: 1 else: 0) # Sortier-Image entsprechend der Richtung setzen
      idPlaylist.sortItemsByIndex(sortCmp) # und das Listview sortieren (Callback fuer den Vergleich)
    
    button.wEvent_Button do ():
      bRanSort = true
      idPlaylist.sortItemsByIndex(sortCmp) # und das Listview sortieren (Callback fuer den Vergleich)
      bRanSort = false
    
    frame.center()
    frame.show()
    app.mainLoop()
    Alles anzeigen
  • Matrix Falling Code

    • Oscar
    • 15. April 2023 um 08:46
    Zitat von o2candoo

    kann mir jemand erklären, warum die frame rate droped nach einer kurzen Zeit (sofern die Maus nicht bewegt wird) ?

    Das liegt am MessageLoop-Modus (GUIGetMsg in der Mainloop). GUIGetMsg erzeugt automatisch Sleeps (ohne Mausbewegung/Tastatureingaben), um den Prozessor zu entlasten.

    Nimm lieber den OnEvent-Modus oder benutzte die Timer-UDF für die Zeichenoperationen.

  • TabItem und ListView

    • Oscar
    • 14. April 2023 um 15:51
    Zitat von BlutigerAnfänger

    darf ich Hilfe erwarten?

    So geht's:

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiEdit.au3>
    #include <ColorConstants.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    
    #Region ### START Koda GUI section ### Form=
    Local $Form1 = GUICreate("Form1", 600, 600, 192, 114)
    Local $Tab1 = GUICtrlCreateTab(50, 16, 1105, 561)
    
    Local $TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
    Local $Button1 = GUICtrlCreateButton("TabSheet1 Auswahl", 250, 450, 200, 33, 0)
    Local $hListView = GUICtrlCreateListView("", 100, 100, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    
    Local $TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
    
    Local $Button2 = GUICtrlCreateButton("TabSheet2 Auswahl", 250, 450, 200, 33, 0)
    Local $hListView2 = GUICtrlCreateListView("", 100, 100, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    GUISetState()
    
    ; Fügt die Spalten hinzu
    _GUICtrlListView_AddColumn($hListView, "Spalte 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Spalte 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Spalte 3", 100)
    
    ; Fügt die Items hinzu
    _GUICtrlListView_AddItem($hListView, "Zeile 1: Spalte 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Zeile 1: Spalte 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Zeile 1: Spalte 3", 2)
    _GUICtrlListView_AddItem($hListView, "Zeile 2: Spalte 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Zeile 2: Spalte 2", 1)
    _GUICtrlListView_AddItem($hListView, "Zeile 3: Spalte 1", 2)
    
    _GUICtrlListView_AddColumn($hListView2, "Spalte 1", 100)
    _GUICtrlListView_AddColumn($hListView2, "Spalte 2", 100)
    _GUICtrlListView_AddColumn($hListView2, "Spalte 3", 100)
    
    ; Fügt die Items hinzu
    _GUICtrlListView_AddItem($hListView2, "Zeile 1: Spalte 1", 0)
    _GUICtrlListView_AddSubItem($hListView2, 0, "Zeile 1: Spalte 2", 1)
    _GUICtrlListView_AddSubItem($hListView2, 0, "Zeile 1: Spalte 3", 2)
    _GUICtrlListView_AddItem($hListView2, "Zeile 2: Spalte 1", 1)
    _GUICtrlListView_AddSubItem($hListView2, 1, "Zeile 2: Spalte 2", 1)
    _GUICtrlListView_AddItem($hListView2, "Zeile 3: Spalte 1", 2)
    
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Tab1
                Switch GUICtrlRead($Tab1)
                    Case 0
                        MsgBox(4160, "Information", "TabSheet1")
                    Case 1
                        MsgBox(4160, "Information", "TabSheet2")
                EndSwitch
            Case $Button1
                MsgBox(4160, "Information", "Items angehakt: " & _GUICltrListView_GetCheckedItems($hListView))
    
            Case $Button2
                MsgBox(4160, "Information", "Items angehakt: " & _GUICltrListView_GetCheckedItems($hListView2))
        EndSwitch
    WEnd
    
    Func _GUICltrListView_GetCheckedItems($hLV, $bArrayRet = False)
        Local $iCnt = _GUICtrlListView_GetItemCount($hLV), $sSelItems = ''
        For $iIndex = 0 To $iCnt - 1
            If _GUICtrlListView_GetItemChecked($hLV, $iIndex) Then $sSelItems &= $iIndex & '|'
        Next
        $sSelItems = StringTrimRight($sSelItems, 1)
        Return ($bArrayRet ? StringSplit($sSelItems, '|', 2) : $sSelItems)
    EndFunc   ;==>_GUICltrListView_GetCheckedItems
    Alles anzeigen
  • Icon (Symbol) ändern und die Größe beibehalten

    • Oscar
    • 5. April 2023 um 14:01

    Ja, ich wollte eigentlich noch etwas zu dem "warum: GUICtlrCreatePic" schreiben, hatte aber nicht mehr soviel Zeit.

    Deswegen hier die Erklärung:

    Bei GUICtrlCreateIcon gibt es einen Bug: wenn man keine Icondatei beim Erstellen angibt, wird ein Platzhalter mit den Maßen 0,0 (width, height) erzeugt, und _WinAPI_GetClientRect liefert nicht die korrekten Daten.

    Bei GUICtlrCreatePic tritt das nicht auf, weshalb ich bevorzugt dieses Controlelement benutze.

    Beispiel:

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <WinAPISysInternals.au3>
    
    $hGui = GUICreate("test", 320, 240)
    
    $idIcon = GUICtrlCreateIcon("", -1, 40, 40, 20, 20) ; GUICtrlCreateIcon (leer)
    $tRect = _WinAPI_GetClientRect(GUICtrlGetHandle($idIcon))
    ConsoleWrite('w,h: ' & $tRect.Right & ',' & $tRect.Bottom & @CRLF)
    
    $idPic = GUICtrlCreatePic("", 80, 40, 20, 20) ; GUICtrlCreatePic (leer)
    $tRect = _WinAPI_GetClientRect(GUICtrlGetHandle($idPic))
    ConsoleWrite('w,h: ' & $tRect.Right & ',' & $tRect.Bottom & @CRLF)
    Alles anzeigen
  • Icon (Symbol) ändern und die Größe beibehalten

    • Oscar
    • 4. April 2023 um 17:42

    Ich würde lieber ein Pic-Control nehmen und eine kleine (selbstgeschriebene) Funktion:

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <SendMessage.au3>
    #include <StaticConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIHObj.au3>
    #include <WinAPIInternals.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPISysInternals.au3>
    
    ;Test_Icongroesse
    
    local $rot = 100
    local $gruen = 101
    
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 519, 305, 674, 144)
    $Icon1 = GUICtrlCreatePic("", 40, 40, 50, 50)
    _GuiCtrlSetImage(-1, "C:\Windows\System32\imageres.dll", $rot)
    $Button1 = GUICtrlCreateButton("Button1", 130, 45, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                _GuiCtrlSetImage($Icon1, "C:\Windows\System32\imageres.dll", $gruen)
        EndSwitch
    WEnd
    
    Func _GuiCtrlSetImage($hWnd, $sIconfile, $iIndex)
        If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
        If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)
        Local $tRect, $hIcon, $hHBitmap
        $tRect = _WinAPI_GetClientRect($hWnd)
        $hIcon = _WinAPI_ShellExtractIcon($sIconfile, $iIndex, $tRect.Right, $tRect.Bottom)
        If Not $hIcon Then Return SetError(2, 0, 0)
        $hHBitmap = _WinAPI_Create32BitHBITMAP($hIcon, False, True)
        _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
        _WinAPI_DeleteObject($hHBitmap)
    EndFunc
    Alles anzeigen
  • Programm läuft-Anzeige

    • Oscar
    • 27. März 2023 um 18:42

    Ich gebe zu Bedenken, dass eine Aktualisierung bei jedem Schleifendurchlauf u.U. dazu führt, dass der Prozessor mehr mit dem aktualisieren beschäftigt ist, als die eigentliche Aufgabe auszuführen.

    Deshalb wäre eine Aktualisierung nur alle xxx Millisekunden viel zielführender. Sowas lässt sich sehr leicht mit einem Timer realisieren.

  • [offen] Problem: Kompiliert als GUI - CopyToClipboard nicht möglich!

    • Oscar
    • 13. März 2023 um 14:30
    Zitat von BugFix

    Hat jemand eine Idee, wie ich das gebacken bekomme?

    Habe schon länger nichts mit NIM gemacht, musste mich erst wieder einlesen. :)

    Man muss OpenClipboard mit dem Fensterhandle aufrufen und EmptyClipboard verwenden, dann funktioniert es auch mit Office.

    Hier mal die geänderte Funktion:

    Code
    import wNim, winim
    
    proc ClipPut*(sText: string = "", wFr: wFrame): bool {.discardable.} =
      if sText == "": return false
      let data = newWideCString(sText)
      let pData = cast[LPWSTR](data[0].addr)
      let iLen = data.len * 2 + 2
      # Allocate memory for the data (GHND = Combines GMEM_MOVEABLE and GMEM_ZEROINIT)
      let hMem = GlobalAlloc(GHND, cast[SIZE_T](iLen))
      if hMem == 0: return false
      let pMem = GlobalLock(hMem) # Get pointer
      if pMem == NULL: return false
      copyMem(pMem, pData, iLen) # Copy data to allocated memory 
      GlobalUnlock(hMem) # Unlock memory
      if OpenClipboard(wFr.mHwnd) == 0: # OpenClipboard mit dem Fenster-Handle aufrufen
        GlobalFree(hMem)
        return false
      EmptyClipboard() # Clipboard-Inhalt loeschen
      if SetClipboardData(CF_UNICODETEXT, hMem) == 0: # Copy data to clipboard
        GlobalFree(hMem)
        CloseClipboard()
        return false
      return CloseClipboard() != 0
    
    let app = App()
    let frame = Frame(title="test", size=(320, 240))
    let panel = Panel(frame)
    frame.center()
    frame.show()
    ClipPut("Das ist eine neue Testzeile.", frame)
    app.mainLoop()
    Alles anzeigen
  • GUICtrlScrolltext

    • Oscar
    • 16. Februar 2023 um 13:31
    Zitat von Velted

    Mit einer nicht dokumentierten Windowsfunktion geht das auch mit deutlich weniger CPU-Last:

    Cool! Ich hatte schon ziemlich lange nach einer anderen Sleep-Funktion gesucht, aber diese Variante habe ich nicht gefunden.

    Vielen Dank dafür! :):thumbup:

    Ich habe das Beispielscript in Post#1 entsprechend angepasst.

  • GUICtrlScrolltext

    • Oscar
    • 15. Februar 2023 um 17:48

    Um einen Text auf einer GUI als Laufschrift auszugeben, gibt es in AutoIt standardmäßig nur die Möglichkeit den Text zeichenweise nach links laufen zu lassen.

    Das sieht nicht so toll aus und meistens ruckelt es auch.

    Hier kommt jetzt meine UDF zum Einsatz, die den gesamten Text vorab rendert und als HBitmap speichert. Anschließend kann man diese HBitmap dann pixelweise in ein Pic-Control blitten.

    Das ist (zumindest auf meinem Rechner) schön flüssig und sieht ganz gut aus (siehe Beispielscript im Anhang).

    Was bietet meine UDF:

    1. beliebiger Text (kann bis 2^32 Pixel lang sein, das sollte selbst fuer sehr viel Text reichen)

    2. jeder installierte Zeichensatz kann benutzt werden

    3. die Hoehe des Zeichensatzes wird automatisch ermittelt (anhand der Größe des Scrolltext-Control)

    4. der Zeichensatzstil (Kombinationen möglich) kann ausgewählt werden (0 = normal, 1 = bold, 2 = italic, 4 = underline, 8 = strikethrough)

    5. die Vorder- und Hintergrundfarbe des Textes sind frei wählbar (RGB-Format)

    6. wenn der Text komplett durchgescrollt wurde, wird "True" statt "False" zurückgegeben, sodass man dann darauf reagieren kann

    Update 16.02.2022:

    Mit der "_ShortSleep"-Funktion von Velted läuft das Beispiel auch mit einer niedrigeren Verzögerung als 10ms (Standard-Sleep) mit einer geringen Prozessorlast. Vielen Dank Velted!

    Hier das Example mit der erwähnten Funktion:

    AutoIt
    #include <GUIConstantsEx.au3>
    
    #include '_GUICtrlScrolltext.au3'
    
    Opt('GUIOnEventMode', 1)
    _SetMinSleep()
    
    OnAutoItExitRegister('_AutoItExit')
    
    Global $aText[2], $iTextIdx = 0
    $aText[0] = 'Ein Beispieltext: Anlässlich des europäischen Tags des Notrufs möchten wir daran erinnern, ' & _
            'dass Sie Notfallkontakte oder Notfalldaten in Ihrem Smartphone hinterlegen können. ' & _
            'Notfallkontakte können Sie beispielsweise auch informieren, ohne direkt einen Notruf abzusetzen. ' & _
            'Vielen Menschen sind diese Funktionen ihres Smartphones nach wie vor nicht bekannt, dabei können ' & _
            'diese Daten in medizinischen Notfällen lebensrettend sein, vor allem, wenn die Person nicht in ' & _
            'der Lage ist, die benötigten Informationen selbst mitzuteilen.'
    
    $aText[1] = 'Bei dieser Scrolltext-UDF wird der zu scrollende Text komplett gerendert und als HBitmap ' & _
            'zwischengespeichert. Diese HBitmap wird dann pixelweise in das vorher erstellte Pic-Control geblittet. ' & _
            'Die Schriftgröße wird beim erstellen des Textes an die Höhe des Pic-Control angepasst. Die Schriftart, ' & _
            'der Style und die Vorder-/Hintergrundfarbe der Schrift können bei jedem neuen Text geändert werden. '
    
    Global $g_iMainWidth = @DesktopWidth / 2, $g_iMainHeight = 180
    Global $g_hMainGui = GUICreate('Scrolltext Example', $g_iMainWidth, $g_iMainHeight, @DesktopWidth / 2 - $g_iMainWidth / 2, 10)
    GUISetBkColor(0x202020, $g_hMainGui)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_AutoItExit')
    
    ; Parameter: Text, Left, Top, Width, Height, Fontname, Fontstyle, TextColor, BkColor
    ; Fontstyle: 0 = normal, 1 = bold, 2 = italic, 4 = underline, 8 = strikethrough
    Global $g_tScroll = _GUICtrlScrolltext_Create('Test 5 4 3 2 1', 0, 40, _
            $g_iMainWidth, $g_iMainHeight - 80, 'Courier New', 1, 0xFFFF00, 0x000066)
    
    GUISetState(@SW_SHOW, $g_hMainGui)
    
    #Region *** MainLoop ***
    While True
        ; wenn die Laufschrift komplett durchgelaufen ist (Funktion gibt TRUE zurueck), dann...
        If _GUICtrlScrolltext_DrawNextFrame($g_tScroll, 1) Then
            Sleep(1000) ; 1000ms (= 1 sek.) nichts tun
            $iTextIdx += 1 ; zum naechsten Text im Array wechseln
            If $iTextIdx = 2 Then $iTextIdx = 0
            Switch $iTextIdx
                Case 0
                    ; Parameter: Scrollstruct, Text, Fontname, Fontstyle, TextColor, BkColor
                    ; Fontstyle: 0 = normal, 1 = bold, 2 = italic, 4 = underline, 8 = strikethrough
                    _GUICtrlScrolltext_SetData($g_tScroll, $aText[$iTextIdx], 'Verdana', 3, 0x000088, 0xFFFF88)
                Case 1
                    ; Parameter: Scrollstruct, Text, Fontname, Fontstyle, TextColor, BkColor
                    ; Fontstyle: 0 = normal, 1 = bold, 2 = italic, 4 = underline, 8 = strikethrough
                    _GUICtrlScrolltext_SetData($g_tScroll, $aText[$iTextIdx], 'Times New Roman', 2, 0x000000, 0xFFFFFF)
            EndSwitch
        Else ; Laufschrift ist noch nicht durchgelaufen, also warten bis zum naechsten Frame
            _ShortSleep(4)
        EndIf
    WEnd
    #EndRegion *** MainLoop ***
    
    Func _ShortSleep($mSec)
        DllCall('Kernel32.dll', 'None', 'Sleep', 'DWORD', $mSec)
    EndFunc
    
    Func _AutoItExit()
        _SetMinSleep(False)
        _GUICtrlScrolltext_Delete($g_tScroll)
        GUIDelete($g_hMainGui)
        Exit
    EndFunc   ;==>_AutoItExit
    
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _SetMinSleep
    ; Description ...: Diese Funktion setzt die Auflösung des System Timers für den aufrufenden Prozess.
    ; Syntax.........: _SetMinSleep([$bSet])
    ; Parameters ....: $bSet = True  - setzt die Auflösung auf den minimalen Wert (in der Regel 0,5 Millisekunden)
    ;                              False - setzt die AUflösung auf den ursprnglichen Wert zurück.
    ; Return values .: Kein Rückgabewert
    ; Author ........: www.autoit.de
    ; ===============================================================================================================================
    Func _SetMinSleep($bSet = True)
        ; http://undocumented.ntinternals.net/index.html?page=UserMode/Undocumented Functions/Time/NtSetTimerResolution.html
        Static $iMax = 0, $iMin = 0, $iCurrent = 0
        Local $tMax, $tMin
        Local $tCur = DllStructCreate('UInt Val')
        If $iMin = 0 Then
            $tMax = DllStructCreate('UInt Val')
            $tMin = DllStructCreate('UInt Val')
            DllCall('Ntdll.dll', 'None', 'NtQueryTimerResolution', 'Struct*', $tMax,  'Struct*', $tMin,  'Struct*', $tCur)
            $iMax = $tMax.Val
            $iMin = $tMin.Val
            $iCur = $tCur.Val
        EndIf
        If $bSet Then
            DllCall('Ntdll.dll', 'None', 'NtSetTimerResolution', 'UInt', $iMin,  'UInt', 1,  'Struct*', $tCur)
        Else
            DllCall('Ntdll.dll', 'None', 'NtSetTimerResolution', 'UInt', $iCur,  'UInt', 1,  'Struct*', $tCur)
        EndIf
    EndFunc   ;==>_SetMinSleep
    Alles anzeigen

    Screenshot:

    GUICtrlScrolltext.png

    Dateien

    _GUICtrlScrolltext.zip 4,16 kB – 288 Downloads
  • Beispiel für ein Syslink-Control

    • Oscar
    • 5. Februar 2023 um 08:37

    Ein Problem gab es noch: und zwar den Fokus-Rahmen. Der war immer dunkelblau, was auf einem dunklen Hintergrund natürlich ungünstig ist.

    Jetzt habe ich es geschafft, eine Funktion zu schreiben, die mir den Index vom Link mit dem Focus zurückgibt, aber $NM_CUSTOMTEXT gibt mir nur den Text aus, aber nicht den Index des gerade zu zeichnenden Textes.

    Also habe ich etwas getrickst und die Texte selbst mit einem Index versehen. Dazu benutze ich eine statische MAP, um die Texte und die Indizes zu speichern.

    Auf jeden Fall kann man so auch die Farbe für den Fokus-Rahmen ändern (wegen der MAP nur mit der aktuellen AutoIt-Version):

    AutoIt
    #include <APIGdiConstants.au3>
    #include <FontConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SendMessage.au3>
    #include <StructureConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIGdiDC.au3>
    #include <WinAPIGdiInternals.au3>
    #include <WinAPIHObj.au3>
    #include <WinAPIInternals.au3>
    #include <WinAPISysInternals.au3>
    #include <WindowsConstants.au3>
    
    #include <WinAPIRes.au3>
    ; This example works in 32bit and 64bit mode (n/y)
    #AutoIt3Wrapper_UseX64=y
    
    ; This function ensures that the common control DLL (Comctl32.dll) is loaded,
    ; and registers ICC_LINK_CLASS from the DLL.
    ; Minimum supported client:    Windows Vista
    If Not _WinAPI_Init_ICC_LINK_CLASS() Then Exit
    
    #Region *** Structs and constants for the syslink control ***
    
    ; The LITEM struct used to set and retrieve information about a link item.
    Global Const $tagLITEM = 'struct;uint mask;int iLink;uint state;uint stateMask;wchar szID[48];wchar szURL[2083];endstruct'
    
    ; The NMLINK struct contains notification information. Send this structure with the NM_CLICK or NM_RETURN messages.
    Global Const $tagNMLINK = 'struct;' & $tagNMHDR & ';' & $tagLITEM & ';endstruct'
    
    ; The NMCUSTOMTEXT struct contains information used with custom text notification.
    Global Const $tagNMCUSTOMTEXT = 'struct;' & $tagNMHDR & ';handle hDC;ptr lpString;int nCount;ptr lpRect;uint uFormat;bool fLink;endstruct'
    
    
    Global Const $NM_CUSTOMTEXT = $NM_FIRST - 24 ; Notifies a control's parent window about custom text operations. This notification code is sent in the form of a WM_NOTIFY message.
    Global Const $LM_HITTEST = $WM_USER + 0x300 ; Determines whether the user clicked the specified link.
    Global Const $LM_GETIDEALHEIGHT = $WM_USER + 0x301 ; Retrieves the preferred height of a link for the control's current width.
    Global Const $LM_GETIDEALSIZE = $LM_GETIDEALHEIGHT ; Retrieves the preferred height of a link for the control's current width.
    Global Const $LM_SETITEM = $WM_USER + 0x302 ; Sets the states and attributes of an item.
    Global Const $LM_GETITEM = $WM_USER + 0x303 ; Retrieves the states and attributes of an item.
    
    
    Global Const $LIF_ITEMINDEX = 0x00000001 ; Retrieve the numeric item index. Items are always accessed by index, therefore you must always set this flag and assign a value to iLink. To obtain the item ID you must set both LIF_ITEMINDEX and LIF_ITEMID.
    Global Const $LIF_STATE = 0x00000002 ; Use stateMask to get or set the state of the link.
    Global Const $LIF_ITEMID = 0x00000004 ; Specify the item by the ID value given in szID.
    Global Const $LIF_URL = 0x00000008 ; Set or get the URL for this item.
    
    
    Global Const $LIS_FOCUSED = 0x00000001 ; The link has the keyboard focus. Pressing ENTER sends an NM_CLICK notification.
    Global Const $LIS_ENABLED = 0x00000002 ; The link can respond to user input. This is the default unless the entire control was created with WS_DISABLED. In this case, all links are disabled.
    Global Const $LIS_VISITED = 0x00000004 ; The link has been visited by the user. Changing the URL to one that has not been visited causes this flag to be cleared.
    Global Const $LIS_HOTTRACK = 0x00000008 ; Indicates that the syslink control will highlight in a different color (COLOR_HIGHLIGHT) when the mouse hovers over the control.
    Global Const $LIS_DEFAULTCOLORS = 0x00000010 ; Enable custom text colors to be used.
    
    
    Global Const $LWS_TRANSPARENT = 0x0001 ; The background mix mode is transparent.
    Global Const $LWS_IGNORERETURN = 0x0002 ; When the link has keyboard focus and the user presses Enter, the keystroke is ignored by the control and passed to the host dialog box.
    Global Const $LWS_NOPREFIX = 0x0004 ; Windows Vista. If the text contains an ampersand, it is treated as a literal character rather than the prefix to a shortcut key.
    Global Const $LWS_USEVISUALSTYLE = 0x0008 ; Windows Vista. The link is displayed in the current visual style.
    Global Const $LWS_USECUSTOMTEXT = 0x0010 ; Windows Vista. An NM_CUSTOMTEXT notification is sent when the control is drawn, so that the application can supply text dynamically.
    Global Const $LWS_RIGHT = 0x0020 ; Windows Vista. The text is right-justified.
    
    #EndRegion *** Structs and constants for the syslink control ***
    
    
    #Region *** Example gui and syslink control ***
    
    Opt('GUIOnEventMode', 1) ; Enable OnEventMode
    
    Global Const $g_iBkColor = 0x303030, $g_iTxtColor = 0xE0E0E0
    
    Global $g_hMainGui = GUICreate('Syslink example 2023/02/05', 640, 280)
    GUISetBkColor($g_iBkColor, $g_hMainGui)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CloseMainGui')
    
    ; create the text including the links (as in HTML)
    Global $g_sText = 'This example was created by Oscar (autoit.de).' & @CRLF & @CRLF & _
            'AutoIt © 1999-2022 Jonathan Bennett' & @CRLF & _
            'Homepage: <a href="https://www.autoitscript.com/site/autoit/">www.autoitscript.com</a>' & @CRLF & _
            'Homepage deutsch: <a href="https://autoit.de/wcf/">autoit.de</a>' & @CRLF & _
            'Onlinehilfe deutsch: <a href="https://autoit.de/onlinehilfe/online/html/index.htm">autoit.de/onlinehilfe</a>'
    
    ; create syslink control
    Global $g_hSyslink = _WinAPI_CreateWindowEx(0, $WC_LINK, $g_sText, _
            BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $LWS_TRANSPARENT, $LWS_USECUSTOMTEXT), _
            20, 10, 620, 200, $g_hMainGui)
    
    ; create desired font
    Global $g_hFont = _WinAPI_CreateFont(32, 0, 0, 0, $FW_SEMIBOLD, True, False, False, $DEFAULT_CHARSET, _
            $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, 0, 'Times New Roman')
    
    ; and send the font to the syslink control
    _SendMessage($g_hSyslink, $WM_SETFONT, $g_hFont, True)
    
    Global $g_idClose = GUICtrlCreateButton('Close', 240, 230, 120, 30)
    GUICtrlSetFont(-1, 14, 400, 0, 'Verdana')
    GUICtrlSetOnEvent(-1, '_CloseMainGui')
    GUICtrlSetState(-1, $GUI_FOCUS)
    
    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    GUISetState(@SW_SHOW, $g_hMainGui)
    
    _WinAPI_SetFocus($g_hSyslink) ; set the focus to the syslink window
    _Syslink_SetItem($g_hSyslink, 1, BitOR($LIS_ENABLED, $LIS_FOCUSED)) ; set the focus on the link nr. 1
    
    WinWaitClose($g_hMainGui) ; wait until the main window is closed
    Exit
    
    #EndRegion *** Example gui and syslink control ***
    
    Func _CloseMainGui()
        _WinAPI_DeleteObject($g_hFont) ; delete font
        _WinAPI_DestroyWindow($g_hSyslink) ; destroy syslink control
        GUIDelete($g_hMainGui) ; close the main window (leads to exit)
    EndFunc   ;==>_CloseMainGui
    
    Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam
        Local Static $mLinks[], $iIndex = 0 ; to indexing the links
        Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        Switch $tNMHDR.hWndFrom ; which Control send the message?
            Case $g_hSyslink ; when syslink control
                Switch $tNMHDR.Code ; which code?
                    Case $NM_CLICK, $NM_RETURN ; mouseclick or <RETURN> on a link
                        Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
                        ShellExecute($tNMLINK.szURL)
                    Case $NM_CUSTOMTEXT ; only works if "$LWS_USECUSTOMTEXT" is present at the syslink style!
                        Local $tNMCUSTOMTEXT = DllStructCreate($tagNMCUSTOMTEXT, $lParam)
                        If $tNMCUSTOMTEXT.nCount > 0 Then ; if the text length is greater than 0
                            If $tNMCUSTOMTEXT.fLink Then ; if it is a link
                                Local $tSyslink = DllStructCreate('wchar text[' & $tNMCUSTOMTEXT.nCount & ']', $tNMCUSTOMTEXT.lpString)
                                If Not MapExists($mLinks, $tSyslink.text) Then ; if the text not included in the map
                                    $mLinks[$tSyslink.text] = $iIndex ; assign the text to an index
                                    $iIndex += 1 ; increase index by one
                                EndIf
                                If $mLinks[$tSyslink.text] = _Syslink_GetFocus($g_hSyslink) Then ; if the link has the focus
                                    Local $tRect = DllStructCreate($tagRECT, $tNMCUSTOMTEXT.lpRect) ; create RECT for the text
                                    Local $hBrush = _WinAPI_CreateSolidBrush(0xEEEEEE) ; color of the focus frame (BGR format)
                                    _WinAPI_FrameRect($tNMCUSTOMTEXT.hDC, $tRect, $hBrush) ; draw frame around the text
                                    _WinAPI_DeleteObject($hBrush)
                                EndIf
                                Switch $mLinks[$tSyslink.text] ; set different colors depending of the index of the link (BGR format)
                                    Case 0
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x4444FF)
                                    Case 1
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x44FF00)
                                    Case 2
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0xFFEE22)
                                    Case Else
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x44FFFF)
                                EndSwitch
                            Else ; if no link, then it is the caption
                                _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, _WinAPI_SwitchColor($g_iTxtColor))
                            EndIf
                        EndIf
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>_WM_NOTIFY
    
    Func _Syslink_GetFocus(ByRef $hSyslink)
        If Not IsHWnd($hSyslink) Then Return SetError(1, 0, -1)
        Local $tLITEM = DllStructCreate($tagLITEM), $ret
        $tLITEM.mask = BitOR($LIF_ITEMINDEX, $LIF_STATE)
        $tLITEM.stateMask = BitOR($LIS_ENABLED, $LIS_FOCUSED)
        $tLITEM.iLink = -1
        Do
            $tLITEM.iLink += 1
            $ret = _SendMessage($hSyslink, $LM_GETITEM, 0, DllStructGetPtr($tLITEM))
            If $ret = 0 Then Return SetError(2, 0, -1)
        Until BitAND($tLITEM.state, $LIS_FOCUSED) = $LIS_FOCUSED
        Return $tLITEM.iLink
    EndFunc   ;==>_Syslink_GetFocus
    
    Func _Syslink_SetItem(ByRef $hSyslink, $iIndex, $iState = -1, $sUrl = '')
        If Not IsHWnd($hSyslink) Then Return SetError(1, 0, False)
        Local $tLITEM = DllStructCreate($tagLITEM), $ret
        $tLITEM.mask = BitOR($LIF_ITEMINDEX, ($iState > -1 ? $LIF_STATE : 0), ($sUrl <> '' ? $LIF_URL : 0))
        $tLITEM.iLink = $iIndex
        If $iState > -1 Then
            $tLITEM.state = $iState
            $tLITEM.stateMask = $iState
        EndIf
        If $sUrl <> '' Then $tLITEM.szURL = $sUrl
        $ret = _SendMessage($hSyslink, $LM_SETITEM, 0, DllStructGetPtr($tLITEM))
        Return $ret <> 0
    EndFunc   ;==>_Syslink_SetItem
    
    Func _WinAPI_Init_ICC_LINK_CLASS()
        Local Const $tagINITCOMMONCONTROLSEX = 'struct;dword dwSize;dword dwICC;endstruct;'
        Local Const $ICC_LINK_CLASS = 0x00008000
        Local $tINITCOMMONCONTROLSEX = DllStructCreate($tagINITCOMMONCONTROLSEX)
        $tINITCOMMONCONTROLSEX.dwSize = DllStructGetSize($tINITCOMMONCONTROLSEX)
        $tINITCOMMONCONTROLSEX.dwICC = $ICC_LINK_CLASS
        Local $aResult = DllCall('comctl32', 'bool', 'InitCommonControlsEx', 'ptr', DllStructGetPtr($tINITCOMMONCONTROLSEX))
        Return $aResult[0] == 1
    EndFunc   ;==>_WinAPI_Init_ICC_LINK_CLASS
    Alles anzeigen

    Screenshot:

    SysLink.png

    Dateien

    SysLink_GuiRegister.au3 10,33 kB – 218 Downloads
  • Beispiel für ein Syslink-Control

    • Oscar
    • 1. Februar 2023 um 17:47

    Ich habe mich mal noch etwas mehr damit beschäftigt und speziell ging es mir um die Möglichkeit die Farben der Links zu ändern, sodass man auch einen dunklen Hintergrund benutzen kann.

    Ich habe mal ein Beispielscript erstellt, bei dem statt der Callback-Routine nur GuiRegisterMsg verwendet wird (ist für Anfänger vielleicht einfacher zu verstehen):

    AutoIt
    #include <FontConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SendMessage.au3>
    #include <StructureConstants.au3>
    #include <WinAPIGdiDC.au3>
    #include <WinAPIGdiInternals.au3>
    #include <WinAPIHObj.au3>
    #include <WinAPIInternals.au3>
    #include <WinAPISysInternals.au3>
    #include <WindowsConstants.au3>
    
    ; This example works in 32bit and 64bit mode (n/y)
    #AutoIt3Wrapper_UseX64=y
    
    ; This function ensures that the common control DLL (Comctl32.dll) is loaded,
    ; and registers ICC_LINK_CLASS from the DLL.
    ; Minimum supported client:    Windows Vista
    If Not _WinAPI_Init_ICC_LINK_CLASS() Then Exit
    
    #Region *** Structs and constants for the syslink control ***
    
    ; The LITEM struct used to set and retrieve information about a link item.
    Global Const $tagLITEM = 'struct;uint mask;int iLink;uint state;uint stateMask;wchar szID[48];wchar szURL[2083];endstruct'
    
    ; The NMLINK struct contains notification information. Send this structure with the NM_CLICK or NM_RETURN messages.
    Global Const $tagNMLINK = 'struct;' & $tagNMHDR & ';' & $tagLITEM & ';endstruct'
    
    ; The NMCUSTOMTEXT struct contains information used with custom text notification.
    Global Const $tagNMCUSTOMTEXT = 'struct;' & $tagNMHDR & ';handle hDC;ptr lpString;int nCount;ptr lpRect;uint uFormat;bool fLink;endstruct'
    
    
    Global Const $NM_CUSTOMTEXT = $NM_FIRST - 24 ; Notifies a control's parent window about custom text operations. This notification code is sent in the form of a WM_NOTIFY message.
    Global Const $LM_HITTEST = $WM_USER + 0x300 ; Determines whether the user clicked the specified link.
    Global Const $LM_GETIDEALHEIGHT = $WM_USER + 0x301 ; Retrieves the preferred height of a link for the control's current width.
    Global Const $LM_GETIDEALSIZE = $LM_GETIDEALHEIGHT ; Retrieves the preferred height of a link for the control's current width.
    Global Const $LM_SETITEM = $WM_USER + 0x302 ; Sets the states and attributes of an item.
    Global Const $LM_GETITEM = $WM_USER + 0x303 ; Retrieves the states and attributes of an item.
    
    
    Global Const $LIF_ITEMINDEX = 0x00000001 ; Retrieve the numeric item index. Items are always accessed by index, therefore you must always set this flag and assign a value to iLink. To obtain the item ID you must set both LIF_ITEMINDEX and LIF_ITEMID.
    Global Const $LIF_STATE = 0x00000002 ; Use stateMask to get or set the state of the link.
    Global Const $LIF_ITEMID = 0x00000004 ; Specify the item by the ID value given in szID.
    Global Const $LIF_URL = 0x00000008 ; Set or get the URL for this item.
    
    
    Global Const $LIS_FOCUSED = 0x00000001 ; The link has the keyboard focus. Pressing ENTER sends an NM_CLICK notification.
    Global Const $LIS_ENABLED = 0x00000002 ; The link can respond to user input. This is the default unless the entire control was created with WS_DISABLED. In this case, all links are disabled.
    Global Const $LIS_VISITED = 0x00000004 ; The link has been visited by the user. Changing the URL to one that has not been visited causes this flag to be cleared.
    Global Const $LIS_HOTTRACK = 0x00000008 ; Indicates that the syslink control will highlight in a different color (COLOR_HIGHLIGHT) when the mouse hovers over the control.
    Global Const $LIS_DEFAULTCOLORS = 0x00000010 ; Enable custom text colors to be used.
    
    
    Global Const $LWS_TRANSPARENT = 0x0001 ; The background mix mode is transparent.
    Global Const $LWS_IGNORERETURN = 0x0002 ; When the link has keyboard focus and the user presses Enter, the keystroke is ignored by the control and passed to the host dialog box.
    Global Const $LWS_NOPREFIX = 0x0004 ; Windows Vista. If the text contains an ampersand, it is treated as a literal character rather than the prefix to a shortcut key.
    Global Const $LWS_USEVISUALSTYLE = 0x0008 ; Windows Vista. The link is displayed in the current visual style.
    Global Const $LWS_USECUSTOMTEXT = 0x0010 ; Windows Vista. An NM_CUSTOMTEXT notification is sent when the control is drawn, so that the application can supply text dynamically.
    Global Const $LWS_RIGHT = 0x0020 ; Windows Vista. The text is right-justified.
    
    #EndRegion *** Structs and constants for the syslink control ***
    
    
    #Region *** Example gui and syslink control ***
    
    Opt('GUIOnEventMode', 1) ; Enable OnEventMode
    
    Global Const $g_iBkColor = 0x303030, $g_iTxtColor = 0xE0E0E0
    
    Global $g_hMainGui = GUICreate('Syslink example 2023/02/01', 640, 220)
    GUISetBkColor($g_iBkColor, $g_hMainGui)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CloseMainGui')
    
    ; create the text including the links (as in HTML)
    Global $g_sText = 'This example was created by Oscar (autoit.de).' & @CRLF & @CRLF & _
            'AutoIt © 1999-2022 Jonathan Bennett' & @CRLF & _
            'Homepage: <a href="https://www.autoitscript.com/site/autoit/">www.autoitscript.com</a>' & @CRLF & _
            'Homepage deutsch: <a href="https://autoit.de/wcf/">autoit.de</a>' & @CRLF & _
            'Onlinehilfe deutsch: <a href="https://autoit.de/onlinehilfe/online/html/index.htm">autoit.de/onlinehilfe</a>'
    
    ; create syslink control
    Global $g_hSyslink = _WinAPI_CreateWindowEx(0, $WC_LINK, $g_sText, _
            BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $LWS_TRANSPARENT, $LWS_USECUSTOMTEXT), _
            20, 10, 620, 200, $g_hMainGui)
    
    ; create desired font
    Global $g_hFont = _WinAPI_CreateFont(32, 0, 0, 0, $FW_SEMIBOLD, True, False, False, $DEFAULT_CHARSET, _
            $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, 0, 'Times New Roman')
    
    ; and send the font to the syslink control
    _SendMessage($g_hSyslink, $WM_SETFONT, $g_hFont, True)
    
    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    GUISetState(@SW_SHOW, $g_hMainGui)
    
    WinWaitClose($g_hMainGui) ; wait until the main window is closed
    Exit
    
    #EndRegion *** Example gui and syslink control ***
    
    Func _CloseMainGui()
        _WinAPI_DeleteObject($g_hFont) ; delete font
        _WinAPI_DestroyWindow($g_hSyslink) ; destroy syslink control
        GUIDelete($g_hMainGui) ; close the main window (leads to exit)
    EndFunc   ;==>_CloseMainGui
    
    Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam
        Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        Switch $tNMHDR.hWndFrom ; which Control send the message?
            Case $g_hSyslink ; when syslink control
                Switch $tNMHDR.Code ; which code?
                    Case $NM_CLICK, $NM_RETURN ; mouseclick or <RETURN> on a link
                        Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
                        ShellExecute($tNMLINK.szURL)
                    Case $NM_CUSTOMTEXT ; only works if "$LWS_USECUSTOMTEXT" is present at the syslink style!
                        Local $tNMCUSTOMTEXT = DllStructCreate($tagNMCUSTOMTEXT, $lParam)
                        If $tNMCUSTOMTEXT.nCount > 0 Then ; if the text length is greater than 0
                            If $tNMCUSTOMTEXT.fLink Then ; if it is a link
                                Local $tSyslink = DllStructCreate('wchar text[' & $tNMCUSTOMTEXT.nCount & ']', $tNMCUSTOMTEXT.lpString)
                                Switch $tSyslink.text ; set different colors depending on the link (BGR format)
                                    Case 'www.autoitscript.com'
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x4444FF)
                                    Case 'autoit.de'
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x44FF00)
                                    Case 'autoit.de/onlinehilfe'
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0xFFEE22)
                                    Case Else
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x44FFFF)
                                EndSwitch
                            Else ; if no link, then it is the caption
                                _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, _WinAPI_SwitchColor($g_iTxtColor))
                            EndIf
                        EndIf
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>_WM_NOTIFY
    
    Func _WinAPI_Init_ICC_LINK_CLASS()
        Local Const $tagINITCOMMONCONTROLSEX = 'struct;dword dwSize;dword dwICC;endstruct;'
        Local Const $ICC_LINK_CLASS = 0x00008000
        Local $tINITCOMMONCONTROLSEX = DllStructCreate($tagINITCOMMONCONTROLSEX)
        $tINITCOMMONCONTROLSEX.dwSize = DllStructGetSize($tINITCOMMONCONTROLSEX)
        $tINITCOMMONCONTROLSEX.dwICC = $ICC_LINK_CLASS
        Local $aResult = DllCall('comctl32', 'bool', 'InitCommonControlsEx', 'ptr', DllStructGetPtr($tINITCOMMONCONTROLSEX))
        Return $aResult[0] == 1
    EndFunc   ;==>_WinAPI_Init_ICC_LINK_CLASS
    Alles anzeigen

    Screenshot:

    SysLink.png

    Dateien

    SysLink_GuiRegister.au3 8,06 kB – 221 Downloads
  • Problem mit $tagNMCUSTOMTEXT

    • Oscar
    • 28. Januar 2023 um 11:47

    Ach shit!

    Jetzt, wo ich das hier aufgeschrieben habe, sehe ich den Fehler: lpRect muss ein Pointer sein und nicht $tagRECT.

    Es muss also so aussehen:

    AutoIt
    Global Const $tagNMCUSTOMTEXT = 'struct;' & $tagNMHDR & ';handle hDC;ptr lpString;int nCount;ptr lpRect;uint uFormat;bool fLink;endstruct'

    Manchmal sieht man den Wald vor lauter Bäumen nicht.

  • Problem mit $tagNMCUSTOMTEXT

    • Oscar
    • 28. Januar 2023 um 11:37

    Ich versuche mich gerade an der farbigen Darstellung bei dem Syslink-Control.

    Dazu muss man das WC_LINK-Window mit $LWS_USECUSTOMTEXT aufrufen. Soweit funktioniert das auch. Es wird auch in der Window-Proc unter $WM_NOTIFY das $NM_CUSTOMTEXT aufgerufen.

    Aber irgendwie wird die Struktur falsch zurückgegeben.

    Laut MSDN soll die Struktur so aussehen:

    Code
    typedef struct tagNMCUSTOMTEXT {
      NMHDR   hdr;
      HDC     hDC;
      LPCWSTR lpString;
      int     nCount;
      LPRECT  lpRect;
      UINT    uFormat;
      BOOL    fLink;
    } NMCUSTOMTEXT, *LPNMCUSTOMTEXT;

    Ich habe daraus dieses hier für AutoIt gemacht:

    AutoIt
    Global Const $tagNMCUSTOMTEXT = 'struct;' & $tagNMHDR & ';handle hDC;ptr lpString;int nCount;' & $tagRECT & ';uint uFormat;bool fLink;endstruct'

    Das funktioniert auch, bis auf die letzten beiden Werte. Bei "uFormat" kommt immer "0" oder "1" raus, was eigentlich bei "fLink" stehen sollte und "fLink" bekommt Zufallswerte (bei jedem Start etwas anderes, was wohl darauf hindeutet, dass über die Struktur hinaus gelesen wird). Habe ich bei der Struktur-Definition einen Fehler gemacht? Oder woran kann das liegen?

    Hier mal mein Script (edit: korrigiertes Script)

    AutoIt
    #include <FontConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SendMessage.au3>
    #include <StructureConstants.au3>
    #include <WinAPIGdiDC.au3>
    #include <WinAPIGdiInternals.au3>
    #include <WinAPIHObj.au3>
    #include <WinAPIInternals.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPISysInternals.au3>
    #include <WindowsConstants.au3>
    #include <WinAPISysWin.au3>
    
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=y
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    ; This function ensures that the common control DLL (Comctl32.dll) is loaded,
    ; and registers ICC_LINK_CLASS from the DLL.
    ; Minimum supported client:    Windows Vista
    If Not _WinAPI_Init_ICC_LINK_CLASS() Then Exit
    
    #Region *** Structs and Constants for the Syslink-Control ***
    
    ; The LITEM struct used to set and retrieve information about a link item.
    Global Const $tagLITEM = 'struct;uint mask;int iLink;uint state;uint stateMask;wchar szID[48];wchar szURL[2083];endstruct'
    
    ; The NMLINK struct contains notification information. Send this structure with the NM_CLICK or NM_RETURN messages.
    Global Const $tagNMLINK = 'struct;' & $tagNMHDR & ';' & $tagLITEM & ';endstruct'
    
    ; The NMCUSTOMTEXT struct contains information used with custom text notification.
    Global Const $tagNMCUSTOMTEXT = 'struct;' & $tagNMHDR & ';handle hDC;ptr lpString;int nCount;ptr lpRect;uint uFormat;bool fLink;endstruct'
    
    
    Global Const $NM_CUSTOMTEXT = $NM_FIRST - 24 ; Notifies a control's parent window about custom text operations. This notification code is sent in the form of a WM_NOTIFY message.
    Global Const $LM_HITTEST = $WM_USER + 0x300 ; Determines whether the user clicked the specified link.
    Global Const $LM_GETIDEALHEIGHT = $WM_USER + 0x301 ; Retrieves the preferred height of a link for the control's current width.
    Global Const $LM_GETIDEALSIZE = $LM_GETIDEALHEIGHT ; Retrieves the preferred height of a link for the control's current width.
    Global Const $LM_SETITEM = $WM_USER + 0x302 ; Sets the states and attributes of an item.
    Global Const $LM_GETITEM = $WM_USER + 0x303 ; Retrieves the states and attributes of an item.
    
    
    Global Const $LIF_ITEMINDEX = 0x00000001 ; Retrieve the numeric item index. Items are always accessed by index, therefore you must always set this flag and assign a value to iLink. To obtain the item ID you must set both LIF_ITEMINDEX and LIF_ITEMID.
    Global Const $LIF_STATE = 0x00000002 ; Use stateMask to get or set the state of the link.
    Global Const $LIF_ITEMID = 0x00000004 ; Specify the item by the ID value given in szID.
    Global Const $LIF_URL = 0x00000008 ; Set or get the URL for this item.
    
    
    Global Const $LIS_FOCUSED = 0x00000001 ; The link has the keyboard focus. Pressing ENTER sends an NM_CLICK notification.
    Global Const $LIS_ENABLED = 0x00000002 ; The link can respond to user input. This is the default unless the entire control was created with WS_DISABLED. In this case, all links are disabled.
    Global Const $LIS_VISITED = 0x00000004 ; The link has been visited by the user. Changing the URL to one that has not been visited causes this flag to be cleared.
    Global Const $LIS_HOTTRACK = 0x00000008 ; Indicates that the syslink control will highlight in a different color (COLOR_HIGHLIGHT) when the mouse hovers over the control.
    Global Const $LIS_DEFAULTCOLORS = 0x00000010 ; Enable custom text colors to be used.
    
    
    Global Const $LWS_TRANSPARENT = 0x0001 ; The background mix mode is transparent.
    Global Const $LWS_IGNORERETURN = 0x0002 ; When the link has keyboard focus and the user presses Enter, the keystroke is ignored by the control and passed to the host dialog box.
    Global Const $LWS_NOPREFIX = 0x0004 ; Windows Vista. If the text contains an ampersand, it is treated as a literal character rather than the prefix to a shortcut key.
    Global Const $LWS_USEVISUALSTYLE = 0x0008 ; Windows Vista. The link is displayed in the current visual style.
    Global Const $LWS_USECUSTOMTEXT = 0x0010 ; Windows Vista. An NM_CUSTOMTEXT notification is sent when the control is drawn, so that the application can supply text dynamically.
    Global Const $LWS_RIGHT = 0x0020 ; Windows Vista. The text is right-justified.
    
    #EndRegion *** Structs and Constants for the Syslink-Control ***
    
    
    Opt('GUIOnEventMode', 1)
    
    Global Const $g_iBkColor = 0xFFFFFF, $g_iTxtColor = 0404040
    
    Global $g_hMainGui = GUICreate('Syslink example', 640, 300)
    GUISetBkColor($g_iBkColor, $g_hMainGui)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CloseMainGui')
    
    Global $g_sText = 'AutoIt' & @CRLF & _
            '© 1999-2022 Jonathan Bennett' & @CRLF & _
            'Homepage: <a href="https://www.autoitscript.com/site/autoit/">www.autoitscript.com</a>' & @CRLF & _
            'Homepage deutsch: <a href="https://autoit.de/wcf/">autoit.de</a>' & @CRLF & _
            'Onlinehilfe deutsch: <a href="https://autoit.de/onlinehilfe/online/html/index.htm">autoit.de/onlinehilfe</a>'
    
    Global $g_hSyslink = _WinAPI_CreateWindowEx(0, $WC_LINK, $g_sText, _
            BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $LWS_TRANSPARENT, $LWS_USECUSTOMTEXT), _
            10, 10, 620, 200, $g_hMainGui)
    
    Global $g_hFont = _WinAPI_CreateFont(32, 0, 0, 0, 400, True, False, False, $DEFAULT_CHARSET, _
            $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, 0, 'Verdana')
    _SendMessage($g_hSyslink, $WM_SETFONT, $g_hFont, True)
    
    Global $g_hSyslinkProc = DllCallbackRegister('_SyslinkProc', 'lresult', _
            'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
    Global $g_pSyslinkProc = DllCallbackGetPtr($g_hSyslinkProc)
    _WinAPI_SetWindowSubclass($g_hMainGui, $g_pSyslinkProc, 1000, 0)
    
    Global $g_idClose = GUICtrlCreateButton('Close', 240, 230, 120, 30)
    GUICtrlSetFont(-1, 14, 400, 0, 'Verdana')
    GUICtrlSetOnEvent(-1, '_CloseMainGui')
    GUICtrlSetState(-1, $GUI_FOCUS)
    
    GUISetState(@SW_SHOW, $g_hMainGui)
    
    WinWaitClose($g_hMainGui)
    DllCallbackFree($g_hSyslinkProc)
    Exit
    
    Func _CloseMainGui()
        _WinAPI_RemoveWindowSubclass($g_hMainGui, $g_pSyslinkProc, 1000)
        _WinAPI_DeleteObject($g_hFont)
        _WinAPI_DestroyWindow($g_hSyslink)
        GUIDelete($g_hMainGui)
    EndFunc   ;==>_CloseMainGui
    
    Func _SyslinkProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
        #forceref $iID, $pData
        Switch $iMsg
            Case $WM_CTLCOLORSTATIC ; Farben beim Syslink festlegen
                ; $lParam = Static-hWnd, $wParam = Static-hDC
                ; Textfarbe fuer die Schrift (im BGR-Format)
                _WinAPI_SetTextColor($wParam, _WinAPI_SwitchColor($g_iTxtColor))
                Return 0
            Case $WM_NOTIFY
                Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
                Switch $tNMHDR.Code
                    Case $NM_CLICK, $NM_RETURN ; Mausklick oder <RETURN> auf einen Link
                        Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
                        ShellExecute($tNMLINK.szURL)
                    Case $NM_CUSTOMTEXT ; funktioniert nur, wenn beim Syslink-Style "$LWS_USECUSTOMTEXT" vorhanden ist!
                        Local $tNMCUSTOMTEXT = DllStructCreate($tagNMCUSTOMTEXT, $lParam)
                        If $tNMCUSTOMTEXT.nCount > 0 Then ; nur wenn die Textlaenge groesser 0 ist
                            If $tNMCUSTOMTEXT.fLink Then ; und es sich um einen Link handelt
                                Local $tSyslink = DllStructCreate('wchar text[' & $tNMCUSTOMTEXT.nCount & ']', $tNMCUSTOMTEXT.lpString)
                                Switch $tSyslink.text ; je nach Link unterschiedliche Farben setzen (im BGR-Format)
                                    Case 'www.autoitscript.com'
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x4444BB)
                                    Case 'autoit.de'
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x44BB00)
                                    Case 'autoit.de/onlinehilfe'
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0xBB4444)
                                    Case Else
                                        _WinAPI_SetTextColor($tNMCUSTOMTEXT.hDC, 0x44BBBB)
                                EndSwitch
                            EndIf
                        EndIf
                EndSwitch
        EndSwitch
        Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
    EndFunc   ;==>_SyslinkProc
    
    Func _Syslink_SetItem($hSyslink, $iIndex, $iState = -1, $sUrl = '')
        If Not IsHWnd($hSyslink) Then Return SetError(1, 0, False)
        Local $tLITEM = DllStructCreate($tagLITEM), $ret
        $tLITEM.mask = BitOR($LIF_ITEMINDEX, ($iState > -1 ? $LIF_STATE : 0), ($sUrl <> '' ? $LIF_URL : 0))
        $tLITEM.iLink = $iIndex
        If $iState > -1 Then
            $tLITEM.state = $iState
            $tLITEM.stateMask = $iState
        EndIf
        If $sUrl <> '' Then $tLITEM.szURL = $sUrl
        $ret = _SendMessage($hSyslink, $LM_SETITEM, 0, DllStructGetPtr($tLITEM))
        Return $ret <> 0
    EndFunc   ;==>_Syslink_SetItem
    
    Func _WinAPI_Init_ICC_LINK_CLASS()
        Local Const $tagINITCOMMONCONTROLSEX = 'struct;dword dwSize;dword dwICC;endstruct;'
        Local Const $ICC_LINK_CLASS = 0x00008000
        Local $tINITCOMMONCONTROLSEX = DllStructCreate($tagINITCOMMONCONTROLSEX)
        $tINITCOMMONCONTROLSEX.dwSize = DllStructGetSize($tINITCOMMONCONTROLSEX)
        $tINITCOMMONCONTROLSEX.dwICC = $ICC_LINK_CLASS
        Local $aResult = DllCall('comctl32', 'bool', 'InitCommonControlsEx', 'ptr', DllStructGetPtr($tINITCOMMONCONTROLSEX))
        Return $aResult[0] == 1
    EndFunc   ;==>_WinAPI_Init_ICC_LINK_CLASS
    Alles anzeigen
  • Noch eine MouseHover-UDF

    • Oscar
    • 22. Januar 2023 um 16:22

    Neue Version in Post#1, um einen Fehler zu beheben.

  • Rechnungsproblem

    • Oscar
    • 21. Januar 2023 um 09:00
    Zitat von Lanealine

    Ist es möglich, das so zu bauen, dass $aNumber beliebig groß sein kann ?

    Dafür gibt es Schleifen:

    AutoIt
    Global $Loesung = 0, $aNumber[] = [3, 7, 6, 8, 5]
    For $i = 0 To UBound($aNumber) - 1
        $Loesung += $aNumber[$i]
    Next
    $Loesung *= $aNumber[0]
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Loesung = ' & $Loesung & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  • Bug oder nicht Bug oder wenigstens ungereimt?

    • Oscar
    • 17. Januar 2023 um 08:48
    Zitat von Peter S. Taler

    Es gibt ja mindestens 2 Lösungen fürs Problem

    Meine Lösung sieht meistens so aus (für mich endet ein Verzeichnis immer mit einem Backslash):

    AutoIt
    Global $sPath = @ScriptDir
    If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sPath = ' & $sPath & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
  • von Datum bis Datum

    • Oscar
    • 14. Januar 2023 um 15:14

    Dafür ist doch _DateDiff perfekt geeignet:

    AutoIt
    #include <Date.au3>
    
    Global $sEndDT = '2023/01/15 00:00:00', $iTimeLeft
    Do
        $iTimeLeft = _DateDiff('s', _NowCalc(), $sEndDT)
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iTimeLeft = ' & $iTimeLeft & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
        Sleep(1000)
    Until $iTimeLeft < 1
    MsgBox(0, 'Ende', 'Das Datum ist erreicht!')

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™