|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: |
(*---------------------------------------------------*)
function CustomSortProc(Node1, Node2: TTreeNode; Data: Integer): Integer; stdcall;
begin
if Node1.ImageIndex<>Node2.ImageIndex Then
begin
if Node1.ImageIndex=Item_Image_Index Then Result:=-1 Else Result:=1;
end Else
Result:=AnsiCompareText(Node1.Text, Node2.Text);
end;
(*---------------------------------------------------*)
function TMainForm.FindNode(ni: integer): TTreeNode;
Var
i:integer;
begin
With treeview1 do for i := 0 to Items.Count - 1 do if ni=Integer(Items[i].Data) then
begin
Result:=Items[i];
Exit;
end;
Result:=nil;
end;
(*---------------------------------------------------*)
procedure TMainForm.FormCreate(Sender: TObject);
var
I: Integer;
SOToken: ISpeechObjectToken;
SOTokens: ISpeechObjectTokens;
begin
DBPath := IncludeTrailingPathDelimiter(ExtractFilePath(Application.Exename));
DBName := 'dbtree.pkr';
Caption :='Untitled - IT Knowledgebase';
PageControl1.ActivePage := Tabsheet1;
OpenDatabase;
end;
(*---------------------------------------------------*)
procedure TMainForm.FormDestroy(Sender: TObject);
var
I: Integer;
begin
AdoTable1.First;
for I := 0 to cbVoices.Items.Count - 1 do
ISpeechObjectToken(Pointer(cbVoices.Items.Objects[I]))._Release;
end;
(*---------------------------------------------------*)
procedure TMainForm.LoadTree;
Var
i:integer;
n,n2:TTreeNode;
begin
ADOTable1.First;
With TreeView1 do
begin
Items.BeginUpdate;
Items.Clear;
while Not ADOTable1.Eof do
begin
n2:=FindNode(ADOTable1Parent.Value);
n:=Items.AddChild(n2,ADOTable1Name.Value);
n.ImageIndex:=ADOTable1Image_Index.Value;
if n.ImageIndex = FolderClose_Image_Index
Then n.SelectedIndex:=FolderOpen_Image_Index
Else n.SelectedIndex:=n.ImageIndex;
n.Data:=Pointer(ADOTable1ID.Value);
ADOTable1.Next;
end;
for i:=0 to Items.Count-1 do Items[i].Expand(True);
CustomSort(@CustomSortProc, 0);
Items.EndUpdate;
end;
With TreeView1 do if Items.Count>0 Then Selected:=Items[0];
end;
(*---------------------------------------------------*)
procedure TMainForm.New1Click(Sender: TObject);
begin
Caption :='Untitled - IT Knowledgebase';
DBPath := IncludeTrailingPathDelimiter(ExtractFilePath(Application.Exename));
DBName := 'dbtree.pkr';
OpenDatabase;
end;
(*---------------------------------------------------*)
procedure TMainForm.NewFolder1Click(Sender: TObject);
Var
n,n2:TTreeNode;
NewText:String;
begin
if (TreeView1.Selected<>nil) And (TreeView1.Selected.ImageIndex = Item_Image_Index ) Then Exit;
NewText:=InputBox('New Folder','Folder Name','');
if NewText='' Then Exit;
n2:=TreeView1.Selected;
n:=TreeView1.Items.AddChild(n2,NewText);
n.ImageIndex:=FolderClose_Image_Index;
n.SelectedIndex:=FolderOpen_Image_Index;
TreeView1.Selected:=nil;
ADOTable1.Insert;
ADOTable1Status.Value:=0;
ADOTable1Name.Value:=n.Text;
ADOTable1Image_Index.Value:=FolderClose_Image_Index;
if Assigned(n2)
Then ADOTable1Parent.Value:=Integer(n2.Data)
Else ADOTable1Parent.Value:=0;
ADoTable1.Post;
n.Data:=Pointer(ADOTable1ID.Value);
TreeView1.Selected:=n;
if n.Parent=nil
Then TreeView1.CustomSort(@CustomSortProc, 0,False)
Else n.Parent.CustomSort(@CustomSortProc, 0,False);
end;
(*---------------------------------------------------*)
procedure TMainForm.NewItem1Click(Sender: TObject);
Var
n,n2:TTreeNode;
NewText:String;
begin
if (TreeView1.Selected=nil) Or (TreeView1.Selected.ImageIndex <> FolderClose_Image_Index) Then Exit;
NewText:=InputBox('New Item','Item Name','');
if NewText='' Then Exit;
n2:=TreeView1.Selected;
n:=TreeView1.Items.AddChild(n2,NewText);
n.ImageIndex:=Item_Image_Index;
n.SelectedIndex:=Item_Image_Index;
TreeView1.Selected:=nil;
ADOTable1.Insert;
ADOTable1Status.Value:=0;
ADOTable1Name.Value:=n.Text;
ADOTable1Image_Index.Value:=Item_Image_Index;
if Assigned(n2)
Then ADOTable1Parent.Value:=Integer(n2.Data)
Else ADOTable1Parent.Value:=0;
ADoTable1.Post;
n.Data:=Pointer(ADOTable1ID.Value);
TreeView1.Selected:=n;
if n.Parent=nil
Then TreeView1.CustomSort(@CustomSortProc, 0,False)
Else n.Parent.CustomSort(@CustomSortProc, 0,False);
end;
(*---------------------------------------------------*)
procedure TMainForm.Open1Click(Sender: TObject);
var
sFileName: String;
begin
OpenDialog1.InitialDir := DBPath;
if OpenDialog1.Execute then
begin
DBName := ExtractFileName(OpenDialog1.FileName);
DBPath := ExtractFilePath(OpenDialog1.FileName);
sFileName := OpenDialog1.FileName;
MainForm.Caption := ExtractFileName(OpenDialog1.FileName) + ' - ' + 'IT Knowledgebase';
updateRecent(sFileName);
OpenDatabase;
end;
end;
(*---------------------------------------------------*)
procedure TMainForm.OpenDatabase;
var
conn_str:string;
begin
conn_str :=
Format('provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=%s%s;',
[IncludeTrailingPathDelimiter(DBPath), DBName]);
ADOConnection1.Connected := False;
ADOConnection1.ConnectionString := conn_str;
ADOConnection1.Connected := True;
ADOTable1.Open;
LoadTree;
end;
(*---------------------------------------------------*)
procedure TMainForm.TreeView1Change(Sender: TObject; Node: TTreeNode);
Var
V:Variant;
e:Boolean;
begin
if Assigned(TreeView1.Selected) then
begin
V:=Integer(TreeView1.Selected.Data);
if V>0 then ADOTable1.Locate('ID',V,[]);
e:=TreeView1.Selected.ImageIndex=Item_Image_Index;
end Else e:=False;
DbRichEdit1.Enabled:=e;
DbRichEdit2.Enabled:=e;
end;
(*---------------------------------------------------*)
procedure TMainForm.TreeView1Editing(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean);
begin
AllowEdit := Node.Parent <> nil;
end;
(*---------------------------------------------------*)
|
Advertisement
| Hall of Fame |