Jump to content

johnmcloud

Active Members
  • Posts

    739
  • Joined

  • Last visited

Community Answers

  1. johnmcloud's post in ListView select subitems. was marked as the answer   
    ;~ Example made by LarsJ, just some very little change by Johnmcloud - 2015 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("MustDeclareVars", 1) Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell $hGUI = GUICreate("Mark Cell in Listview", 250, 222) Local $iListview = GUICtrlCreateListView("Column 0|Column 1", 2, 2, 248, 180, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $$hListview = GUICtrlGetHandle($iListview) Local $iButton = GUICtrlCreateButton("Value?", 90, 193, 70, 20) For $i = 0 To 50 GUICtrlCreateListViewItem("Item" & $i & "|SubItem " & $i, $iListview) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 2, $aInfo[1] - 2) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY 
    $LVS_EX_BORDERSELECT works only with icon Listview style, your use is wrong. Rename the thread accordy to the request, so "how to select subitem in listview" or similar.
  2. johnmcloud's post in TraySetToolTip override default was marked as the answer   
    I have found my answer. After hour of search for the solution, found on the russian autoit forum ( of 2012 thread ) but the same answer was on THIS forum from a thread of 2008 by Jos, is soo damn easy:
    _TraySetNoToolTip() While 1 Sleep(100) WEnd Func _TraySetNoToolTip() Return TraySetToolTip(Chr(0)) EndFunc Is not the case to add it in the Help?
    https://www.autoitscript.com/autoit3/docs/functions/TraySetToolTip.htm
    Thanks to all
  3. johnmcloud's post in Making a Listview not clickable? was marked as the answer   
    ;~ Johnmcloud 2014 #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> $Form = GUICreate("Johnmcloud Test Code", 400, 220, -1, -1) $hListView = GUICtrlCreateListView("Col 1|Col 2|Col 3", 0, 0, 400, 220) For $i = 0 To 100 GUICtrlCreateListViewItem('Text|Text|Text', $hListView) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $IdFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $IdFrom = DllStructGetData($tNMHDR, "IdFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $IdFrom Case $hListView Switch $iCode Case $LVN_ITEMACTIVATE Return 1 Case $LVN_ITEMCHANGING Return 1 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
  4. johnmcloud's post in Set image png to ListView was marked as the answer   
    ; Johnmcloud - 2014 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GUIImageList.au3> #include <GUIListView.au3> #include <GDIPlus.au3> $hGUI = GUICreate("Johnmcloud Test GUI", 620, 440, -1, -1) $iListView = GUICtrlCreateListView("County|Name|Address", 0, 0, 620, 440, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($iListView) $hImageList = _GUIImageList_Create(40, 40) _GUICtrlListView_SetImageList($hListView, $hImageList, 1) _GUICtrlListView_InsertItem($hListView, 'RO', 0) _GUICtrlListView_SetItemImageEx($hListView, 0, @ScriptDir & "\img1.png") _GUICtrlListView_AddSubItem($hListView, 0, "Place to eat in Romania", 1) _GUICtrlListView_AddSubItem($hListView, 0, "7722 Dusty Cider Highlands", 2) _GUICtrlListView_InsertItem($hListView, 'RO', 1) _GUICtrlListView_SetItemImageEx($hListView, 0, @ScriptDir & "\img2.png") _GUICtrlListView_AddSubItem($hListView, 1, "Place to eat in England", 1) _GUICtrlListView_AddSubItem($hListView, 1, "3042 High Branch Freeway", 2) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, -1) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, -1) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, -1) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _GUICtrlListView_SetItemImageEx($hWnd, $iIndex, $sFile) ; Orginal function by Yashied Local $Size = _GUIImageList_GetIconSize($hImageList), $W, $H, $hGraphic, $hPic, $hImage, $hIcon If (Not $Size[0]) Or (Not $Size[1]) Then Return 0 _GDIPlus_Startup() $hPic = _GDIPlus_ImageLoadFromFile($sFile) $W = _GDIPlus_ImageGetWidth($hPic) $H = _GDIPlus_ImageGetHeight($hPic) If ($W < 0) Or ($H < 0) Then _GDIPlus_Shutdown() Return 0 EndIf If $W < $H Then $W = $Size[0] * $W / $H $H = $Size[1] Else $H = $Size[1] * $H / $W $W = $Size[0] EndIf $hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $Size[0], 'int', $Size[1], 'ptr*', 0, 'ptr', 0, 'ptr', 0) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage[4]) _GDIPlus_GraphicsClear($hGraphic, 0) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hPic, ($Size[0] - $W) / 2, ($Size[1] - $H) / 2, $W, $H) $hIcon = DllCall($ghGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage[4], 'ptr*', 0) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage[4]) _GDIPlus_ImageDispose($hPic) _GDIPlus_Shutdown() If Not $hIcon[2] Then Return 0 _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon[2]) _GUICtrlListView_SetItemImage($hWnd, $iIndex, _GUIImageList_GetImageCount($hImageList) - 1) _WinAPI_DestroyIcon($hIcon[2]) Return 1 EndFunc ;==>_GUICtrlListView_SetItemImageEx
  5. johnmcloud's post in [BUG 3.3.8.1] GUISetState, something doesn't add up was marked as the answer   
    Work with the last stable version, i'm still stuck to 3.3.8.1 and with that version not work. The breaking things make me scared
  6. johnmcloud's post in Run shortcut Maximized/Minimized was marked as the answer   
    Me = 1 vs MVPs/Mod = 0, this time and maybe only this time i have the ANSWER  Yeah is not a competition but it is a satisfaction ;~ ;johnmcloud - 2014 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ;~ Global Const $tagSTARTUPINFO = "int Size;ptr Reserved1;ptr Desktop;ptr Title;int X;int Y;int XSize;int YSize;int XCountChars;" & _ ;~ "int YCountChars;int FillAttribute;int Flags;short ShowWindow;short Reserved2;ptr Reserved3;int StdInput;" & _ ;~ "int StdOutput;int StdError" Global $sState = @SW_SHOW Global $sShortcut = _RunFromShortcut() If IsArray($sShortcut) Then If $sShortcut[6] = 3 Then $sState = @SW_SHOWMAXIMIZED If $sShortcut[6] = 7 Then $sState = @SW_SHOWMINIMIZED EndIf $hGUI = GUICreate("Johnmcloud knows best", 265, 250, -1, -1, $WS_MAXIMIZEBOX) _WinAPI_ShowWindow($hGUI, $sState) ;@SW_SHOWMAXIMIZED with GUISetState not work While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _RunFromShortcut() Local $tSI = DllStructCreate($tagSTARTUPINFO) DllCall('kernel32.dll', 'none', 'GetStartupInfoW', 'struct*', $tSI) If @error Then Return SetError(@error, @extended, 0) Local $vFlag = DllStructGetData($tSI, 'Flags') If BitAND($vFlag, 0x800) Then Local $sTitle = DllStructCreate('wchar ShortcutPath[261]', DllStructGetData($tSI, 'Title')) Local $sShortcutPath = DllStructGetData($sTitle, 'ShortcutPath') If $sShortcutPath Then Return FileGetShortcut($sShortcutPath) Else Return SetError(1, 0, 0) EndIf Else Return SetError(2, 0, 0) EndIf EndFunc ;==>_Shortcut
  7. johnmcloud's post in Start exe as child of explorer.exe was marked as the answer   
    My last shot on this:
    ;johnmcloud _RunFromExplorer("notepad.exe") Sleep(1000) _RunFromExplorer("calc.exe") Func _RunFromExplorer($ExePath = "") If $ExePath = "" Then SetError(1, 0, 0) $objShell = ObjCreate("Shell.Application") $objShell.FileRun WinWait("[CLASS:#32770]", "") ControlSetText("[CLASS:#32770]", "", "Edit1", $ExePath) ControlClick("[CLASS:#32770]", "", "Button2") EndFunc ;==>_RunFromExplorer Tested on XP and CLASS maybe change on ther o.s. Pratically i'll open the Run Dialog Box and write the path of the software, so it start with explorer parent
    Result:

  8. johnmcloud's post in Hour Input UpDown Control was marked as the answer   
    I have beat FireFox, is a good day
    I'm jocking, this is what MyEarth want:
    ; johnmcloud #include <GuiDateTimePicker.au3> #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 120, 50, -1, -1) $hDTP = _GUICtrlDTP_Create($hGUI, 20, 15, 80, 21, $DTS_UPDOWN) GUISetState() _GUICtrlDTP_SetFormat($hDTP, "HH.mm.ss") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE
  9. johnmcloud's post in SOLVED:Change right mouse menu was marked as the answer   
    Try this:
    #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> #include <GuiMenu.au3> #include <WinAPI.au3> Global Enum $idPaste = 1000 $hGUI = GUICreate("Test", 300, 200) $Input = GUICtrlCreateInput("Input Test", 16, 16, 100, 25) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "Paste", $idPaste) GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") $wProcOld = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) DllCallbackFree($wProcHandle) Func _WindowProc($hWnd, $msg, $wParam, $lParam) Switch $hWnd Case GUICtrlGetHandle($Input) Switch $msg Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) Return 0 Case $WM_COMMAND Switch $wParam Case $idPaste MsgBox(0, 0, "Put Func Here") EndSwitch EndSwitch EndSwitch Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, "hwnd", $hWnd, "uint", $msg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc ;==>_WindowProc
×
×
  • Create New...