Leaderboard
Popular Content
Showing content with the highest reputation on 10/20/2016 in all areas
-
In the forums you can find several questions about how to edit the text in a ListView cell with a standard control eg. an Edit control or a ComboBox. The zip below contains three examples with an Edit control, a ComboBox and a DateTimePicker. How? A description from MicroSoft of how to edit a ListView cell with a ComboBox can be found here. When you click a cell the position and size is calculated, and the ComboBox is created on top of the cell. The text is shown in the Edit box. You can edit the text or select a value in the Listbox. Press Enter to save the text in the ListView cell and close the ComboBox. The ComboBox exists only while the text is edited. Code issues Especially because the control to edit the ListView cell is created on top of the ListView and is not part of the ListView, there are some issues you should be aware of. To get everything to look as good as possible most actions should be carried out when a mouse button is pressed and not when it's released. You should also be aware that the new code you add, does not conflict with existing functionality for example multiple selections. The examples consists of small but fairly many pieces of code to respond to events and messages. Keyboard support To edit a text value you are more or less forced to use the keyboard to type in the text. It would be nice if you could also select the current cell in the ListView with the keyboard. Cell selection with the keyboard is not too hard to implement with custom draw code. The current cell is drawn with a specific background color. It looks like this. You can select the current cell with the arrow keys. Open the control There must be a way to initiate the creation of the control. This is typically done with a single or double click in the ListView. Or with Enter or Space key in the examples with keyboard support. Default in the examples is double click and Enter key. You can change this in global variables in top of the scripts. A WM_NOTIFY message handler created with GUIRegisterMsg is used to watch for single and double click in the ListView. This message handler is also used to handle custom draw messages for keyboard support. Because the control is created on top of the ListView cell, it's very important that the ListView is set as the parent window. This ensures that mouse clicks and key presses are captured by the control and not by the ListView. Events in the control In a ComboBox and a DateTimePicker an additional control (Listbox and MonthCal, respectively) is opened if you click the Dropdown arrow (or press <Alt+Down arrow> on the keyboard). Click the Dropdown arrow again to close the control (or press <Alt+Up arrow> on the keyboard). The interesting messages (DROPDOWN, SELECTION, CLOSEUP) from such an additional control are usually contained in WM_COMMAND or WM_NOTIFY messages which are sent to the parent window. The parent window is the ListView. To catch the messages the ListView must be subclassed. Messages from the Edit control, the Edit box of the ComboBox, or the client area of the DateTimePicker are catched by subclassing the controls (Edit control, Edit box and DateTimePicker) directly. The interesting information here is dialog codes to accept (Enter) or cancel (Esc) the value and close the control. Dialog codes are sent as $WM_GETDLGCODE messages. In all examples the value in the control can also be accepted and saved with a double click. Close the control A mouse click in the ListView outside the control should close the control and cancel editing of the current cell. Because the control is not part of the ListView in particular mouse clicks on the Scrollbars should close the control immediately. The control will not be repainted properly on scrolling. Mouse clicks in the ListView and on Scrollbars can be identified by WM_LBUTTONDOWN and WM_NCLBUTTONDOWN messages. The area which is filled by Scrollbars in a ListView is non-client area. Mouse clicks in non-client area generates WM_NCLBUTTONDOWN messages. To catch the messages you have to subclass the ListView. A mouse click in the GUI outside the ListView and in non-client GUI area (eg. the Titlebar) should also close the control. Mouse clicks in GUI are catched through GUI_EVENT_PRIMARYDOWN messages. Mouse clicks in non-client GUI area are catched through WM_NCLBUTTONDOWN messages by subclassing the GUI. Finish the code A great part of the code is running in message handlers created with GUIRegisterMsg or created by subclassing a window. Lengthy code to open or close the control should not be executed in these message handlers. Instead of a message is sent to the AutoIt main loop where the control is opened or closed. Some of the message handlers are only needed while the control is open. They are created and deleted as part of the control open and close code. In the context of the updates May 26 the $LVS_EX_HEADERDRAGDROP extended style (rearranging columns by dragging Header items with the mouse) is added to all ListViews. See post 20 and 21. A few lines of code are added to better support usage of the keyboard. See image above. The code provides for horizontal scrolling of the ListView to make sure that a subitem (or column) is fully visible when it's selected with left or right arrow. Among other things, the code takes into account rearranging and resizing of columns as well as resizing of the GUI and ListView. A new example EditControlKeyboardTenCols.au3 demonstrates the features. See post 22. A few lines of code is added to handle multiple selections. Multiple selections is enabled in all examples. Pressing the Tab key in the control closes the control. The image shows a DateTimePicker control. Zip file The zip contains three examples with an Edit control, a ComboBox and a DateTimePicker. For each control there are two scripts with and without keyboard support. In the script with keyboard support you can select the current cell in the ListView with the arrow keys and open the control with the Enter (default) or the Space key. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewEditingCells.7z1 point
-
Active Directory UDF
ILoveCoding reacted to water for a topic
Will check after my vacation (appr. 1 week)1 point -
There is definitely a problem. I'll look at it.1 point
-
Can you use WMI ? A long time ago I wrote a remote event viewer in AutoIt. The meat of which was: Func FireToServer() $Instancesvar = IniReadSection(@scriptdir &"\evv.ini", "Instances") For $i = 1 To $Instancesvar[0][0] $ServerVar=IniReadSection (@scriptdir &"\evv.ini", $Instancesvar[$i][1]) For $j = 1 To $servervar[0][0] ;Call("Test",$Instancesvar[$i][1],$servervar[$j][1]) Call("EventViewRead",$Instancesvar[$i][1],$servervar[$j][1]) Call("ProgressBar",$Instancesvar[$i][1],$servervar[$j][1]) Next Next EndFunc ;;Debug Func Test($InstanceVar,$ServerVar) msgbox(0,"","Sent: " &$InstanceVar & "-" & $ServerVar) EndFunc ;;Debug Func eventviewread($Instancevar,$ServerVar) $TimesCalled=$TimesCalled+1 $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND SourceName = 'MyServiceName' AND EventType=1 AND timewritten >='" & $EVDate & "'" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $Servervar & "\root\cimv2") If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery ($Query_Clause) If IsObj($colItems) Then For $objEvent In $colItems $Output=$Output & $InstanceVar & "," & $ServerVar & "," $Output=$Output & StringRight(Stringleft($objEvent.TimeWritten,8),2) & "/" & Stringmid(StringLeft($objEvent.TimeWritten,8),5,2) & "/" & Stringleft(Stringleft($objEvent.TimeWritten,8),4) & "," $Output=$Output & StringRight(StringLeft($ObjEvent.TimeWritten,10),2) & ":" & StringRight(StringLeft($ObjEvent.TimeWritten,12),2) & ":" & StringRight(StringLeft($objEvent.TimeWritten,14),2) & "," & $objEvent.Message #cs $Output &= "Category: " & $objEvent.Category & @CRLF $Output &= "Computer Name: " & $objEvent.ComputerName & @CRLF $Output &= "Event Code: " & $objEvent.EventCode & @CRLF $Output &= "Message: " & $objEvent.Message & @CRLF $Output &= "Record Number: " & $objEvent.RecordNumber & @CRLF $Output &= "Source Name: " & $objEvent.SourceName & @CRLF $Output &= "Time Written: " & $objEvent.TimeWritten & @CRLF $Output &= "Event Type: " & $objEvent.Type & @CRLF $Output &= "User: " & $objEvent.User & @CRLF If MsgBox(64 + 4, "Entry Found:", $Output & @CRLF & @CRLF & "Continue?") = 7 Then Exit #ce Next Else $Output="$colItems is not an object." EndIf Else $Output="$objWMIService is not an object." EndIf ;call("WriteCSV",$Output) if $TimesCalled=$TotalCalls Then call("WriteCSV",$Output) EndIf EndFunc and the ACTUAL meat being $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND SourceName = 'MyServiceName' AND EventType=1 AND timewritten >='" & $EVDate & "'" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $Servervar & "\root\cimv2") If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery ($Query_Clause) Take a look here: https://msdn.microsoft.com/en-us/library/aa389290(v=vs.85).aspx1 point
-
I think you might be misunderstanding something as well. Initially you were using the "@systemDir" macro as the value for the system directory. This macro will be set to equal either (on a 64 bit machine) "C:\Windows\Syswow64" if compiled as a 32-bit application, or "C:\Windows\system32" if compiled as a 64-bit application. There is no need for you to specifically define the paths like you did in your script, as the "@SystemDir" macro does this for you depending on how you compile the script. Does that make since?1 point
-
One way would be to launch them all from the same master program, and get a PID for each off the Run command. And there are various other ways, involving writing to a checking file or Registry entry etc.1 point
-
I don't think it's a good choice for anything. Figure out why you have a memory leak before artificially trying to hide the leak.1 point
-
ASM (handcoded) is (a little bit) faster, but what you meant are the "native" FPU-Code FSIN(), FCOS() and FSINCOS(), where are way slower than an (as mentioned and showed by trancexx) approximation. Calling the/an API-function is once more slower... One of the reasons, why trancexx used __forceinline which causes the compiler to inline this function into code. That means, no jumps/calls into a function! Makes the code some bytes bigger, but faster I deinstalled VS yesterday....i am waiting for a compiler which is able to use "real" SIMD when switch on the SSE-Flag. I examined the EXE with IDApro. Yes, the compiler produces short and (in most cases) fast(?!) code using (half-hearted) processor-features which were introduced about 20 years ago... The only code i saw from a compiler using SIMD (as intended) was from the newest INTEL C++/FORTRAN-Compiler XE (v17.0). And to get this performance it is necessary to program in a "vectorizing" style ( and/or excessive use of _intrinsics_(), which force the compiler to fast(?!) code) . Or use OpenMP, CILK and other features/libraries. But all this is fu*** sh** to push their (INTEL´s) CPU´s. If the program/algorithm is good to parallelize, OpenCL/CUDA on a price-adjusted GPU is up to 50 to 100 times faster than the code running on a CPU. Enough whining, we have AutoIt after all...1 point
-
@trancexx thanks. At the first look C++ code looks more difficult but it isn't at least compared with Pythagoras code. The C++ code made me curious and I will install the monster Visual Studio once again. Thanks for sharing. Btw, I add your Sin_/Cos_ function to FB just to compare the speed. I expected that the ASM inline is faster but isn't. Might be because the API calls amortize the speed difference.1 point
-
@Mutley, não é exatamente o que você queria, mas é disso que estou falando... Criar uma imagem de fundo, e adicionar os controles necessários, esse exemplo é básico, mas pode ser o início de uma solução. Após a composição da imagem, você pode imprimir normalmente. A melhor ideia seria criar uma imagem pronta, com o formulário vazio, e imprimir na imagem apenas as informações, assim fica mais rápido também. This example it is a toy, to create, move, resize, delete and set color to many Contols. In this example, it work with GuiCtrlCreateLabel, but can be adapted to any control. The Mod()'s function it's a attempt to move a Control to 8 to 8 pixels only, for example, not 1 to 1. If you not want this way/recurse, only comment delete the lines have Mod() function. If you want to improve this function, it's is welcome. Use Secondary mouse button, to Add, Delete, Set Color and export to PNG. Use Primary over the control to Move or Resize. ;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;~ #Tidy_Parameters=/sf ; #FUNCTION# ==================================================================================================================== ; Name ..........: No name ; Description ...: Allow create, move, resize, delete and set color a GuiCtrlCreateLabel and export to PNG image ; Syntax ........: ; Parameters ....: ; Return values .: ; Author ........: Luigi ; Example .......: ; =============================================================================================================================== #include-once #include <Array.au3> #include <GUIConstantsEx.au3> #include <File.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GuiMenu.au3> #include <WinAPIGdi.au3> #include <Misc.au3> #include <GDIPlus.au3> OnAutoItExitRegister("OnExit") Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("MustDeclareVars", 1) Global $aGuiSize[2] = [800, 600] Global $sGuiTitle = "GuiTitle" Global $hGui Global $hUm, $hDois Global $aCursor, $aMouse[5], $aMove[6], $arr, $size Global $iLimit = 6 Global $aCursor2, $aMouse2[5] Global $SUM, $DX, $DY Global $hDummy, $hDummyContext, $hDummyContextMenu Global $focus _GDIPlus_Startup() Global $hBitmap Global $hContext Global $hBrush = _GDIPlus_BrushCreateSolid() Global $hFormat, $hFamily, $hFont, $tLayout, $aInfo Global $hPen $hPen = _GDIPlus_PenCreate() Global Const $UP = 1, $RIGHT = 2, $DOWN = 4, $LEFT = 8 Global Const $UP_RIGHT = $UP + $RIGHT, $UP_LEFT = $UP + $LEFT, $DOWN_RIGHT = $DOWN + $RIGHT, $DOWN_LEFT = $DOWN + $LEFT $hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetBkColor(0xFFFFFF, $hGui) _CreateDummy($hDummy, $hDummyContext, $hDummyContextMenu, "Add=Context_Add;Del=Context_Del;Color=Context_Color;Image=Context_CreateImage") Global $aNode[1] = [0] Global $SID = IniRead("label.ini", "config", "id", 1) Global $NODES = IniReadSection("label.ini", "objetos") If IsArray($NODES) Then ReDim $NODES[UBound($NODES, 1)][3] Else Global $NODES[1][3] = [[0]] EndIf If IsArray($NODES) Then For $ii = 1 To $NODES[0][0] NewObj($NODES[$ii][0], $NODES[$ii][1], $ii) Next EndIf Func NewObj($ID = 0, $input = 0, $ii = 0) If $ID Then $input = StringSplit($input, ",", 2) $NODES[$ii][2] = GUICtrlCreateLabel($ID, $input[0], $input[1], $input[2], $input[3], $SS_SUNKEN) GUICtrlSetBkColor($NODES[$ii][2], Number($input[4])) Else Local $color = NewColor() $aCursor = GUIGetCursorInfo($hGui) $aCursor[0] -= Mod($aCursor[0], 20) + 10 $aCursor[1] -= Mod($aCursor[1], 20) + 10 Local $new = GUICtrlCreateLabel($SID, $aCursor[0], $aCursor[1], 40, 40, $SS_SUNKEN) GUICtrlSetBkColor($new, $color) $SID += 1 IniWrite("label.ini", "config", "id", $SID) IniWrite("label.ini", "objetos", $SID, ",,,," & $color) _ArrayAdd2d($NODES, $SID, "", $new) EndIf EndFunc ;==>NewObj Func NewColor() Return "0x" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) EndFunc ;==>NewColor Func _ArrayAdd2d(ByRef $arr, $mOpt0 = Default, $mOpt1 = Default, $mOpt2 = Default, $mOpt3 = Default, $mOpt4 = Default, $mOpt5 = Default, $mOpt6 = Default, $mOpt7 = Default) $arr[0][0] = UBound($arr, 1) Local $iCol = UBound($arr, 2) ReDim $arr[$arr[0][0] + 1][$iCol] If @NumParams - 1 < $iCol Then $iCol = @NumParams - 1 For $ii = 0 To $iCol - 1 $arr[$arr[0][0]][$ii] = Eval("mOpt" & $ii) Next EndFunc ;==>_ArrayAdd2d GUICtrlSetState($hUm, $GUI_ONTOP) ;~ _WinAPI_BringWindowToTop(GUICtrlGetHandle($hUm)) GUICtrlSetBkColor($hUm, 0x336633) GUICtrlSetBkColor($hDois, 0x996633) GUISetState(@SW_SHOW, $hGui) While Sleep(25) $aCursor = GUIGetCursorInfo($hGui) If IsArray($aCursor) Then If $aCursor[3] Then _GUICtrlMenu_TrackPopupMenu($hDummyContextMenu, $hGui) EndIf $focus = $aCursor[4] ? $aCursor[4] : 0 If $aCursor[2] Then If $aCursor[4] Then $aMouse[4] = $aCursor[4] $arr = ControlGetPos($hGui, "", $aCursor[4]) $aMove[0] = $arr[0] - $aCursor[0] ConsoleWrite("[" & $aMove[0] & "] [" & $arr[0] & "] [" & $aCursor[0] & "]" & @LF) $aMove[1] = $arr[1] - $aCursor[1] $aCursor2 = GUIGetCursorInfo($hGui) Switch $SUM Case $DOWN GUISetCursor(11, 1, $hGui) $DX = $aCursor2[1] - $arr[3] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[1] <> $aMouse2[1]) Then ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX) $aMouse2[1] = $aCursor2[1] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $UP GUISetCursor(11, 1, $hGui) $aMouse2[1] = $aCursor2[1] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[1] <> $aMouse2[1]) Then $size = $aMouse2[1] - $aCursor2[1] $arr[1] -= $size $arr[3] += $size ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3]) $aMouse2[1] = $aCursor2[1] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $RIGHT GUISetCursor(13, 1, $hGui) $DY = $aCursor2[0] - $arr[2] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[0] <> $aMouse2[0]) Then ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $aCursor2[0] - $DY, $arr[3]) $aMouse2[0] = $aCursor2[0] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $LEFT GUISetCursor(13, 1, $hGui) $aMouse2[0] = $aCursor2[0] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[0] <> $aMouse2[0]) Then $size = $aMouse2[0] - $aCursor2[0] $arr[0] -= $size $arr[2] += $size ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3]) $aMouse2[0] = $aCursor2[0] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $UP_RIGHT GUISetCursor(10, 1, $hGui) $aMouse2[1] = $aCursor2[1] $DY = $aCursor2[0] - $arr[2] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[1] <> $aMouse2[1]) Or ($aCursor2[0] <> $aMouse2[0]) Then $size = $aMouse2[1] - $aCursor2[1] $arr[1] -= $size $arr[3] += $size $arr[2] = $aCursor2[0] - $DY ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3]) $aMouse2[0] = $aCursor2[0] $aMouse2[1] = $aCursor2[1] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $DOWN_RIGHT GUISetCursor(12, 1, $hGui) $DY = $aCursor2[0] - $arr[2] $DX = $aCursor2[1] - $arr[3] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then $arr[2] = $aCursor2[0] - $DY ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX) $aMouse2[0] = $aCursor2[0] $aMouse2[1] = $aCursor2[1] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $UP_LEFT GUISetCursor(12, 1, $hGui) $aMouse2[0] = $aCursor2[0] $aMouse2[1] = $aCursor2[1] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then $size = $aMouse2[1] - $aCursor2[1] $arr[1] -= $size $arr[3] += $size $size = $aMouse2[0] - $aCursor2[0] $arr[0] -= $size $arr[2] += $size ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $arr[3]) $aMouse2[0] = $aCursor2[0] $aMouse2[1] = $aCursor2[1] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case $DOWN_LEFT GUISetCursor(10, 1, $hGui) $aMouse2[0] = $aCursor2[0] $DX = $aCursor2[1] - $arr[3] While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then $size = $aMouse2[0] - $aCursor2[0] $arr[0] -= $size $arr[2] += $size ControlMove($hGui, "", $aCursor[4], $arr[0], $arr[1], $arr[2], $aCursor2[1] - $DX) $aMouse2[0] = $aCursor2[0] $aMouse2[1] = $aCursor2[1] _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd Case Else GUISetCursor(9, 1, $hGui) While IsArray($aCursor2) And $aCursor2[2] $aCursor2 = GUIGetCursorInfo($hGui) If ($aCursor2[0] <> $aMouse2[0]) Or ($aCursor2[1] <> $aMouse2[1]) Then $aCursor2[0] = $aCursor2[0] - Mod($aCursor2[0], 20) ;+ $aMove[0] ConsoleWrite("[" & $aCursor2[0] & "] [" & $aMove[0] & "] [" & $aCursor2[0] - Mod($aCursor2[0], 20) & "]" & @LF) $aCursor2[1] = $aCursor2[1] - Mod($aCursor2[1], 20); + $aMove[1] $aMouse2[0] = $aCursor2[0] $aMouse2[1] = $aCursor2[1] ControlMove($hGui, "", $aCursor[4], $aCursor2[0], $aCursor2[1], $arr[2], $arr[3]) _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE) EndIf WEnd EndSwitch GUISetCursor(6, 1, $hGui) Else EndIf Else If $aCursor[4] Then $arr = ControlGetPos($hGui, "", $aCursor[4]) $aMove[0] = $arr[0] - $aCursor[0] $aMove[1] = $arr[1] - $aCursor[1] $SUM = 0 If $aMove[0] <= 0 And $aMove[0] > -$iLimit Then $SUM += $LEFT If $aMove[0] <= -($arr[2] - $iLimit) And $aMove[0] >= -$arr[2] Then $SUM += $RIGHT If $aMove[1] <= 0 And $aMove[1] > -$iLimit Then $SUM += $UP If $aMove[1] <= -($arr[3] - $iLimit) And $aMove[1] >= -$arr[3] Then $SUM += $DOWN Switch $SUM Case $UP GUISetCursor(11, 1, $hGui) Case $DOWN GUISetCursor(11, 1, $hGui) Case $RIGHT GUISetCursor(13, 1, $hGui) Case $UP_RIGHT GUISetCursor(10, 1, $hGui) Case $DOWN_RIGHT GUISetCursor(12, 1, $hGui) Case $LEFT GUISetCursor(13, 1, $hGui) Case $UP_LEFT GUISetCursor(12, 1, $hGui) Case $DOWN_LEFT GUISetCursor(10, 1, $hGui) Case Else GUISetCursor(6, 1, $hGui) EndSwitch Else GUISetCursor(6, 1, $hGui) EndIf EndIf EndIf WEnd Func OnExit() For $ii = 1 To $NODES[0][0] IniWrite("label.ini", "objetos", $NODES[$ii][0], _ArrayToString(ControlGetPos($hGui, "", $NODES[$ii][2]), ",") & "," & GUICtrlGetBkColor($NODES[$ii][2])) Next _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_Shutdown() GUISetState($hGui, @SW_HIDE) GUIDelete($hGui) EndFunc ;==>OnExit Func Quit() Exit EndFunc ;==>Quit Func _CreateDummy(ByRef $dummy, ByRef $context, ByRef $menu, $cmd) Local $aDummy[1][3] _ArrayAdd($aDummy, $cmd, Default, "=", ";") $dummy = GUICtrlCreateDummy() $context = GUICtrlCreateContextMenu($dummy) $menu = GUICtrlGetHandle($context) For $ii = 1 To UBound($aDummy, 1) - 1 $aDummy[$ii][2] = GUICtrlCreateMenuItem($aDummy[$ii][0], $context) If $aDummy[$ii][1] Then GUICtrlSetOnEvent($aDummy[$ii][2], $aDummy[$ii][1]) Next EndFunc ;==>_CreateDummy Func Context_Add() NewObj() EndFunc ;==>Context_Add Func _box($hToGraphic, $iXX, $iYY, $iWW, $iHH, $iColor = 0, $bFill = False) ; _box3 _GDIPlus_BrushSetSolidColor($hBrush, $iColor) If $iWW = 1 And $iHH = 1 Then If $iColor Then _GDIPlus_GraphicsFillRect($hToGraphic, $iXX, $iYY, $iWW, $iHH, $hBrush) Else _GDIPlus_GraphicsFillRect($hToGraphic, $iXX, $iYY, $iWW, $iHH) EndIf Else Local $aBox[5][2] $aBox[0][0] = 4 $aBox[1][0] = $iXX $aBox[1][1] = $iYY $aBox[2][0] = $iXX + $iWW - 1 $aBox[2][1] = $iYY $aBox[3][0] = $iXX + $iWW - 1 $aBox[3][1] = $iYY + $iHH - 1 $aBox[4][0] = $iXX $aBox[4][1] = $iYY + $iHH - 1 If $iColor Then _GDIPlus_PenSetColor($hPen, $iColor) _GDIPlus_GraphicsFillPolygon($hToGraphic, $aBox, $hBrush) _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox, $hPen) Else _GDIPlus_GraphicsDrawPolygon($hToGraphic, $aBox) EndIf EndIf EndFunc ;==>_box Func _Text($hToGraphic, $sFont, $sText, $iSize, $iXX, $iYY, $iWW, $iHH, $iColor) _GDIPlus_BrushSetSolidColor($hBrush, $iColor) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate($sFont) $hFont = _GDIPlus_FontCreate($hFamily, $iSize, 0) $tLayout = _GDIPlus_RectFCreate($iXX, $iYY, $iWW, $iHH) $aInfo = _GDIPlus_GraphicsMeasureString($hToGraphic, $sText, $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hToGraphic, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) EndFunc ;==>_Text Func Context_CreateImage() ConsoleWrite("Context_CreateImage()" & @LF) Local $aControlGetPos, $iColor, $sText Local $iR, $iG, $iB $hBitmap = _GDIPlus_BitmapCreateFromScan0($aGuiSize[0], $aGuiSize[1]) $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hContext, 0) _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF) For $ii = 1 To $NODES[0][0] $aControlGetPos = ControlGetPos($hGui, "", $NODES[$ii][2]) $iColor = GUICtrlGetBkColor($NODES[$ii][2]) $iR = _WinAPI_GetRValue($iColor) $iG = _WinAPI_GetGValue($iColor) $iB = _WinAPI_GetBValue($iColor) $iColor = "0x99" & Hex(_WinAPI_RGB($iR, $iG, $iB), 6) _box($hContext, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], $iColor, True) $sText = GUICtrlRead($NODES[$ii][2]) _Text($hContext, "Courier New", $sText, 10, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], 0xFF000000) Next Local $sFile = @TempDir & "\Test.png" FileDelete($sFile) _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save bitmap to disk ShellExecute($sFile) EndFunc ;==>Context_CreateImage Func Context_Del() Local $find = _ArraySearch($NODES, $focus, 1, Default, 0, 0, 0, 2) ConsoleWrite("$focus[" & $focus & "] $find[" & $find & "]" & @LF) If $find >= 0 Then GUICtrlDelete($focus) IniDelete("label.ini", "objetos", $NODES[$find][0]) _ArrayDelete($NODES, $find) $aCursor = GUIGetCursorInfo($hGui) EndIf $NODES[0][0] = UBound($NODES, 1) - 1 EndFunc ;==>Context_Del Func Context_Color() If Not $focus Then Return Local $color = GUICtrlGetBkColor($focus) Local $NewColor = _ChooseColor(2, $color, 2, $hGui) If $NewColor = -1 Then Return GUICtrlSetBkColor($focus, $NewColor) EndFunc ;==>Context_Color ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlGetBkColor ; Description ...: Retrieves the RGB value of the control background. ; Syntax ........: GUICtrlGetBkColor($hWnd) ; Parameters ....: $hWnd - Control ID/Handle to the control ; Return values .: Success - RGB value ; Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlGetBkColor($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel($hDC, 0, 0) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColor1 point
-
It's an old post, so it was probably good at the time, and then when converted to the newer forum, the '\' was dropped. One of my other posts also dropped the '\', but the results were as expected, which backs up my assumption.1 point
-
masvil, Use @DeskTopWidth/@DeskTopHeight to get the screen size and use some simple maths. M231 point
-
I should read the help more and look at examples If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf1 point
-
You want that the button on x axis is the same as the x axis from the tab. That means when you resize the window button and tab should stay on same x coordinate. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 615, 438, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME)) $Tab1 = GUICtrlCreateTab(24, 32, 561, 377) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("TabSheet1") $TabSheet2 = GUICtrlCreateTabItem("TabSheet2") GUICtrlCreateTabItem("") $Button_1 = GUICtrlCreateButton("Button", 24, 6, 100) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd If not I will give up... Br, UEZ1 point
-
I little bit abrupt if I might add, UEZ is at least trying to help, which can't be said for you. I would highly recommend reading the Help File and using what can only be said as a "brilliant" Example by UEZ to learn from.1 point