Beiträge von UEZ
-
-
Du musst die Grafik neuzeichnen, wenn das Fenster "gelöscht" wurde.
Suche nach GDIPlus und WM_PAINT.
-
-
Euch beiden (BugFix & Der_Doc) alles Gute und feiert schön.

-
Herzlichen Glückwunsch zum Geburtstag und alles Gute für die Zukunft.
-
-
So geht's:
Module1 in Excel erstellen:
Code
Alles anzeigenOption Explicit Dim ItmEvt As New Class1 Public Sub Mail() Dim outApp As Object Dim outMail As Object Set outApp = CreateObject("Outlook.Application") Set outMail = outApp.CreateItem(0) Set ItmEvt.Itm = outMail On Error Resume Next With outMail .To = "" .CC = "" .BCC = "" .Subject = "VBA Test" .BodyFormat = olFormatHTML .HTMLBody = "Blah Blah Blah" .Display End With On Error GoTo 0 Set outMail = Nothing Set outApp = Nothing End SubClass1 erstellen:
Code
Alles anzeigenOption Explicit Public WithEvents itm As Outlook.MailItem Private Sub itm_Close(Cancel As Boolean) Dim blnSent As Boolean On Error Resume Next blnSent = itm.Sent If Err.Number = 0 Then MsgBox "Email not sent" Else MsgBox "Email sent" End If End SubWichtig: Tools->References muss "Microsoft Outlook 15.0 Object Library" selektiert sein (oder die entsprechende Version)!
-
-
Es geht darum, wenn der VBA Code gestartet wird, wird ein Outlook Fenster gestartet (neue Mail). Ich will nun prüfen, ob die Mail nun versandt wurde oder nicht. D.h. wurde der "Senden" Knopf gedrückt oder nicht. Dem entsprechend soll dann eine Zeile in Excel gefärbt oder nicht gefärbt werden.
Das geht mit Event, aber ich bekomme das nicht aus Excel heraus nicht hin. Die Beispiele aus dem Internet funzen irgendwie nicht richtig. Um das Problem darzustellen muss das Office Paket installiert sein.
-
-
Irgendwie kriege ich es nicht gebacken aus Excel Outlook Events abzufragen.
Beispiel in Excel VBA:
Code
Alles anzeigenPublic Sub Mail() Dim outApp As Object Dim outMail As Object Set outApp = CreateObject("Outlook.Application") Set outMail = outApp.CreateItem(0) On Error Resume Next With outMail .To = "" .CC = "" .BCC = "" .Subject = "VBA Test" .BodyFormat = olFormatHTML .HTMLBody = "Blah Blah Blah" .Display True End With On Error GoTo 0 Set outMail = Nothing Set outApp = Nothing End SubWie kann ich jetzt abfragen, ob der "Send" Button gedrückt wurde?
Irgendwie finde ich nichts, was in Excel läuft.
Hat jemand eine Idee?
Ich benutze Office 2013.
Danke.
-
-
Mit Kantenglättung sieht es besser aus und ein Mod für eine Animation würde die Times Table besser zur Geltung bringen:
Externer Inhalt www.youtube.comInhalte von externen Seiten werden ohne deine Zustimmung nicht automatisch geladen und angezeigt.Durch die Aktivierung der externen Inhalte erklärst du dich damit einverstanden, dass personenbezogene Daten an Drittplattformen übermittelt werden. Mehr Informationen dazu haben wir in unserer Datenschutzerklärung zur Verfügung gestellt. -
Wenn mehrer Apps den Flag Topmost haben, wer gewinnt?
Es gewinnt der, der auf der Z-Order oben steht, welches sich jederzeit ändern kann.
-
Soweit sieht es ganz gut aus, nur funktioniert nicht der Regler, wenn die Maustaste gedrückt ist und die Maus nach l/r bewegt wird (habe ich hinzugefügt).
Scheint am Subclassing zu liegen, dass die Bitmap im Control solange nicht aktualisiert wird, bis die Maustaste losgelassen wird.
Anstelle der If ... AND ... AND .. Then kann man auch dies verwenden:
-
Zufällig ist auch parallel hier die gleiche Frage gestellt worden: https://www.autoitscript.com/forum/topic/178354-problem-with-flashing-label/?do=findComment&comment=1279824
-
Tweaky: oder zeichne doch einfach den Text auf das Bild und sende es anschließend in den Button.
So was in er Art:
AutoIt
Alles anzeigen;needs GDIPlus.au3 at least from AutoIt version 3.3.9.23 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hGUI = GUICreate("GDI+ Test", 200, 100) GUISetBkColor(0x505050) Global Const $iPicBtn = GUICtrlCreatePic("", 60, 38, 80, 24) Global $aButtons = _GDIPlus_BitmapCreateButtonAndText("install", 80, 24) _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) GUISetState() Global $aMouseInfo, $bShow = False, $bHide = False Do If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $iPicBtn _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) $bShow = True $bHide = False Case Else _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) $bHide = True $bShow = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($aButtons[0]) _WinAPI_DeleteObject($aButtons[1]) _GDIPlus_Shutdown() Exit Case $iPicBtn MsgBox(0, "Information", "Button pressed") EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateButtonAndText ; Description ...: Draws via GDI+ a Windows 8 style button with text ; Syntax ........: _GDIPlus_BitmapCreateButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2014-05-08 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xFFFFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, 1), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) ;~ Local Const $aInfo = _GDIPlus_PathGetWorldBounds($hPath_Dummy) ;~ $tLayout.Y = ($iHeight - $aInfo[3]) / 2 - Ceiling($aInfo[1]) ;center string on Y axis ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsClear($aGfxCtxt[0], $iBgColor) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawRect($aGfxCtxt[1], $iFrameSize / 2, $iFrameSize / 2, $iWidth - $iFrameSize, $iHeight - $iFrameSize, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc -
Probiere es mal hiermit:
C
Alles anzeigen#Region ;************ Includes ************ #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiButton.au3> #include <GDIPlus.au3> #include <WinAPIShellEx.au3> #EndRegion ;************ Includes ************ Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled $sIcon = @ScriptDir & "\icon.ico" _GDIPlus_Startup() $hGui = GUICreate("Test", 200, 400) GUICtrlCreateIcon($sIcon, 0, 10, 10, 128, 128) $hIcon = _WinAPI_ShellExtractIcon($sIcon, 0, 128, 128) $hBmp_Icon = _GDIPlus_BitmapCreateFromHICON32($hIcon) $hHBmp_Icon = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp_Icon) $idButton = GUICtrlCreateButton("", 10, 200, 150, 150, $BS_BITMAP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($idButton), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_Icon)) GUISetOnEvent($GUI_EVENT_CLOSE, "_beenden") GUISetState() While 1 Sleep(10) WEnd Func _beenden() _WinAPI_DestroyIcon($hIcon) _GDIPlus_BitmapDispose($hBmp_Icon) _WinAPI_DeleteObject($hHBmp_Icon) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc ;==>_beenden -
Hintergrund ist, dass eine Webandwendung eine 2D Tabelle mit vielen Informationen erstellt, die nach Excel exportiert werden kann.
Diese Exceltabelle will ich benutzen, um simple Rack Layouts zu erstellen. Dabei werden nur bestimmte Spalten extrahiert, um den Baum zu erstellen, quasi die Koordinate, wo das Rack steht.
Es soll nun die Koordinate per Baum selektiert werden und auf der rechten Seite wird dann "on the fly" das Rack Layout dargestellt.
Danke für die Links.
-
-
Hi,
mit TreeViews habe ich kaum Erfahrung und wollte ein sortiertes 2D Array in ein Treeview abbilden.
Das Array sieht so aus und ist auch als Datei verfügbar (Path.txt

Array.pngSpalte 0 bildet die Wurzel ab und hier gibt es nur "EMEA". Spalte 9 bildet das letzte Element ab. Spalte 7 ist zu ignorieren und dient nur für die Sortierung des Arrays.
Das Array wird aus einer Excel Tabelle erstellt.Hier ein Beispiel Code:
AutoIt
Alles anzeigen#include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hItem, $iTree, $x, $y, $iParent Local $iStyle = BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) GUICreate("TreeView Add First", 600, 800) $iTree = GUICtrlCreateTreeView(2, 2, 596, 768, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) Local $aData = StringSplit2D(FileRead(@ScriptDir & "\Path.txt")) _GUICtrlTreeView_BeginUpdate($iTree) Local $aTmp[UBound($aData, 2)] For $y = 1 To UBound($aData) - 1 For $x = 0 To UBound($aData, 2) - 1 If $x = 7 Then ContinueLoop Next Next _GUICtrlTreeView_EndUpdate($iTree) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example ; #FUNCTION# ======================================================================================================================================== ; Name .................: StringSplit2D() ; Description ..........: Splits a string into columns instead of rows as it is done by SplitString(), like a csv file to a 2d array ;-) ; Syntax ...............: StringSplit2D($sString[, $sDelimiter = ";"[, $bStripWS = True[, $sQuotationMark = '"'[, $sDummy = "¦"[, $iWidthLen = 256]]]]]) ; Parameters ...........: $sString - A string value. ; $sDelimiter - [optional] A string value. Default is ";". ; $bStripWS - [optional] A binary value. Default is True. ; $sQuotationMark - [optional] A string value. Default is '"'. ; $sDummy - [optional] A string value. Default is "¦". ; $iWidthLen - [optional] An integer value. Default is 256. ; Return values .......: Success - 2d array ; Error 1 - $sStringis not set ; Error 2 - $delimter is not set ; Error 3 - error splitting string ; Error 4 - array width exceeded ; ; Version .............: v0.97 build 2015-03-03 beta ; Author ..............: UEZ ; Modified ............: ; Comment .............: former StringSplitW ; Remarks .............: RegEx take from http://stackoverflow.com/questions/4476812/regular-expressions-how-to-replace-a-character-within-quotes ; Related .............: StringSplit, StringReplace, StringRegExpReplace, StringLen, StringStripCR ; =================================================================================================================================================== Func StringSplit2D($sString, $sDelimiter = ";", $bStripWS = False, $sQuotationMark = '"', $sDummy = "¦", $iWidthLen = 256) If $sString = "" Then Return SetError(1, 0, 0) If $sDelimiter = "" Then Return SetError(2, 0, 0) Local $aSplit = StringSplit(StringStripCR($sString), @LF) If @error Then Return SetError(3, 0, 0) Local $chk, $iWidth, $i, $j, $k, $iLen, $iMax = 1, $iMaxWidth, $iSum = 0 Local $aPos[1], $l = 0 Local $aVertical[$aSplit[0]][$iWidthLen], $iDelimiterLen = StringLen($sDelimiter) - 1, $sLine For $k = 1 To $aSplit[0] $iLen = StringLen($aSplit[$k]) If $iLen > 1 Then Switch $bStripWS Case True $sLine = StringRegExpReplace($aSplit[$k], '(?m)\' & $sDelimiter & '(?=[^' & $sQuotationMark & ']*' & $sQuotationMark & '(?:[^' & $sQuotationMark & '\r\n]*' & $sQuotationMark & '[^' & $sQuotationMark & ']*' & $sQuotationMark & ')*[^' & $sQuotationMark & '\r\n]*$)', $sDummy) Case Else ; ,(?=[^"]*"(?:[^"\r\n]*"[^"]*")*[^"\r\n]*$) $sLine = StringRegExpReplace(StringStripWS($aSplit[$k], 4), '(?m)\' & $sDelimiter & '(?=[^' & $sQuotationMark & ']*' & $sQuotationMark & '(?:[^' & $sQuotationMark & '\r\n]*' & $sQuotationMark & '[^' & $sQuotationMark & ']*' & $sQuotationMark & ')*[^' & $sQuotationMark & '\r\n]*$)', $sDummy) EndSwitch $chk = StringReplace($sLine, $sDelimiter, $sDelimiter) $iWidth = @extended $iSum += $iWidth If $iWidth > $iWidthLen Then Return SetError(4, 0, 0) If $iWidth >= $iMax Then $iMax = $iWidth + 1 Switch $iWidth Case 0 $aVertical[$l][0] = $sLine Case Else Dim $aPos[$iWidth * 2 + 2] $j = 1 $aPos[0] = 1 For $i = 0 To $iWidth - 1 $aPos[$j] = StringInStr($sLine, $sDelimiter, 0, $i + 1) - 1 $aPos[$j + 1] = $aPos[$j] + 2 + $iDelimiterLen $j += 2 Next $aPos[UBound($aPos) - 1] = StringLen($sLine) $j = 0 For $i = 0 To UBound($aPos) - 1 Step 2 $aVertical[$l][$j] = StringReplace(StringMid(StringReplace($sLine, $sDummy, $sDelimiter), $aPos[$i], $aPos[$i + 1] - $aPos[$i] + 1), '""', "") ;~ ConsoleWrite($aVertical[$l][$j] & @CRLF) $j += 1 Next EndSwitch $l += 1 EndIf Next ReDim $aVertical[$l][$iMax] Return $aVertical EndFuncHat jemand eine Idee, wie ich effizient die Tabelle als Treeview abbilden kann?
So etwa soll es aussehen:
+EMEA
_____+DE
________+Frankfurt
_________________+FFM.A
_______________________+00
__________________________+Carrier-4-D
_____________________________________+A-Carrier-4D
_________________________________________________+AC
____________________________________________________+12 (letzes Element)
...
_________________+FFM.B
_______________________+01
...Danke!
-
-
Ist im Prinzip das Gleiche über 2 verschiedene Wege - Callback bzw. Windows Message.
Adhog würde ich sagen, dass beide Techniken gleich gut sind. Ich persönlich arbeite mehr mit WM.