Probleme bei Icons



  • Auf die Idee bin ich auch schon gekommen, hat aber nichts gebracht.



  • Iconer schrieb:

    Ich will das Icon bevor ich das Programm gestartet habe sehen, also statt diesem Fenster möchte ich das Icon...

    Hi

    Wenn ich mich mal so einschalten darf: Wann willst du jetzt das Icon genau sehen? Als Symbol für deine Exe-Datei im Explorer oder als Symbol für dein Fenster (in der Taskbar und in der linken oberen Ecke deines Fensters)?

    So, wie ich das verstehe, willst du, dass das Icon im Explorer als Symbol für dein Programm angezeigt wird. Also wie jetzt?



  • Sry wenn das unverständlich war: Im Explorer



  • Dann ist das mit dem SetClassLong und so hinlänglich 🤡

    Martin Richter schrieb:

    Wie ich geschrieben habe, das Icon mit der niedrigsten ID bzw. das erste Icon das in der EXE gefunden wird, wird auch im Explorer verwendet.

    Irgendwas kann dann in deiner Resourcen-Datei nicht stimmen. Müsste so aussehen:

    ID_ICON_MAIN ICON DISCARDABLE "Data\\MeinIcon.ico"
    

    Der String sollte deinem (relativen oder totalen) Dateipfad für die Icon-Datei entsprechen. IC_ICON_MAIN durch deine Icon-ID oder eine Zahl ersetzen. Das "ICON" ist wichtig!

    Diese Syntax funktioniert so sicherlich nicht bei jedem Compiler. Also sag mal bitte, was du für einen Compiler hast und deinen Code in der Resourcen-Datei.



  • *hust*Resourcen-Datei? Geht das nicht anders? Es gibt 2 Gründe warum ich die nicht mag:
    1: Ich finde die Blöd 🙂
    2: nur Gott (und ein paar Auserwählt) wissen, wie man die beim Borland Compiler (nicht bei der IDE, sondern beim BCC) einbindet



  • Also nicht, dass ihr denkt, dass ich zu faul bin das zu suchen. Aber ich habe einiges probiert, aber das war alles irgendwo nicht funktionstüchtig.


  • Mod

    CodeFinder schrieb:

    Martin Richter schrieb:

    Indem nan z.B. SetIcon verwendet um dies währen der Laufzeit zu machen.
    Ansonsten wird für ein Programm das erste Icon mit der niedrigsten ID im Explorer angezeigt, wenn es sich nicht um eine registrierte Komponente handelt.

    SetIcon ist IMHO MFC...Das WinApi-Pendant ist SetClassLong.

    Nein! SetIcon ist nur ein MFC Wrapper für WM_SETICON. SetClassLong für das Icon ist ein ganz anderer Ansatz und beeinflusst alle Fenster einer Klasse. WM_SETICON beeinflusst nur dieses Fenster und kann dynamisch verwendet werden.


  • Mod

    Iconer schrieb:

    *hust*Resourcen-Datei? Geht das nicht anders? Es gibt 2 Gründe warum ich die nicht mag:
    1: Ich finde die Blöd 🙂
    2: nur Gott (und ein paar Auserwählt) wissen, wie man die beim Borland Compiler (nicht bei der IDE, sondern beim BCC) einbindet

    Blöd finden ist dämlich und wenn es nur Gott weiß... tja dann solltest Du es vielleicht mit Beten probieren... ich mache das jedenfalls regelmässig... zu den Auserwählten habe ich auch nie gehört, denn ich habe Borland Produkte immer gemieden wie die Pest.
    SCNR

    Zur Sache:
    Es geht nicht anders. Du musst das Icon als Ressource einbinden wiel der Explorer eben genau die entsprechende Resource aus der EXE lädt.
    Nach anderem brauchst Du gar nicht zu suchem.



  • Martin Richter schrieb:

    Nein! SetIcon ist nur ein MFC Wrapper für WM_SETICON. SetClassLong für das Icon ist ein ganz anderer Ansatz und beeinflusst alle Fenster einer Klasse. WM_SETICON beeinflusst nur dieses Fenster und kann dynamisch verwendet werden.

    Hm k, k, (wie ich schon sagte: IMHO), aber du solltest im WinAPI-Subforum vllt auch WinAPI-Snippets posten 😉 .



  • Aber du hast das Icon schon als Resource eingebunden, oder? Wenn nicht, kann Windows das Icon nicht als Symbol für dein Programm anzeigen! Das Icon muss sich dafür nämlich in der Exe befinden! Windows muss ja das Icon anzeigen können, ohne das Programm zu starten. MS hat deshalb halt festgelegt, dass das Icon als ICON-Resource in der Exe-Datei eingebunden sein muss!

    Greets, Badestrand


  • Mod

    [quote="CodeFinderHm k, k, (wie ich schon sagte: IMHO), aber du solltest im WinAPI-Subforum vllt auch WinAPI-Snippets posten 😉 .[/quote]

    Uppps... Sorry! Ich habe beim hin herspringen zwischen den Foren das gar nicht gemerkt. Werde mich bessern... 🕶



  • mein problem ist ja eben nur, da ich nicht weiß wie ich eine rc-Datei in den Borlanc C Compiler einbinden soll...wie gesagt habe noch nichts gefunden was wirklich funktioniert



  • @Iconer

    Die .rc-Datei kannst Du nicht einbinden. Wenn Du eine IDE hast, kannst Du die .rc-Datei "zum Proojekt hinzufügen", wie das geht, hängt von der IDE ab. Bei einem Kommandozeilencompiler mußt Du die .rc-Datei mit dem Resourcen-Compiler kompilieren (ERgebnis ist eine .res-Datei). Danach wird die .res-Datei mit der .obj-Datei (aus dem Quelltext kompiliert) verlinkt.

    Normalerweise gibt es für alle Borland-Kompiler auch eine IDE. Für Bcc 5.5 frei Haus im Internet. Mal googeln. 🙂



  • Ich benutze prinzipiell keine IDE's, deshalb...weißt du wie ich die res-Datei mit der obj-Datei verlinken muss?



  • Iconer schrieb:

    Ich benutze prinzipiell keine IDE's, deshalb

    Warum nicht? Kann vieles erleichtern. Vor allem- bei einer guten IDE ist auch ein Resourcen-Builder dabei. Da kann man den ganzen Kram graphisch erstellen.
    Und für den Notfall hat jede IDE auch einen beigepackten Kommandozeilencompiler.

    ...weißt du wie ich die res-Datei mit der obj-Datei verlinken muss?

    Nein. Ich habe halt eine IDE, die macht das ganz von alleine, weil alles in der Projekt-Datei steht. 😃 😉

    Normalerweise geht das mit Zeilen wie

    bclink quelltext.obj resourcen.res Zieldatei.exe
    

    oder so ähnlich. Hängt auch vom Linker ab.



  • ich benutze zwar MVC++ aber nur für das Highlithing.
    Mit dem verlinken werde ich mal probiern.

    Weißt du wo ich einen Resourcen-Compiler herbekomme, oder sollte der beim Borland C Compiler schon dabei sein?



  • Ein Resourcen-Compiler sollte bei jedem guten Compiler-Paket dabeiliegen, wenn das Paket für Windows-GUI-Progs geeignet sein soll. Bei bc5.5 ist er dabei. Bei VCExpress auch (sinnigerweise hat VCExpress keinen Resourcenbuilder). Such mal nach Dateinamen wie "bcres.exe" oder "bres.exe" oder ähnliche.

    Ansonsten empfehle ich DEV-C++. Ist eine IDE mit allem Drum und Dran.

    Korrektur: Ich arbeite mit Borland C++5.02. Da heißt der Resourcen-Compiler brc.exe oder brcc.exe
    Ich nehme an, daß bei Borlandc++ 5.02 und BorlandC++ 5.5 die Kommandozeilen-Anwendungen die gleichen sind (ist aber nur eine Vermutung).



  • ok danke, ich werde das versuchen.



  • ich habe es jetzt geschafft eine .res datei zu erstellen, allerdings klappt es mit dem verlinken nicht, und in der hilfe sehe ich auch nicht durch. hier mal das was die hilfe zum linker sagt:

    The linker syntax controls how the linkers work. Linker command-line options are case-sensitive.
    The linkers can also use a configuration file called ILINK32.CFG for options that you'd normally type at the command-line.
    
    Syntax
    
    ILINK32 [@respfile][options] startup myobjs, [exe], [mapfile], [libraries], [deffile], [resfile]
    
    [@respfile]	A response file is an ASCII file that lists linker options and file names that you would normally type at the command line. By placing options and files names in a response file, you can save the amount of keystrokes you need to type to link your application.
    
    [options]	Linker options that control how the linker works. For example, options specify whether to produce an .EXE or a DLL file. Linker options must be preceded by either a slash (/) or a hyphen (-).
    startup	A Borland initialization module for executables or DLLs that arranges the order of the various segments of the program. Failure to link in the correct initialization module usually results in a long list of error messages telling you that certain identifiers are unresolved, or that no stack has been created.
    
    myobjs	The .OBJ files you want linked. Specify the path if the files aren't in the current directory. (The linker appends an .OBJ extensions if no extension is present.)
    [exe]	The name you want given to the executable file ( .EXE, or .DLL). If you don't specify an executable file name, ILINK32 derives the name of the executable by appending .EXE or .DLL to the first object file name listed. (The linker assumes or appends an .EXE extensions for executable files if no extension is present. It also assumes or appends a .DLL extension for dynamic link libraries if no extension is present.)
    
    [mapfile]	Is the name you want given to the map file. If you don't specify a name, the map file name is given the same as exefile (but with the .MAP extension). (The linker appends a .MAP extensions if no extension is present.)
    [libraries]	The library files you want included at link time. Do not use commas to separate the libraries listed. If a file is not in the current directory or the search path (see the /L option) then you must include the path in the link statement. (The linker appends a .LIB extension if no extension is present.)
    
    The order in which you list the libraries is very important; be sure to use the order defined in this list:
    	 Code Guard libraries (if needed)
    	 List any of your own user libraries, noting that if a function is defined more than once, the linker uses the first definition encountered
    	 IMPORT32.LIB (if you’re creating an executable that uses the Windows API)
    	 Math libraries
    	 Runtime libraries 
    [deffile]	The module definition file for a Windows executable. If you don't specify a module definition (.DEF) file and you have used the /Twe
     or /Twd option, the linker creates an application based on default settings. (The linker appends a .DEF extension if no extension is present.)
    
    [resfile]	A list of .RES files (compiled resource files) to bind to the executable. (The linker appends an .RES extension if no extension is present.)
    


  • Hat den niemand eine Idee, wie ich das machen muss? Ich probiere jetzt schon 2h rum, aber es klappt einfach nicht!


Anmelden zum Antworten