Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2005.10.16;
Скачать: [xml.tar.bz2];

Вниз

problems with KOL Pmenu Submenus   Найти похожие ветки 

 
rofl   (2005-02-14 03:07) [0]

i have a problem with a popupmenu; i want it to expand like folder structure on hard drive. the function i use works recursive, but suddenly the pointer to parentmenu is $FEEEFEEE and i get an exception when executing pmenu.insert. i am using KOL 2.0

this is my code:

var
 popmenu: Pmenu;

     function PathMatchSpecA(pszFile, pszSpec: String): Boolean; StdCall; External 'SHLWAPI.DLL';

...

function FileSearch(const sRoot, sFileEXT: String; const strRecursive: Boolean):string;
const vardel = #13#10;
var WFD: TWin32FindData; hFile: THandle;
begin
 result := '';
 hFile := FindFirstFileA(pchar(sRoot + '*'), WFD);
 while FindNextFileA(hFile, WFD) do

   if (WFD.dwFileAttributes and 16) = 16 then
   begin
      if sFileEXT = ' ' then result := result + sRoot + String(WFD.cFileName) + vardel;
      (if strRecursive then if Copy(String(WFD.cFileName),1,1)  '.' then
      FileSearch(sRoot + String(WFD.cFileName) + '\', sFileEXT, True))
   end
      else if PathMatchSpecA(String(WFD.cFileName), sFileEXT) then
      result := result + sRoot + String(WFD.cFileName) + vardel;

 FindClose(hFile);
 if strRecursive then strSearch := strSearch + Result;
end;

procedure tform1.addSubSubMenu(var parentmenu:pointer;fld:string;posi:integer);
var s : string;
   i : integer;
   curloc: integer;
   opt: TMenuOptions;
   t:pmenu;
begin
  if (copy(fld,length(fld),1) = '.') or (copy(fld,length(fld)-1,2) = '..') then exit;
  if fld[length(fld)]  '\' then fld := fld + '\';
  inc(nosubmenus);
  setlength(submenus,Nosubmenus+1);
  if nosubmenus = 2 then exit;
  i:=0;
  curloc := 0;
// check if subdirs exist;
  s := filesearch(fld,' ',false);
// cut away . and .. dirs
  while pos('.'#13#10,s)  0 do
   s:= copy(s,pos('.'#13#10,s)+3,length(s));
// if subfolders then opt = submenu
  if s  '' then opt := [moSubMenu]
   else
  opt := [moDefault];
//   if pointer(parentmenu) = pointer(popmenu) then curloc := sublocs+1;
  t := parentmenu;
  submenus[nosubmenus] := t.Insert(posi,pchar(fld),TOnMenuItem( MakeMethod( nil, @DoPopUpItem )),opt);
//   testlist.Add(fld);
  while pos(#13#10,s)  0 do
  begin
     //recursive if more subfolders
     addsubsubmenu(pointer(submenus[nosubmenus]),copy(s,1,pos(#13#10,s)-1),i);
     s := copy(s,pos(#13#10,s)+2,length(s));
     inc(i);
  end;
end;

procedure tform1.addNewSubMenu(fld:pchar);
var s : string;
i : integer;
begin
  inc(sublocs);
  addsubsubmenu(pointer(popmenu),string(fld),sublocs+1);
end;

// START via i.e. addNewSubMenu('c:\windows');


 
rofl   (2005-02-14 03:20) [1]

var submenus: array of pmenu;


 
rofl   (2005-02-14 08:33) [2]

found the bug, the routine tried to add a submenu to MoDefault Menus. o0



Страницы: 1 вся ветка

Форум: "KOL";
Текущий архив: 2005.10.16;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.038 c
14-1127590552
KilkennyCat
2005-09-24 23:35
2005.10.16
Предлагаю всем соседям по куоомуналке, родственничкам и


2-1126206634
Пантелеев Иван
2005-09-08 23:10
2005.10.16
Заставка перед запуском программы


2-1126686038
JTAG
2005-09-14 12:20
2005.10.16
Про tray


3-1125509304
Турист
2005-08-31 21:28
2005.10.16
ADO - возможность использования clUseServer в CursorLocation


2-1125575312
Русланка
2005-09-01 15:48
2005.10.16
Вопрос по потокам





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский