![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
неприодалимый глюк погите разобраться в VCL
koha! © (2008-10-21 04:40:00)Описание глюка: Есть на форме ListView у него свойства "anhors" akLeft=true, akRight=true, akTop=true, akBottom=true; то есть компонент должен растягиваться во всю вместе с формой, но этого не происходит, то он растянется, то нет, повисает и при чем основательно,
http://webfile.ru/2329861- выглядит это так, еще может вообще свернуться в комок или маленькое окошечко 100х100 пиксел где-то, по ни понятным мне причинам.
Как этот глюк преодолеть? Писано на ВDS2006.
koha! (2008-10-21 13:18:00) [21]Всем... только пожалуйста не смейтесь над кодом я не профессионал...
koha! (2008-10-21 13:11:00) [22]
> <Цитата>
>
>
> Сергей М. © (21.10.08 13:00) [22]
> > конечно же пишу с ошибкамиТак в этом здесь никто и не
> сомневается)> как только добавляю в него чего-нитьбудьКомбобоксы,
> например ?
Вот процедурки прорисовки комбо-боксов
{------------------------------- ListItemIsVisible ----------------------------}
function TMainFrm.ListItemIsVisible(LV: TListView; Index: integer): boolean;
begin
Result:=(LV.TopItem.Index <= Index) and
(Index <= (LV.TopItem.Index + SendMessage(LV.Handle, LVM_GETCOUNTPERPAGE, 0, 0)));
end;
{----------------------------- LVCustomDraw -----------------------------------}
procedure TMainFrm.LVCustomDraw(Sender: TCustomListView; const ARect: TRect;
var DefaultDraw: Boolean);
Var
i,j: integer;
SubItem: integer;
Rect: TRect;
begin
//ndDebugMsg('TMainFrm.LVCustomDraw ');
if LV.Items.Count = 0 then Exit;
for i:=0 to LV.Items.Count -1 do begin
if ListItemIsVisible(LV, i) then begin
//SendDebugMsg('ListItemIsVisible(LV,'+ IntToStr(i)+') = true');
Rect := LV.Items[i].DisplayRect(drBounds);
SubItem := 4;
for j:=0 to SubItem-1 do Inc(Rect.Left,LV.Columns[j].Width);
Rect.Right:=Rect.Left+LV.Columns[SubItem].Width;
With TComboBox(CmBoxList.Items[i]) do begin
if ComboBoxIsDisplayChenge(CmBoxList.Items[i],Rect) then begin
Left := Rect.Left+5;
Width := (Rect.Right-Rect.Left)-10;
Top := Rect.Top;
end;
end;
if Not TComboBox(CmBoxList.Items[i]).Visible then
TComboBox(CmBoxList.Items[i]).Visible:=true;
end
else begin
//SendDebugMsg('ListItemIsVisible(LV,'+ IntToStr(i)+') = false');
if TComboBox(CmBoxList.Items[i]).Visible then
TComboBox(CmBoxList.Items[i]).Visible:=false;
end;
end;
end;
{------------------------------ CustomDrawItem --------------------------------}
procedure TMainFrm.LVCustomDrawItem(Sender: TCustomListView; Item: TListItem;
State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if (Item.Index mod 2) = 0 then sender.canvas.brush.Color := clInfoBk
//Tcolor($FCCDB1)//TColor($F3DECB)//TColor($F3FFE6) //clInfoBk
else sender.canvas.brush.Color := clCream;
//Tcolor($AF8E50)//TColor($FCCDB1)//TColor($D1FEB4)//clInfoBk;//clwhite;
end;
koha! (2008-10-21 13:06:00) [23]
> Johnmen © (21.10.08 12:34) [19]
> > но как только добавляю в него чего-нитьбудьКак добавляешь?
>
Думал, что ответить..... как то так:
unit Unit1;
//.............................................
implementation
procedure TMainFrm.Act_AddFolderExecute(Sender: TObject);
Var
ChosenDirectory: String;
Options: TSelectDirExtOpts;
NewItem: TListItem;
NameDir: String;
i: integer;
begin
Options:=[sdNewUI,sdShowShares];
if Not SelectDirectory('','',ChosenDirectory, Options, Nil) then Exit;
if ChosenDirectory = '' then Exit;
SendDebugMsg(ChosenDirectory);
for i:=0 to LV.Items.Count-1 do
if CompStr(LV.Items[i].SubItems[0], ChosenDirectory) then Exit;
if ChosenDirectory[Length(ChosenDirectory)] = '\' then NameDir:=ChosenDirectory
else NameDir:=ExtractFileName(ChosenDirectory);
CmBoxAddList(AddItemNew(NameDir, ChosenDirectory, SmalImgList.AddIcon(IcnFolder)),0);
end;
procedure TMainFrm.Act_AddToArchiveExecute(Sender: TObject);
var
i: integer;
icn: TIcon;
Name: String;
begin
try
ListPathName := TStringList.Create;
Icn := TIcon.Create;
for i:=0 to Pred(LV.Items.Count) do ListPathName.Add(LV.Items[i].SubItems[0]);
With FrmAddDlg do begin
edAddFolder.Text := '';
edPathArchive.Text := '';
edPathArchive.Text := '';
CbBoxRepository.Text := '';
CbBoxRepository.Items.Text := ListDir.Text;
LBoxFiles.Clear;
ShowModal;
end;
finally
Icn.Free;
ListPathName.Free;
end;
end;
procedure TMainFrm.Act_Add_FilesExecute(Sender: TObject);
Var
Icn: TIcon;
i,c: integer;
NewItem: TListItem;
List: TStrings;
HI: THandle;
IcnIndex: Word;
begin
OpenDlg.Options := [ofHideReadOnly,ofNoChangeDir,ofAllowMultiSelect,ofEnableSizing];
OpenDlg.Filter := 'All files (*.*)|*.*';
OpenDlg.InitialDir:='C:\Downloads\NEW_SOFT'; //.................
if Not OpenDlg.Execute Then Exit;
try
IcnIndex := 1;
List := TStringList.Create;
if LV.Items.Count <> 0 then
for i:=1 to LV.Items.Count-1 do List.Add(LV.Items[i].SubItems[0]);
Icn:=TIcon.Create;
LV.Items.BeginUpdate;
for i:=0 to OpenDlg.Files.Count -1 do begin
if List.IndexOf(OpenDlg.Files[i]) <> -1 then Continue;
Icn.Handle:=ExtractAssociatedIcon(HInstance,PChar(OpenDlg.Files[i]),IcnIndex);
if NOt Icn.HandleAllocated Then MainImgList.GetIcon(0,icn);
CmBoxAddList(AddItemNew(ExtractFileName(OpenDlg.Files[i]), OpenDlg.Files[i], SmalImgList.AddIcon(Icn)),0);
end;
LV.Items.EndUpdate;
finally
Icn.Free;
List.Free;
end;
end;
{------------------------------ Act_LoadListExecute --------------------------}
procedure TMainFrm.Act_LoadListExecute(Sender: TObject);
var
Fstrm : TFileStream;
i, SizeType : integer;
PItmCnfg : PItemConfig;
NewItem : TListItem;
Icn : TIcon;
IcnIndex : Word;
begin
if Not OpenDlg.Execute then Exit;
try
try
Fstrm:=TFileStream.Create(OpenDlg.FileName, fmOpenRead);
if Fstrm.Size = 0 then Exit;
Icn := TIcon.Create;
ClearAllList;
SizeType:=SizeOf(TItemConfig);
if (Fstrm.Size mod SizeType) <> 0 then begin
ShowMessage('Error: no size type.');
exit;
end;
LV.Items.BeginUpdate;
for i:=0 to Pred((Fstrm.Size div SizeType)) do begin
New(PItmCnfg);
FillChar(PItmCnfg^,SizeType, 0);
Fstrm.Read(PItmCnfg^,SizeType);
ListConfig.Add(PItmCnfg);
NewItem := LV.Items.Add;
With NewItem do begin
Caption := PItmCnfg^.Name;
SubItems.Add(PItmCnfg^.FilePath);
SubItems.Add(PItmCnfg^.ArchivePath);
SubItems.Add(PwdN);
IcnIndex := 1;
Case TFileType(PItmCnfg^.FType) of
FT_FOLDER: NewItem.ImageIndex:=SmalImgList.AddIcon(IcnFolder);
FT_FILE :
Begin
Icn.Handle := ExtractAssociatedIcon(HInstance,PChar(LV.Items[i].SubItems[0]),IcnIndex);
if Not Icn.HandleAllocated Then MainImgList.GetIcon(0,Icn);
NewItem.ImageIndex := SmalImgList.AddIcon(Icn);
end;
End;
end;
CmBoxAddList(i,Integer(TArchiveType(PItmCnfg^.ArchiveType)));
end;
LV.Items.EndUpdate;
finally
Icn.Free;
Fstrm.Free;
end;
except
Exit;
end;
end;
function TMainFrm.AddItemNew(Name, Path: String; IcnIndex: Integer): integer;
Var
NewItem : TListItem;
NewItemConf : PItemConfig;
begin
NewItem := LV.Items.Add;
NewItem.Caption := Name;
NewItem.Checked := false;
NewItem.ImageIndex := IcnIndex;
NewItem.SubItems.Add(Path); //File Name Full Path
NewItem.SubItems.Add(''); //Archive Path
NewItem.SubItems.Add(PwdN); //Password
NewItem.SubItems.Add(IntToStr(NewItem.Index));
Result := NewItem.Index;
New(NewItemConf);
FillChar(NewItemConf^, SizeOf(TitemConfig), 0);
NewItemConf.Name := Name;
NewItemConf.FilePath := Path;
ListConfig.Add(NewItemConf);
end;
procedure TMainFrm.ClearAllList;
var
i: integer;
begin
if ListConfig.Count = 0 then exit;
for i:=0 to Pred(ListConfig.Count) do Dispose(ListConfig.Items[i]);
ListConfig.Clear;
LV.Clear;
SmalImgList.Clear;
end;
procedure TMainFrm.CmBoxAddList(index, ItmIndex: integer);
begin
//R:=NewItem.DisplayRect(drBounds);
//for c:=0 to 3 do Inc(R.Left,LV.Columns[c].Width);
//R.Right:=R.Left+LV.Columns[3].Width;
CmBoxList.Add(TComboBox.Create(Owner));
With TComboBox(CmBoxList.Items[index]) do begin
//NewItem.Data:=TComboBox.Create(Owner);
//With TComboBox(NewItem.Data) do begin
Parent := LV;
Style := csDropDown;
Font.Size := 7;
Font.Style := [fsBold];
Font.Color := clNavy;
Height := 19;
Items.Text := 'RAR'+#10+'7ZIP'+#10+'ZIP';
text := 'FREE_'+IntToStr(Index);
OnClick := ComboBoxOnClick;
Tag := index;
ItemIndex := ItmIndex;
Visible := False;
end;
end;
procedure TMainFrm.ComboBoxOnClick(Sender: TObject);
begin
SendDebugMsg('ComboBoxOnClick');
With PItemConfig(ListConfig.Items[TComboBox(Sender).Tag])^ do begin
Case TComboBox(Sender).ItemIndex of
0: ArchiveType := AT_RAR;
1: ArchiveType := AT_ZIP;
3: ArchiveType := AT_7ZIP;
end;
end;
end;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
CurDir := ExtractFileDir(Application.ExeName);
CurPath := ExtractFilePath(Application.ExeName);
Archivator := 'Rar.exe';
CmBoxList := Tlist.Create;
IcnFolder := Ticon.Create;
ListConfig := TList.Create;
ListDir := TStringList.Create;
IcnFolder.Handle := GetDirectoryIcon;
if FileExists(CurPath+'DirList.lst') then ListDir.LoadFromFile(CurPath+'DirList.lst');
if Not IcnFolder.HandleAllocated then MainImgList.GetIcon(1,IcnFolder);
RegLoadConfiguration;
end;
end.
Сергей М. (2008-10-21 13:00:00) [24]
> конечно же пишу с ошибками
Так в этом здесь никто и не сомневается)
> как только добавляю в него чего-нитьбудь
Комбобоксы, например ?
Ega23 (2008-10-21 12:36:00) [25]
> как написано в проекте - это не главная часть самолета,
> главное функционал, что бы работало правильно и без глюков.
Не скажи, проект с семантической модели надо начинать.
koha! (2008-10-21 12:34:00) [26]
> Сергей М. © (21.10.08 12:19) [16]
вот блин, вам и ассоциации корабли с ПО уже путают...
я конечно же пишу с ошибками, но у меня есть знакомая она профессиональный журналист газеты "N" и после как все будет готово я ее даю на проверку и она мои ляпы все исправляет, а сейчас мне пофигу, как написано в проекте - это не главная часть самолета, главное функционал, что бы работало правильно и без глюков.
Johnmen (2008-10-21 12:34:00) [27]
> но как только добавляю в него чего-нитьбудь
Как добавляешь?
clickmaker (2008-10-21 12:25:00) [28]> Специально так и назвал, так прикольней.
надо было "манагер"
koha! (2008-10-21 12:24:00) [29]Когда пустой ListView, то ничего вне подвисает нормально растягивается, но как только добавляю в него чего-нитьбудь, то подвисает, до тех пор пока скролбоксом не двинешь. затема расправляется
Сергей М. (2008-10-21 12:19:00) [30]
> Специально так и назвал
Как корабль назовешь, так он и поплывет.. Якорем .. Ко дну)...
Johnmen (2008-10-21 12:19:00) [31]
> Специально так и назвал, так прикольней.
Archve Path тоже прикольно...
> Ega23 © (21.10.08 12:13) [12]
> А якоря свои дурацкие убрал?
Якоря автоматом устанавливаются в Тру, когда делаем алКлиент...
koha! (2008-10-21 12:18:00) [32]
> Ega23 © (21.10.08 12:13) [12]
> > Так же глючит в со свойством Align = alClient.А якоря
> свои дурацкие убрал?
да...
Сергей М. (2008-10-21 12:17:00) [33]
> Johnmen © (21.10.08 11:05) [9]
Мда)..
> koha! (21.10.08 12:08) [10]
Т.е. ты утверждаешь , что на форме имеенно компонент TListView и никакой иной ?
И кроме этого контрола в кл.области окна формы нет ни единого контрола ?
Ega23 (2008-10-21 12:13:00) [34]
> Так же глючит в со свойством Align = alClient.
А якоря свои дурацкие убрал?
koha! (2008-10-21 12:12:00) [35]
> Johnmen © (21.10.08 11:05) [9]
> Веселое слово "Menager" :)))
Специально так и назвал, так прикольней.
koha! (2008-10-21 12:08:00) [36]Сделал как предлагал > Ega23 © (21.10.08 10:23) [5], но результат тот же.
Так же глючит в со свойством Align = alClient.
http://webfile.ru/2330395
Johnmen (2008-10-21 11:05:00) [37]Веселое слово "Menager" :)))
Сергей М. (2008-10-21 10:52:00) [38]
> koha! (21.10.08 10:25) [6]
Вот как узнаешь, так сразу и приходи
Ega23 (2008-10-21 10:49:00) [39]
> - пока точно сам не знаю, что будет, все пока в разработке
Я себе это твое название записал. В мемориз. Никогда ещё более дебильного определения "других контролов" не встречал.
koha! (2008-10-21 10:25:00) [40]
>"другие VCL" (надо записать название.
> ..)
- пока точно сам не знаю, что будет, все пока в разработке