[Class] LV_Colors - 1.1.05.00 (2024-03-16)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

16 Nov 2017, 17:03

OK, so I was forgetting of course that the pure AHK solution is processing the messages for it's own window.
Ideally I want to build this as a C# DLL (Which normally lacks a message pump, so cannot process messages), so I will need a message pump and to somehow intercept the messages for the AHK window.

I think I have some code that will do that, I wrote a POC for RawInput in a C# dll, which also required a message pump, so I think I am half way there.
Clocking off for today, will try and do some more work on it over the weekend.
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

18 Nov 2017, 18:12

Ah, I was going about things the wrong way - if the C# code is being loaded as a library from AHK, then of course I can just hook the messages meant for the AHK GUI (Local hook, not global hook).
ManagedWinapi has stuff built-in for this it seems, so now I can hook into the messages sent to the ListView.
I still do not understand what to do at what point and in response to what messages though. It seems that LV_Colors uses NM_CUSTOMDRAW whereas the example code I have been messing around with uses WM_PAINT / WM_ERASEBKGND
So... more progress, and I think I have proved that you *can* completely offload this code to C#, but still not that close to actually getting it working.
AlexD9111

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

16 Feb 2018, 04:50

Hi thanks for your Class, this is very usefull.
I have a little problem, when my listview appears first there is no color.
I have to scroll down or resize my list view to refresh and display alternate rows colors.
Could you please help me ?
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

17 Feb 2018, 06:14

LV_Colors_sample.ahk:

Code: Select all

...
Gui, Show, , ListView & Colors
; Redraw the ListView after the first Gui, Show command to show the colors, if any.
WinSet, Redraw, , ahk_id %HLV%
...
AlexD9111

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

20 Feb 2018, 00:54

thanks Just me
it works fine when I use only this line :
WinSet, Redraw, , ahk_id %HLV%
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

22 Jul 2019, 04:24

Hey justme,

have you already figured out why you can't sort the columns when the colors are on?
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

22 Jul 2019, 04:40

Hi jNizM,

no, it's still a mystery. It seems that message processing gets out of order at some stage.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

22 Jul 2019, 04:49

I played a bit with the Class.
With CLV := New LV_Colors(HLV,,false) sort is working.. why do you added the NoSort? Just a feature for the Class?

It is the first time I noticed this Flag :facepalm:
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

22 Jul 2019, 05:03

Setting the flag to False might be working. But i didn't work always. So you do it on your own risk.
gmanhunt
Posts: 18
Joined: 14 Mar 2018, 01:30

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

27 Sep 2019, 04:26

Hello, I'm working on a script where I want doubleclicked rows to be colored, and when the user doubleclicked a different row, the previously colored row will revert back to default, and the newly selected row will be colored. If the user doubleclicked on a already colored row, the row will revert back to default.

The problem is that when I double clicked on a new row, the previously colored row kept its color and now I have more than 1 colored rows. How do I fix this? Here's an example script:

Code: Select all

#SingleInstance Force
#Include <Class_LV_Colors>

Gui, SampleGui:New
Gui, Add, ListView, W244 R10 +Grid vSampleLV gCheckLV hwndColorLV, Col1|Col2|Col3
Gui, SampleGui:Show,, % "Sample GUI"

CLV := New LV_Colors(ColorLV)

Loop, 10
{
	LV_Add("", "Value " . A_Index, A_Index)
}

Loop, % LV_GetCount("Column")
{
	LV_ModifyCol(A_Index, 80)
}

previousSelection := 0

CheckLV:
	If (A_GuiEvent == "DoubleClick") {
		CLV.Clear()
		currentSelection := A_EventInfo
		If (previousSelection != currentSelection) {
			Goto, LoadValue
		} else {
			Goto, UnloadValue
		}
	}
return

LoadValue:
	CLV.Row(currentSelection, 0x000000, 0xFFFFFF)
	previousSelection := currentSelection
return

UnloadValue:
	MsgBox,, % "Alert", % "Unloading values!"
return
list
Posts: 221
Joined: 26 Mar 2014, 14:03
Contact:

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

27 Sep 2019, 05:02

@gmanhunt Redraw your Listview - also use Gosub :)

Code: Select all

CheckLV:
	If (A_GuiEvent == "DoubleClick") {
		currentSelection := A_EventInfo
		If (previousSelection != currentSelection) {
			Gosub, LoadValue   ; use gosub not goto
		} else {
			Gosub, UnloadValue ; use gosub not goto
		}
	}
return

LoadValue:
	CLV.Clear() ; moved here
	GuiControl, +Redraw, SampleLV ; Redraw
	CLV.Row(currentSelection, 0x000000, 0xFFFFFF)
	previousSelection := currentSelection
return
gmanhunt
Posts: 18
Joined: 14 Mar 2018, 01:30

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

27 Sep 2019, 05:16

list wrote:
27 Sep 2019, 05:02
@gmanhunt Redraw your Listview - also use Gosub :)

Code: Select all

CheckLV:
	If (A_GuiEvent == "DoubleClick") {
		currentSelection := A_EventInfo
		If (previousSelection != currentSelection) {
			Gosub, LoadValue   ; use gosub not goto
		} else {
			Gosub, UnloadValue ; use gosub not goto
		}
	}
return

LoadValue:
	CLV.Clear() ; moved here
	GuiControl, +Redraw, SampleLV ; Redraw
	CLV.Row(currentSelection, 0x000000, 0xFFFFFF)
	previousSelection := currentSelection
return
That worked! Thanks a lot! :)
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

09 Nov 2019, 11:05

I'm having crash problems. Is there a general solution? When you work on top of each other, it doesn't take long for it to collapse. Fully responsible LV_Colors, because there will be no crashes when disabled.

The work file is too big. Excuse me.

Code: Select all

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Include %A_ScriptDir%\Class_SQLiteDB.ahk 
#Include %A_ScriptDir%\LV_EX.ahk
#Include %A_ScriptDir%\Class_LV_Colors.ahk

Menu MenuBar, Add, &Dosya, FileMenu
Menu MenuBar, Add, &Düzen, GuiKaydet
Gui Menu, MenuBar
FileMenu:

DB := new SQLiteDB
DBFile = %A_Scriptdir%\DOSYALAR.SQLITE
;DBFile := "\\halkali1\ISTHUKUK\AA----DİĞER PERSONELLER-----\HASAN SALİHOĞLU\ÇALIŞMALAR\DOSYALARDB\DOSYALAR.SQLITE"
DB.OpenDB(DBFile)
global SutunSirasi := []
global SutunSirasi2 := []
; Generated by AutoGUI 2.5.8
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Gui +Resize  +Owner ; +AlwaysOnTop
;Gui Add,Button, gGuiKaydet x+10 ,Sütunları Kaydet
Gui Add, ListView, hWndhLVItems vLVBulunanlar x0 y90 w1632 +Grid +0x100 +LV0x4000, ; height guisizede ayarllanır h600 Açıklama|Adli Birim|Arşiv Klasör No|Arşiv No|Arşiv Tarihi|Aşaması|Başlama Tarihi|Bölge|Diğer Taraf|Durumu|Esas No|Esas Yıl|Eski Esaslar|Hükmedilen Tutar|Hüküm|Islah Edilen Tutar|Karar No|Karar Tarihi|Karar Tebliğ Tarihi|Karşı Taraf|Karşı Taraf Vekili|Kayıt Tarihi|Konumu|Konusu|Kurum Dosya Numarası|Özel Alan|Reddedilen Tutar|Sonucu|Talep Edilen Tutar|Tarafımız|Vekalet Ücreti|Vekalet ÜcretiÖdenen|Vekalet Ücreti Tahsil Edilen|Vekillerimiz|Adliye|İl
DllCall("UxTheme.dll\SetWindowTheme", "Ptr", hLVItems, "WStr", "Explorer", "Ptr", 0)

;----------Veritabanından Columnları Al---

FileRead,HangiSutunlarGelecek,%A_Scriptdir%\Sutunlar.ini	
SQL := "pragma table_info(Dosyalar)"
DB.GetTable(SQL, Sutunlar)	

TumSutunlar := []
loop % Sutunlar.RowCount
{
	GeciciSutunSirasi := A_Index
	Loop,Parse,HangiSutunlarGelecek,`r,`n
		if(A_LoopField == Sutunlar.Rows[GeciciSutunSirasi,2]){
			LV_InsertCol(LV_GetCount("Column") + 1,,Sutunlar.Rows[GeciciSutunSirasi,2])
			TumSutunlar.Push(Sutunlar.Rows[GeciciSutunSirasi,2])
		}
}	
;----------Veritabanından Columnları Al----
Gui Font, s10
Gui Add, ComboBox, hWndhCbxItems vArananMetinV gDosyaSorgula  x8 y8 w1455, ;ComboBox ;gArananMetinG
Gui Add, ComboBox, hWndhCbxFiltre vFiltrelenenMetinV   x863 y50 w600, % "|" ;ComboBox ;gArananMetinG
hCbxEdit := DllCall("GetWindow", "Ptr", hCbxItems, "UInt", 5, "Ptr") ; GW_CHILD
SendMessage 0x1501, 1, "Aramak istediğiniz metni girin...",, ahk_id %hCbxEdit% ; EM_SETCUEBANNER
hCbxFiltre := DllCall("GetWindow", "Ptr", hCbxFiltre, "UInt", 5, "Ptr") ; GW_CHILD
SendMessage 0x1501, 1, "Sütunlarda filtreleme yapın...",, ahk_id %hCbxFiltre% ; EM_SETCUEBANNER

Gui Add, Button, x8 y45 w90 gFiltreOlustur vFiltreOlustur, Filtre Oluştur
Gui Add, Checkbox, x105 y45 VkonumuMevcutV +Checked, Mevcut
Gui Add, Checkbox, x105 y60 VkonumuArsivV, Arşiv

Gui Add, Checkbox, x175 y45 vbolgesiIstanbulV +Checked, İstanbul
Gui Add, Checkbox, x175 y60 vbolgesiAnkaraV, Ankara
		;*******
;######### VEKİLLERİ DB DEN ALIR #################
SQL := "Select DISTINCT Vekillerimiz From Dosyalar"
DB.GetTable(SQL, Result)
loop % Result.RowCount 
	if(Result.Rows[a_index,1] != "")
		listeyiAl1 .= Result.Rows[a_index,1]  "|"
Gui Add, Text, x255 y53 ,Vekil:
Gui Add, ComboBox, vVekillerListV x290 y50 w200  +Sort, % "`r|" . listeyiAl1
;######### VEKİLLERİ DB DEN ALIR #################
		;*******
;######### tARAF TÜRLERİNİ VERİTABANINDAN ALIP CMBXA GÖSTERİR #######
SQL := "Select DISTINCT [Tarafımız] From Dosyalar"
DB.GetTable(SQL, Result)
loop % Result.RowCount 
	if(Result.Rows[a_index,1] != "")
		listeyiAl .= Result.Rows[a_index,1]  "|"
Gui Add, Text, x510 y53 ,Tarafımız:
Gui Add, ComboBox, x570 y50 w100 VTarafTuruListV, % "`r|" . listeyiAl
;GuiControl,,TarafTuruListV,% Result.Rows[a_index,1]
;######### tARAF TÜRLERİNİ VERİTABANINDAN ALIP CMBXA GÖSTERİR #######
		;*******
;######### KAÇ SONUÇ GETİRİLECEK KISITLAMASI #######
Gui Add, Text, x690 y53, Kaç Sonuç:
Gui Add, ComboBox, x760 y50 w60 vKacTaneGetirilecek hwndHCBB, 50||100|500|1000|5000|10000|1000000
HCBEDIT := ComboBoxGetHEDIT(HCBB) ;SADECE RAKAM GİRİLEBİLSİN DİYE
WinSet, Style, +0x2000, ahk_id %HCBEDIT% ; ES_NUMBER
ComboBoxGetHEDIT(HCBB) {
	Static SizeOfCBI := (4 * 10) + (A_PtrSize * 3)
	Static OffHEDIT := (4 * 10) + A_PtrSize
	VarSetCapacity(CBI, SizeOfCBI, 0)
	NumPut(SizeOfCBI, CBI, 0, "UInt")
	If DllCall("User32.dll\GetComboBoxInfo", "Ptr", HCBB, "Ptr", &CBI, "UInt")
		Return NumGet(CBI, OffHEDIT, "UPtr")
	Return False
}	;SADECE RAKAM GİRİLEBİLSİN DİYE
;######### KAÇ SONUÇ GETİRİLECEK KISITLAMASI #######
		;*******

Gui Add, StatusBar,, Status Bar

;####-----------SUTUN SİRASINI GERİ YÜKLE---------------
FileRead,DosyadanSutunSira,%A_Scriptdir%\SutunHizalama 
Loop,Parse,DosyadanSutunSira,`r,`n
	if(A_LoopField != "")
		SutunSirasi2[a_index] := A_LoopField
LV_EX_SetColumnOrder(hLVItems,SutunSirasi2)
;#####--------SUTUN GENİSLİKLERİ GERİ YÜKLE --------------
Gui +LastFound
FileRead,DosyadanSutunGenislik,%A_Scriptdir%\SutunGenislik 
Loop,Parse,DosyadanSutunGenislik,`r,`n
	if(A_LoopField != "")
		LV_ModifyCol(a_index,A_LoopField)
;LV_EX_GetColumnWidth(hLVItems,)

;GALİBA ÇÖKTÜRÜYOR
[color=#FF0000]CLV := New LV_Colors(hLVItems,,,False)[/color] ;LV DEKİ RENKLERİ SIFIRLAR GALİBA
;LVX_Setup("LVBulunanlar") 			;Kılavuz listviewine renk verebilmek içindir
Gui Show, w1482 h738, Dosya Ara

LVler := [] ;array olarak eklemek gerekiyor
Return



#IfWinActive,Dosya Ara

DosyaSorgula:
Enter::
NumpadEnter::
;~NumpadAdd::

Gui, ListView,LVBulunanlar
LV_Delete()
GuiControlGet,aramaMetin,,ArananMetinV           		 						;arama çubuğundan arama metnini alır
GuiControlGet,UygulananFiltreler,,FiltrelenenMetinV           		 						;arama çubuğundan arama metnini alır
GuiControl,1:,ArananMetinV,% aramaMetin
GuiControlGet,kacTane,,KacTaneGetirilecek

GuiControlGet,hangiVekil,,VekillerListV
GuiControlGet,hangiTaraf,,TarafTuruListV
GuiControlGet,istanbulBolgesi,,bolgesiIstanbulV
GuiControlGet,ankaraBolgesi,,bolgesiAnkaraV
GuiControlGet,konumuArsiv,,konumuArsivV
GuiControlGet,konumuMevcut,,konumuMevcutV
GuiControl,,ilerleme,% "Aranıyor: " aramaMetni    
SorguKriterleri := ;değişkeni temizlemek lazım
if(hangiVekil != "")
	SorguKriterleri .= """Vekillerimiz"":" chr(34) hangiVekil chr(34) "* AND "
if(hangiTaraf != "")
	SorguKriterleri .= """Tarafımız:""" chr(34) hangiTaraf chr(34) "* AND "
if(istanbulBolgesi == 1 AND ankaraBolgesi == 0) ;AND VAR ÇÜNKÜ İKİSİ DE SEÇİLİYSE SINIRLAMA GETİRMENİN ANLAMI YOK HEPSİ LİSTELENSİN DİYE BOŞ BIRAKMAK DAHA MANTIKLI
	SorguKriterleri .=  " AND ""Bölge"":""İSTANBUL""*" 
if(ankaraBolgesi == 1 AND istanbulBolgesi == 0) ;AND VAR ÇÜNKÜ İKİSİ DE SEÇİLİYSE SINIRLAMA GETİRMENİN ANLAMI YOK HEPSİ LİSTELENSİN DİYE BOŞ BIRAKMAK DAHA MANTIKLI
	SorguKriterleri .=  " AND ""Bölge"":""ANKARA""*"
if(konumuArsiv == 1 AND konumuMevcut = 0) ;AND VAR ÇÜNKÜ İKİSİ DE SEÇİLİYSE SINIRLAMA GETİRMENİN ANLAMI YOK HEPSİ LİSTELENSİN DİYE BOŞ BIRAKMAK DAHA MANTIKLI
	SorguKriterleri .=  " AND ""Konumu"":""ARŞİVDE""*"
if(konumuMevcut == 1 AND konumuArsiv = 0) ;AND VAR ÇÜNKÜ İKİSİ DE SEÇİLİYSE SINIRLAMA GETİRMENİN ANLAMI YOK HEPSİ LİSTELENSİN DİYE BOŞ BIRAKMAK DAHA MANTIKLI
	SorguKriterleri .=  " AND ""Konumu"":""MEVCUT""*"


;SQL := "SELECT * FROM Database('" SQL " " SQLtarih "')Limit " kacTane " " 	;tüm satırlarda arama bazlı
StringRight,ney,% aramaMetin,1 ;TAM METİN ARA JOKER KARAKTERİNİ KONTROL EDER +

yildiz := "*"
if(aramaMetin != ""){ ;ana arama boxu boşsa boşuna yere giriş yapılmayacak
	yildiz := "*"
	if(ney == "+"){
		SubStr(aramaMetin,1,StrLen(aramaMetin) - 1)
		yildiz := ""	
	}
	aramaMetin := Chr(34) aramaMetin Chr(34) yildiz
}
ELSE
{	
	;ANA ARAMA TEXTİ BOŞ GÖRÜNÜYOR BU DURUMDA AND İLE BAŞLAYAN İFADELERDEN KAÇINMAK ZORUNAYIZ
	SorguKriterleri := StrReplace(SorguKriterleri,"AND","",,1) ; sorgu kriterleri sorgu ifadesinde daha önce geçtiği için İLK AND her halükarda silinmeli. Bu kısımdaki kotlar ana arama boxu boşsa çalışır zaten
	if(UygulananFiltreler != "" AND SorguKriterleri == "") 	;bu ifin üst ifiyle zaten sadece ana arama boxu boşsa çalışıyor, sorgu kriterleri boş değilse zaten sorguda uygulanan filtrelerden önce geleceği için başta and ifadesi olmasında sıkıntı yok ama ilk bu ifadeyse başta and olmamalı
		UygulananFiltreler := StrReplace(UygulananFiltreler,"AND","",,1) 
}

SutunAdlariFnc(){ ;hangi sütun adlarının alınacağını ini dosyasından seçerek alır
	FileRead,HangiSutunlarGelecek,%A_Scriptdir%\Sutunlar.ini
	Loop,Parse,HangiSutunlarGelecek,`r,`n
		if(A_LoopField != ""){
			SQLsutunlar .= ilkVirgul Chr(34) A_LoopField Chr(34)
			ilkVirgul := ","  ;ilk sütun adından önce virgül olmamalı bu yüzden ilk kelime girildikten sonr alıyoruz virgülü
		}

Return SQLsutunlar
}
SQL := "SELECT " SutunAdlariFnc() " FROM Dosyalar(' " aramaMetin "  "  SorguKriterleri " " UygulananFiltreler "')Limit " kacTane " " 	;tüm satırlarda arama bazlı	

WinSet, Redraw, , ahk_id %h%


;MsgBox % SQL 
DB.GetTable(SQL, Result)
;CLV.Clear()
;LV_Delete()
GuiControl, -ReDraw, LVBulunanlar
;Sleep,5000
loop % Result.RowCount 			;BULUNAN DEĞERLERİ LV YE GİRECEK
{
	;MsgBox % RegExReplace(Result.Rows[a_index, 2], "(....)(..)(..)(..)(..)(..)", "$1.$2.$3 $4:$5")
	;I := a_index ; Her satır döngüsü için satır değerini ayarlayın
	;LV_Add("", Result.Rows[a_index, 1], Result.Rows[a_index, 2], Result.Rows[a_index, 3], Result.Rows[a_index, 4], Result.Rows[a_index, 5], Result.Rows[a_index, 6], Result.Rows[a_index, 7]) ; show the value of row I, column a_index for table Test - you can assign to a variable instead and make use of the data, or just msgbox it to show.
	
	
	LV_Add("", Result.Rows[a_index,1],Result.Rows[a_index,2],Result.Rows[a_index,3],Result.Rows[a_index,4],Result.Rows[a_index,5],Result.Rows[a_index,6],Result.Rows[a_index,7],Result.Rows[a_index,8],Result.Rows[a_index,9],Result.Rows[a_index,10],Result.Rows[a_index,11],Result.Rows[a_index,12],Result.Rows[a_index,13],Result.Rows[a_index,14],Result.Rows[a_index,15],Result.Rows[a_index,16],Result.Rows[a_index,17],Result.Rows[a_index,18],Result.Rows[a_index,19],Result.Rows[a_index,20],Result.Rows[a_index,21],Result.Rows[a_index,22],Result.Rows[a_index,23],Result.Rows[a_index,24],Result.Rows[a_index,25],Result.Rows[a_index,26],Result.Rows[a_index,27],Result.Rows[a_index,28],Result.Rows[a_index,29],Result.Rows[a_index,30],Result.Rows[a_index,31],Result.Rows[a_index,32],Result.Rows[a_index,33],Result.Rows[a_index,34],Result.Rows[a_index,35],Result.Rows[a_index,36]) ; show the value of row I, column a_index for table Test - you can assign to a variable instead and make use of the data, or just msgbox it to show.
	
	if(renk == "0xFFFFFF")
		renk := "0xf0f2f0"
	else
		renk := "0xFFFFFF"
	
	 ;arşivde sütunun yerini her zaman tespit etmek gerekiyor
	ArsivdeSutunu(ustA_index)
	{
		Loop % LV_GetCount("Column"){
			LV_GetText(ArsivSutunu,0,a_index)
			if(ArsivSutunu == "Konumu"){
				Return a_index
			}
		}
	}
	;if(Result.Rows[a_index,ArsivdeSutunu(A_Index)] == "ARŞIVDE")
		;LVX_SetColour(A_Index, renk,"0x5ac73a") 
	;ELSE
		;LVX_SetColour(A_Index, renk) 
	
	[color=#FF0000]CLV.Row(a_index,renk,0x000000 )[/color]
}

GuiControl, +ReDraw, LVBulunanlar
;CLV.Row(1, 0x000000, 0xFFFFFF)

;CLV.AlternateRows(0xf0f2f0, 0xd0d0d) ;lv satırları zebra gibi renklendirir
;Sleep,50
Return
#If


GuiSize: ;dinamik olarka gui nesnelerini pencere boyutuna göre değiştirir
If (A_EventInfo == 1) {
	return
}
Gui, +LastFound
WinGetPos, x, y, w, h ;,Dosya Ara
GuiControl, Move, LVBulunanlar,  % "h" A_GuiHeight - 115
GuiControl, Move, LVBulunanlar,  % "w" A_GuiWidth - 10
Return


GuiKaydet: ;sütun genişliklerini ve sırasını kaydeder
FileDelete,%A_Scriptdir%\SutunGenislik ;sutungenislik ayar doısyasını siler
FileDelete,%A_Scriptdir%\SutunHizalama ;sutunsirasi ayar dosyasını siler
Sleep,500
SutunSirasi := LV_EX_GetColumnOrder(hLVItems)
For,K,V in SutunSirasi 
	sutunHizasi .= v "`r`n"
FileDelete,%A_Scriptdir%\SutunHizalama
FileAppend,% sutunHizasi, %A_Scriptdir%\SutunHizalama ;SutunHizalama
Loop % LV_GetCount("Column")
{
	SendMessage, 4125, A_Index - 1, 0, SysListView321  ; 4125 is LVM_GETCOLUMNWIDTH.
	SutunGenislikleri .= ErrorLevel "`r`n"
}
FileAppend,% SutunGenislikleri, %A_Scriptdir%\SutunGenislik ;SutunHizalama
MsgBox  Kaydedildi
return

GuiEscape:
GuiClose:
ExitApp
Return


FiltreleriKaldir:
Gui, Filtrele:Destroy
GuiControl,1:Choose,FiltrelenenMetinV,1 ;önce birinci boş satırı seçer
GuiControl,1:,FiltreOlustur,Filtre Oluştur
Return

FiltreleriUygula: ;filtreler ekranında tamam butonuna basınca
Gui, ListView,SutunlarLV
FiltreSorgulari := "" ;önce değişkeni sıfırlayalım
Loop, % LV_GetCount(){ ;döngü tüm başlıkların yanında girili kodları alır lv den
	LV_GetText(FiltreSorgulariGecici,A_Index,3)
	if(FiltreSorgulariGecici != "")
		FiltreSorgulari .= FiltreSorgulariGecici
}
;MsgBox % FiltreSorgulari
GuiControl,1:Choose,FiltrelenenMetinV,1 ;önce birinci boş satırı seçer
GuiControl,1:,FiltrelenenMetinV,% FiltreSorgulari
GuiControl,1:Choose,FiltrelenenMetinV,% FiltreSorgulari
GuiControl,1:,FiltreOlustur,*Filtre Oluştur
;burada return olmayacak kaydet butonu aynı zamanda pencereyi de gizle demek oluyor
FiltreleGuiEscape:
FiltreleGuiClose:
If DllCall("IsWindowVisible", UInt,HangiGui)	;filtreleme guisini kapatmayacak gizleyecek
	Gui, Show, Hide,HangiGui
return



FiltreOlustur: ; ana ekrandaki filtre oluştur butornu
;FiltrelenenMetinG:
If DllCall("IsWindowVisible", UInt,HangiGui){
	Gui Filtrele:Show, w720 h750, Sütunlarda Filteleme
	return
}
Gui Filtrele:New
Gui +Resize ;+AlwaysOnTop
Gui Filtrele:Add, ListView, vSutunlarLV gSutunlarG x8 y8 w360 h680 AltSubmit +Grid +LV0x4000, Sütunlar|Filtreler|SqlSorgusu
LV_ModifyCol(1,120)
LV_ModifyCol(2,2000)
LV_ModifyCol(3,0)	;sql sorgusu sütunu kullanıcıdan gizleniyor
;loop % Sutunlar.RowCount ;Ana ahk ilk yüklenince sorguyla db den sutun adlarını alyıor
for k,Sutun in TumSutunlar
	if (Sutun != "Kurum Dosya Numarası" and Sutun != "Esas No" and Sutun != "Eski Esaslar")
		LV_Add("",Sutun)
	
;Gui Filtrele:Add, ListView, vBenzersizlerLV gBenzersizlerG x216 y8 w238 h454 -ReadOnly   +Grid +LV0x4000, Filtrele
;Gui Filtrele:Add, ListView, vFiltrelerLV x8 y466 w437 h164 +Grid +LV0x4000, Uygulanan Filtreler
Gui Filtrele:Add, Text, x8 y695 w370 h680 vSatirdakiFiltrelerV,Uygulanan Filtre:
Gui Filtrele:Add, Button, x630 y720 w80 h23 gFiltreleriUygula, &Filtreleri Uygula
Gui Filtrele:Add, Button, x540 y720 w80 h23 gFiltreleriKaldir, Filtreleri Kaldır
Gui Filtrele:Show, w720 h750, Sütunlarda Filteleme
SutunAdlari :=

HangiGui := WinExist()
return



GenelLv: ;filtrelencek satırların seçilip seçim dışı bırakılmasını sağlar

If(A_GuiEvent == "I"){
	If(ErrorLevel == "C"){ ;değerleri al yeniden ekle sütunda biriktir boylece
		Gui, ListView, % DegiskenV
		LV_GetText(isaretlenenSatir, A_EventInfo,1) 	;isaretlenenSatir filtrelenecek içeriğik arşivde derdest avukat adı gibi
		Gui, ListView,SutunlarLV  			;sutun adlarının olduğu lv yi etkinleştiriyoruz
		
		LV_GetText(eskiFiltreleme,HangiSutunAdi,2)	;daha önce bir filtreleme varsa onu alır Hangisutunadı sutunlar lv sine ilk tıklanınca gelen satır numarasıdır
		LV_GetText(eskiFiltrelemeSorgu,HangiSutunAdi,3)	;daha önce bir sql sorgusuna dönüştürülmüş filtreleme varsa onu alır
		
		eskiFiltreleme .=  isaretlenenSatir " : "	;filtreler ikinci sutuna yazılsın diye surundaki eski değerlerin olduğu değişkene eklenir
		LV_Modify(DegiskenV,"",,eskiFiltreleme)	 	 ;ikinci sütuna kullanıcı ne yazmış görsün diye giriş yapar
		
		GuiControl,Filtrele:,SatirdakiFiltrelerV,% "Filtreler: "eskiFiltreleme ;Önizleme için sonuçları alttaki txtboxa girer
		
		eskiFiltrelemeSorgu .= " AND " Chr(34) FiltreYapilacakSutunAdi Chr(34) ":" Chr(34) isaretlenenSatir Chr(34)  ;sql sorgusu şeklinde üçüncü sütunda görünmeyecek şekilde saklanır
		LV_Modify(DegiskenV,"",,,eskiFiltrelemeSorgu)	 ;3. sütuna sql sorugusu olarak giriş yapar
		Gui, ListView, % DegiskenV			 ;Tekrar eski lv yi seçiyor
	}
	Else If (ErrorLevel == "c"){ ;chcxbox kaldırılırsa
		Gui, ListView, % DegiskenV
		LV_GetText(isaretlenenSatir, A_EventInfo,1) 	;isaretlenenSatir filtrelenecek içeriğik arşivde derdest avukat adı gibi sadece bu satır sağdaki lv den içerik alır
		Gui, ListView,SutunlarLV			;sutun adlarının olduğu lv yi etkinleştiriyoruz
		LV_GetText(eskiFiltreleme2,HangiSutunAdi,2)	;daha önce bir filtreleme varsa onu alır Hangisutunadı sutunlar lv sine ilk tıklanınca gelen satır numarasıdır
		LV_GetText(eskiFiltrelemeSorgu2,HangiSutunAdi,3)	;daha önce bir sql sorgusuna dönüştürülmüş filtreleme varsa onu alır
		eskiFiltreleme2 := StrReplace(eskiFiltreleme2,isaretlenenSatir " : ","") ;lv dena alınan içerikten chcboxu kaldırılan texti çıkar
		LV_Modify(DegiskenV ,"",,eskiFiltreleme2)	;replace ile eksiltmilmiş içeriği lv ye geri girer
		
		GuiControl,Filtrele:,SatirdakiFiltrelerV,% "Filtreler: "eskiFiltreleme2 ;Önizleme için sonuçları alttaki txtboxa girer
		
		eskiFiltrelemeSorgu2 := StrReplace(eskiFiltrelemeSorgu2, " AND " Chr(34) FiltreYapilacakSutunAdi Chr(34) ":" Chr(34) isaretlenenSatir Chr(34),"") ;lv dena alınan içerikten chcboxu kaldırılan sorguyu çıkar
		LV_Modify(DegiskenV ,"",,,eskiFiltrelemeSorgu2)  ;replca ile eksiltilmiş sorguyu lv ye geri girer
		Gui, ListView, % DegiskenV
	}
}

;If(A_GuiEvent = "I") AND ( InStr(ErrorLevel,"S",true) ) 
	;msgbox dfd

Return





SutunlarG:
;if (A_GuiEvent = "DoubleClick"){ ;çift tıklama yapılınca dosyayı aç
	;msgbox ff ;gosub olduğu için retrune gerek yok. dosyayı aç komutu zaten vardı ona gider
;}
If (A_GuiEvent = "I") AND ( InStr(ErrorLevel,"S",true) ) 
{	
	HangiSutunAdi := A_EventInfo  	;satır içeriğini alır bu içerikle sorgu oluşturma makrsosunda sorgu oluşturulacak
	

	
	
	For k,v  in LVler			;LV lerin hepsini gizlediğine emin olmak gerekiyor
		GuiControl,Hide,% v
	GuiControl,Hide,% DegiskenV		;çok gerekli değil döngüde gizlenmiştir ama yine de 
	
	if(A_EventInfo = LVler[A_EventInfo]){  ;önceden oluşmuşsa lv onu geri göstereir yeniden oluşturma yapılmaz çünkü işaretlenmiş satırlar kaybedilmemeli
		
		GuiControl,Show,% A_EventInfo ; degisken v ile verilen sütun adına eşittir
		DegiskenV :=  A_EventInfo 	
		Return
	}
	LVler[A_EventInfo] := A_EventInfo  	;sonradan ifle kontrol etmek için dizeye alalım 
	Gui, ListView,SutunlarLV		;soldaki sütun adlarını içeren listeyi etkinleştirir
	LV_GetText(RowText, A_EventInfo,1)	;satırdan sütun adını alır
	FiltreYapilacakSutunAdi := RowText	;sutun adını sorguda kullanmak için yedekler
	DegiskenV :=  A_EventInfo 		;lv adını değişkenV ye yedekler
	;msgbox % DegiskenV
	;MsgBox % RowText
	;Gui Filtrele:Add, ListView, vBenzersizlerLV x216 y8 w238 h454 -ReadOnly   +Grid +LV0x4000, BenzersizlerLV
	
	
	GuiControl,Hide,% DegiskenV		;buraya kadar geldiğine göre yeni lv  ekleniyor demektir mevcut lv yi gizlemek gerekiyor
	
	Gui Filtrele:Add, ListView, v%DegiskenV% gGenelLv x370 y8 w338 h680 AltSubmit -ReadOnly +Checked  +Grid +LV0x4000, % RowText ;değişken olarak adlandırlımış (soldaki sütun adları lvsindeki sütun adının sıra rakamına göre
	Gui, ListView,%DegiskenV%  		;yeni stutunu aktifleştirelim
	Sql := "SELECT DISTINCT [" RowText "] FROM Dosyalar ORDER BY [" RowText "] ASC" ;veritabanından kayıtların sdece bir örneğini al
	;MsgBox % Sql
	DB.GetTable(SQL, BenzersizKelimeler)	;Sqlden benzersiz kayıt olarak birer örnek almak içinsorgu
	;LV_Delete()
	GuiControl, -ReDraw, % DegiskenV
	Loop % BenzersizKelimeler.RowCount ;sonuçları lv ye girmek için
		Lv_Add("",BenzersizKelimeler.Rows[A_Index,1]) 
	GuiControl, +ReDraw, % DegiskenV	
	
	
	
	
	Sleep,300
	;Gui, ListView,BenzersizlerLV
	
	
	
	/*
		
		Burada yapılacaklar:
		Önce hepsi eklenmeden kontrol edilmeli tekrar seçildiği zaman aynı sütundaki filterle geri yüklenebilmeli column serach kullanılabilir
		
		
		
	*/
	
	
	
	
	
	return
}
return




























Gui, ListView,BenzersizlerLV
If !LV_GetCount("Selected"){ ;seçilen birşey yoksa
	;msgbox df
	;Return	 ; ... yapacak bir şey yok
}
Selected := [] ; seçili satırları depolamak için bir dizi
Row := 0 ; satır 0'dan başlar, yani listenin en üstünden başlar
While (Row := LV_GetNext(Row))  	; seçili satırlar bulunduğu sürece
    Selected.Insert(Row) ; dizideki tüm seçili satırları toplama
    Index := Selected.MaxIndex()    	; dizinin en büyük dizin indeksine Dizin kümesini ayarlama
While (Row := Selected[Index]) { ; Seçili[Dizin] bir satır numarası verdiği sürece
; dosya adını alma
LV_GetText(File, Row)
; sevgili dosyalarımı silmek istemiyorum
;	FileDelete, %Dir%\%File%
; delete the row
MsgBox % Row
LV_Delete(Row)
	; decrement Index, yani biz ters sırada dizi ayrıştını
    Index--
}
Selected := ""
return













WM_LBUTTONDOWN(wParam, lParam)
{
	X := lParam & 0xFFFF
	Y := lParam >> 16
	if (A_GuiControl = "BenzersizlerLV"){
		Send, {LButton Up}
		Send, {Control Down}{LButton}{Control Up}
	}
	return
	Ctrl := "`n(in control " . A_GuiControl . ")"
	ToolTip You left-clicked in Gui window #%A_Gui% at client coordinates %X%x%Y%.%Ctrl%
}

;~LButton::
OnMessage(0x201, "WM_LBUTTONDOWN")
return

;p::
Send, {Control Down}{LButton}{Control Up}
return























/*
		Title: LVX Library
		
		Row colouring and cell editing functions for KılavuzView controls.
		
		Remarks:
			Cell editing code adapted from Michas <http://www.autohotkey.com/forum/viewtopic.php?t=19929>;
			row colouring by evl <http://www.autohotkey.com/forum/viewtopic.php?t=9266>.
			Many thanks to them for providing the code base of these functions!
		
		License:
			- Version 1.04 by Titan <http://www.autohotkey.net/~Titan/#lvx>
			- zlib License <http://www.autohotkey.net/~Titan/zlib.txt>
*/

/*
		
		Function: LVX_Setup
			Initalization function for the LVX library. Must be called before all other functions.
		
		Parameters:
			name - associated variable name (or Hwnd) of KılavuzView control to setup for colouring and cell editing.
		
*/
LVX_Setup(name) {
	global lvx
	If name is xdigit
		h = %name%
	Else GuiControlGet, h, Hwnd, %name%
	VarSetCapacity(lvx, 4 + 255 * 9, 0)
	NumPut(h + 0, lvx)
	OnMessage(0x4e, "WM_NOTIFY")
	LVX_SetEditHotkeys() ; initialize default hotkeys
}

/*
		
		Function: LVX_CellEdit
			Makes the specified cell editable with an Edit control overlay.
		
		Parameters:
			r - (optional) row number (default: 1)
			c - (optional) column (default: 1)
			set - (optional) true to automatically set the cell to the new user-input value (default: true)
		
		Remarks:
			The Edit control may be slightly larger than its corresponding row,
			depending on the current font setting. 
		
*/
LVX_CellEdit(set = true) {
	global lvx, lvxb
	static i = 1, z = 48, e, h, k = "Enter|Esc|NumpadEnter"
	If i
	{
		Gui, %A_Gui%:Add, Edit, Hwndh ve Hide r1
		;make row resize to fit this height.. then back
		h += i := 0
	}
	If r < 1
		r = %A_EventInfo%
	If !LV_GetNext()
		Return
	If !(A_Gui or r)
		Return
	l := NumGet(lvx)
	SendMessage, 4135, , , , ahk_id %l% ; LVM_GETTOPINDEX
	vti = %ErrorLevel%
	VarSetCapacity(xy, 16, 0)
	ControlGetPos, bx, t, , , , ahk_id %l%
	bw = 0
	by = 0
	bpw = 0
	SendMessage, 4136, , , , ahk_id %l% ; LVM_GETCOUNTPERPAGE
	Loop, %ErrorLevel% {
		cr = %A_Index%
		NumPut(cr - 1, xy, 4), NumPut(2, xy) ; LVIR_LABEL
		SendMessage, 4152, vti + cr - 1, &xy, , ahk_id %l% ; LVM_GETSUBITEMRECT
		by := NumGet(xy, 4)
		If (LV_GetNext() - vti == cr)
			Break
	}
	by += t + 1
	cr--
	VarSetCapacity(xy, 16, 0)
	CoordMode, Mouse, Relative
	MouseGetPos, mx
	Loop, % LV_GetCount("Col") {
		cc = %A_Index%
		NumPut(cc - 1, xy, 4), NumPut(2, xy) ; LVIR_LABEL
		SendMessage, 4152, cr, &xy, , ahk_id %l% ; LVM_GETSUBITEMRECT
		bx += bw := NumGet(xy, 8) - NumGet(xy, 0)
		If !bpw
			bpw := NumGet(xy, 0)
		If (mx <= bx)
			Break
	}
	bx -= bw - bpw - 2
	LV_GetText(t, cr + 1, cc)
	GuiControl, , e, %t%
	ControlMove, , bx, by, bw, , ahk_id %h%
	GuiControl, Show, e
	GuiControl, Focus, e
	VarSetCapacity(g, z, 0)
	NumPut(z, g)
	LVX_SetEditHotkeys(~1, h)
	Loop {
		DllCall("GetGUIThreadInfo", "UInt", 0, "Str", g)
		If (lvxb or NumGet(g, 12) != h)
			Break
		Sleep, 100
	}
	GuiControlGet, t, , e
	If (set and lvxb != 2)
		LVX_SetText(t, cr + 1, cc)
	GuiControl, Hide, e
	Return, lvxb == 2 ? "" : t
}

/*
		
		Function: LVX_SetText
			Set the text of a specified cell.
		
		Parameters:
			text - new text content of cell
			row - (optional) row number
			col - (optional) column number
		 
*/
LVX_SetText(text, row = 1, col = 1) {
	global lvx
	l := NumGet(lvx)
	row--
	VarSetCapacity(d, 60, 0)
	SendMessage, 4141, row, &d, , ahk_id %l%  ; LVM_GETITEMTEXT
	NumPut(col - 1, d, 8)
	NumPut(&text, d, 20)
	SendMessage, 4142, row, &d, , ahk_id %l% ; LVM_SETITEMTEXT
}

/*
		
		Function: LVX_SetEditHotkeys
			Change accept/cancel hotkeys in cell editing mode.
		
		Parameters:
			enter - comma seperated list of hotkey names/modifiers that will save
				the current input text and close editing mode
			esc - same as above but will ignore text entry (i.e. to cancel)
		
		Remarks:
			The default hotkeys are Enter and Esc (Escape) respectively,
				and such will be used if either parameter is blank or omitted.
		 
*/
LVX_SetEditHotkeys(enter = "Enter,NumpadEnter", esc = "Esc") {
	global lvx, lvxb
	static h1, h0
	If (enter == ~1) {
		If esc > 0
		{
			lvxb = 0
			Hotkey, IfWinNotActive, ahk_id %esc%
		}
		Loop, Parse, h1, `,
			Hotkey, %A_LoopField%, _lvxb
		Loop, Parse, h0, `,
			Hotkey, %A_LoopField%, _lvxc
		Hotkey, IfWinActive
		Return
	}
	If enter !=
		h1 = %enter%
	If esc !=
		h0 = %esc%
}

_lvxc: ; these labels are for internal use:
lvxb++
_lvxb:
lvxb++
LVX_SetEditHotkeys(~1, -1)
Return

/*
		
		Function: LVX_SetColour
			Set the background and/or text colour of a specific row on a KılavuzView control.
		
		Parameters:
			index - row index (1-based)
			back - (optional) background row colour, must be hex code in RGB format (default: 0xffffff)
			text - (optional) similar to above, except for font colour (default: 0x000000)
		
		Remarks:
			Sorting will not affect coloured rows. 
		 
*/
LVX_SetColour(index, back = 0xffffff, text = 0x000000) {
	global lvx
	a := (index - 1) * 9 + 5
	NumPut(LVX_RevBGR(text) + 0, lvx, a)
	If !back
		back = 0x010101 ; since we can't use null
	NumPut(LVX_RevBGR(back) + 0, lvx, a + 4)
	h := NumGet(lvx)
	WinSet, Redraw, , ahk_id %h%
}

/*
		
		Function: LVX_RevBGR
			Helper function for internal use. Converts RGB to BGR.
		
		Parameters:
			i - BGR hex code
		
*/
LVX_RevBGR(i) {
	Return, (i & 0xff) << 16 | (i & 0xffff) >> 8 << 8 | i >> 16
}

/*
		Function: LVX_Notify
			Handler for WM_NOTIFY events on KılavuzView controls. Do not use this function.
*/
LVX_Notify(wParam, lParam, msg) {
	global lvx
	If (NumGet(lParam + 0) == NumGet(lvx) and NumGet(lParam + 8, 0, "Int") == -12) {
		st := NumGet(lParam + 12)
		If st = 1
			Return, 0x20
		Else If (st == 0x10001) {
			a := NumGet(lParam + 36) * 9 + 9
			If NumGet(lvx, a)
      	NumPut(NumGet(lvx, a - 4), lParam + 48), NumPut(NumGet(lvx, a), lParam + 52)
		}
	}
}

WM_NOTIFY(wParam, lParam, msg, hwnd) {
	; if you have your own WM_NOTIFY function you will need to merge the following three lines:
	global lvx
	If (NumGet(lParam + 0) == NumGet(lvx))
		Return, LVX_Notify(wParam, lParam, msg)
}
User avatar
Chunjee
Posts: 1400
Joined: 18 Apr 2014, 19:05
Contact:

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

12 Nov 2019, 20:56

I too had crashing issues with an app that used this class. I may not have been using it 100% correctly because I needed to sort and color rows.

I never solved it.
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

23 Dec 2019, 15:47

I found a thread from the old forum with code to change the font weight (and maybe also other font characteristics such as italic, underline, strikethrough) of individual rows in a GUI ListView.
https://autohotkey.com/board/topic/17007-change-font-weight-in-listview-row-using-customdraw/
It would be very useful to have that features also in the LV_Colors class.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

27 Jun 2020, 13:27

I'm having a lot of crashes on Windows 10 64 bits. Is everybody like this?
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

01 Jul 2020, 10:30

What do you mean with "crashes"? Some of the issues described in the comments at the top of the script?
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

01 Jul 2020, 13:48

just me wrote:
01 Jul 2020, 10:30
What do you mean with "crashes"? Some of the issues described in the comments at the top of the script?
The whole GUI freezes. I have to end the application.

I'm trying the old version of LV_Colors now. No crash yet.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

02 Jul 2020, 03:51

Class_LV_Colors.ahk wrote:

Code: Select all

; ...
; To avoid the loss of Gui events and messages the message handler might need to be set 'critical'. This can be
; achieved by setting the instance property 'Critical' to the required value (e.g. MyInstance.Critical := 100).
; New instances default to 'Critical, Off'. Though sometimes needed, ListViews or the whole Gui may become
; unresponsive under certain circumstances if Critical is set and the ListView has a g-label.
; ...
Did you try it?
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

28 Dec 2020, 11:17

Is it possible to add transparency to the cells/rows? because selecting a row removes the colors of the entire row until selection is on another row or out of focus.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: charlie89, gwarble and 130 guests