![]() |
Re: Eigenes Favoriten-Menü
Sorry, bin nicht so gut in Delphi. Woher weiss ich, was das Handle des aufrufenden Fensters ist?
|
Re: Eigenes Favoriten-Menü
Es ist das Handle deines Formulars. Rufst du die Funktion aus einer Methode auf, dann schrieb einfach nur "Handle". Rufst du aus einer Prozedur auf, dann muss der Formularname davor stehen, also z.B. "Form1.Handle"
|
Re: Eigenes Favoriten-Menü
AAAhhh :idea: THX !
|
Re: Eigenes Favoriten-Menü
Zitat:
|
Re: Eigenes Favoriten-Menü
Liste der Anhänge anzeigen (Anzahl: 1)
Noch ne Kleinigkeit. Ich wollte die Favs anstatt in MainMenu in einem PopupMeun anzeigen lassen. Habe den Code von #8 wiefolgt angepasst
Delphi-Quellcode:
Nur kommt folgendes raus (siehe Bild), also er kopiert alle Seiten und Ordner in das Item "Favs1". Ich will aber, dass er die Einträge (Seiten und Ordner) direkt als Items in meinem PopupMenu ("Fav") erstellt. Problem ist, dass PopupMenu ("Fav") Kein Item ist. Er braucht aber ein Parent vom typ TMenuItem in dieser Zeile
{.$DEFINE TINIFILE}
procedure TForm1.OnURLMenuItemClick(Sender: TObject); begin if(Sender is TMenuItem) and ((Sender as TMenuItem).Hint <> '') then ShellExecute(self.Handle,'open',pchar((Sender as TMenuItem).Hint), nil,nil,SW_SHOWNORMAL); end; procedure TForm1.LoadLocalFavorites; procedure scanit(const orgPath: string; parentMI: TMenuItem); var path : string; res : integer; ds : TSearchRec; mii : TMenuItem; {$IFDEF TINIFILE} ini : TIniFile; {$ENDIF} begin path := GetCurrentDir; // zuerst alle Ordner, weil das Einträge für // Untermenüs werden res := FindFirst('*.*',faAnyFile,ds); while(res = 0) do begin if(ds.Attr and faDirectory <> 0) and (ds.Attr and faHidden = 0) and ((ds.Name <> '.') and (ds.Name <> '..')) then begin mii := TMenuItem.Create(parentMI); mii.Caption := ds.Name; // rein ins Menü parentMI.Add(mii); if(SetCurrentDir(ds.Name)) then scanit(orgPath,mii); end; res := FindNext(ds); Application.ProcessMessages; end; FindClose(ds); // und jetzt alle URL-Dateien suchen res := FindFirst('*.url',faAnyFile,ds); while(res = 0) do begin if(ds.Name <> '.') and (ds.Name <> '..') and (ds.Attr and faDirectory = 0) then begin mii := TMenuItem.Create(parentMI); mii.Caption := ChangeFileExt(ds.Name,''); {$IFDEF TINIFILE} ini := TIniFile.Create(path + '\' + ds.Name); if(ini <> nil) then try mii.Hint := ini.ReadString('InternetShortcut','URL',''); finally ini.Free; end; {$ELSE} mii.Hint := '"' + path + '\' + ds.Name + '"'; {$ENDIF} mii.ImageIndex := 11; mii.OnClick := OnURLMenuItemClick; // ab ins Menü damit if(mii.Hint <> '') and (mii.Caption <> '') then parentMI.Add(mii); end; res := FindNext(ds); Application.ProcessMessages; end; FindClose(ds); // und wieder einen Ordner nach oben if(path <> orgPath) then ChDir('..'); end; var cDummy, xPath : string; begin // aktuelles Verzeichnis ermitteln cDummy := GetCurrentDir; // Favoritenordner des aktuellen Benutzers // ermitteln, ... xPath := GetSpecialFolder(Handle, CSIDL_FAVORITES); // ... & scannen if(xPath <> '') and (SetCurrentDir(xPath)) then scanit(xPath,[b]Favs1[/b]); // du kannst auch noch die Favoriten für // alle Benutzer anhängen, wenn du nach // "CSIDL_COMMON_FAVORITES" suchst end; function tform1.GetSpecialFolder(hWindow: HWND; Folder: Integer): String; var pMalloc: IMalloc; pidl: PItemIDList; Path: PChar; begin // get IMalloc interface pointer if (SHGetMalloc(pMalloc) <> S_OK) then begin MessageBox(hWindow, 'Couldn''t get pointer to IMalloc interface.', 'SHGetMalloc(pMalloc)', 16); Exit; end; // retrieve path SHGetSpecialFolderLocation(hWindow, Folder, pidl); GetMem(Path, MAX_PATH); SHGetPathFromIDList(pidl, Path); Result := Path; FreeMem(Path); // free memory allocated by SHGetSpecialFolderLocation pMalloc.Free(pidl); end;
Delphi-Quellcode:
Was muss man ändern? Ich habe da kein Überblick mehr :wall:
procedure scanit(const orgPath: string; [b]parentMI: TMenuItem[/b]);
|
Re: Eigenes Favoriten-Menü
Frage zur folgender Stelle:
Delphi-Quellcode:
Mit diesem Code öffnet mein Programm den Internet Explorer (, also den Standartbroser von Windoof). Was muss man da ändern, damit er den link "xy" im programm selbst im TWebBrowser öffnet?
procedure TForm1.OnURLMenuItemClick(Sender: TObject);
begin if(Sender is TMenuItem) and ((Sender as TMenuItem).Hint <> '') then ShellExecute(self.Handle,'open',pchar((Sender as TMenuItem).Hint), nil,nil,SW_SHOWNORMAL); end; Und so nebenbei. Weiss vielleicht jemand, wie man eigenen Browser zum Standartbroser von Windoof macht? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz