diff options
author | Alexey Kulakov <panda75@bk.ru> | 2014-01-22 17:42:42 +0000 |
---|---|---|
committer | Alexey Kulakov <panda75@bk.ru> | 2014-01-22 17:42:42 +0000 |
commit | d139e286676c7fa67ed208e69f2ee9dc22e2f614 (patch) | |
tree | aa3d8ab63b2593573df9ff8077249c06eaf5e02c /plugins/QuickSearch/sr_window.pas | |
parent | dde622d64e2c3ef843c70971b4f108189f19195f (diff) |
QuickSearch: bug of column menu fixed
git-svn-id: http://svn.miranda-ng.org/main/trunk@7828 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/QuickSearch/sr_window.pas')
-rw-r--r-- | plugins/QuickSearch/sr_window.pas | 76 |
1 files changed, 35 insertions, 41 deletions
diff --git a/plugins/QuickSearch/sr_window.pas b/plugins/QuickSearch/sr_window.pas index 64aef6a95d..2c25cf9fd1 100644 --- a/plugins/QuickSearch/sr_window.pas +++ b/plugins/QuickSearch/sr_window.pas @@ -1010,11 +1010,30 @@ begin end;
end;
+procedure addcolumn(num:integer;column:pcolumnitem);
+var
+ lvcol:LV_COLUMNW;
+ hdi:THDITEM;
+begin
+ zeromemory(@lvcol,sizeof(lvcol));
+ lvcol.mask :=LVCF_TEXT or LVCF_WIDTH;
+ lvcol.pszText :=TranslateW(column.title);
+ lvcol.cx :=column.width;
+ SendMessageW(grid,LVM_INSERTCOLUMNW,num,lparam(@lvcol));
+
+ // set checkbox in column header
+ hdi.mask:=HDI_FORMAT;
+ if (column.flags and COL_FILTER)<>0 then
+ hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX or HDF_CHECKED
+ else
+ hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX;
+ SendMessage(ListView_GetHeader(grid),HDM_SETITEM,num,tlparam(@hdi));
+end;
+
procedure MakeColumnMenu;
var
column:pcolumnitem;
menu:HMENU;
- lvcol:LV_COLUMNW;
pt:TPOINT;
flag,id,i,j:integer;
begin
@@ -1031,13 +1050,14 @@ begin end;
GetCursorPos(pt);
id:=integer(TrackPopupMenu(menu,TPM_RETURNCMD+TPM_NONOTIFY,pt.x,pt.y,0,mainwnd,nil));
- if id>100 then
+ if id>=100 then
begin
dec(id,100);
column:=@qsopt.columns[id];
- column.flags:=column.flags xor COL_ON;
- if (column.flags and COL_ON)<>0 then
+ // show column
+ if (column.flags and COL_ON)=0 then
begin
+ column.flags:=column.flags or COL_ON;
// memory
if (column.flags and COL_INIT)=0 then
begin
@@ -1049,29 +1069,27 @@ begin end;
// screen
i:=ColumnToListView(id);
- zeromemory(@lvcol,sizeof(lvcol));
- lvcol.mask :=LVCF_TEXT or LVCF_WIDTH;
- lvcol.pszText :=TranslateW(column.title);
- lvcol.cx :=column.width;
- //!!
- SendMessageW(grid,LVM_INSERTCOLUMNW,i,tlparam(@lvcol));
+ addcolumn(i,column);
// fill new column
FillLVColumn(id,i);
end
else
+ // hide column
begin
j:=0;
+
for i:=0 to qsopt.numcolumns-1 do
begin
if (qsopt.columns[i].flags and COL_ON)<>0 then
inc(j);
end;
- // keep at least one visible column
- if j>1 then
- SendMessage(grid,LVM_DELETECOLUMN,ColumnToListView(id),0)
- else
- column.flags:=column.flags or COL_ON;
+ // keep at least one visible column (1 + this)
+ if j>2 then
+ begin
+ SendMessage(grid,LVM_DELETECOLUMN,ColumnToListView(id),0);
+ column.flags:=column.flags and not COL_ON;
+ end;
end;
end;
DestroyMenu(menu);
@@ -1625,29 +1643,16 @@ begin qsopt.columns[num].flags:=flags;
end;
end;
-{
-procedure addcolumn(handle:hwnd;num,width:integer;title:PWideChar);
-var
- lvcol:LV_COLUMNW;
-begin
- zeromemory(@lvcol,sizeof(lvcol));
- lvcol.mask :=LVCF_TEXT or LVCF_WIDTH;
- lvcol.pszText :=title;
- lvcol.cx :=width;
- SendMessageW(handle,LVM_INSERTCOLUMNW,num,lparam(@lvcol));
-end;
-}
+
// Set columns and clear listview
procedure PrepareTable(reset:boolean=false);
var
lvcol:LV_COLUMNW;
hdi:THDITEM;
- header:HWND;
i:integer;
old:integer;
begin
SendMessage(grid,LVM_DELETEALLITEMS,0,0);
- header:=ListView_GetHeader(grid);
zeromemory(@hdi,sizeof(hdi));
hdi.mask:=HDI_FORMAT;
@@ -1662,18 +1667,7 @@ begin begin
if (flags and COL_ON)<>0 then
begin
- lvcol.pszText:=TranslateW(title);
- lvcol.cx :=width;
- SendMessageW(grid,LVM_INSERTCOLUMNW,tablecolumns,tlparam(@lvcol));
-// addcolumn(grid,tablecolumns,width,TranslateW(title));
-
- // set checkbox in column header
- if (flags and COL_FILTER)<>0 then
- hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX or HDF_CHECKED
- else
- hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX;
- SendMessage(header,HDM_SETITEM,tablecolumns,tlparam(@hdi));
-
+ addcolumn(tablecolumns,@qsopt.columns[i]);
inc(tablecolumns);
end;
|