Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 2 3 4 5 6 7 8 9 |
There is also undocumented function SetConsoleIcon ''' <summary>Sets console icon</summary> ''' <param name="hicon">Handle of icon (<see cref="Icon.Handle"/>)</param> ''' <returns>True of succes, false on error</returns> ''' <remarks>This function is undocumented</remarks> Public Declare Function SetConsoleIcon Lib "Kernel32.dll" (ByVal hicon As IntPtr) As Boolean * http://support.microsoft.com/kb/124103 describes how to get handle of console window. |
Quellcode |
|
1 2 3 4 5 6 7 8 9 |
There is also undocumented function SetConsoleIcon ''' <summary>Sets console icon</summary> ''' <param name="hicon">Handle of icon (<see cref="Icon.Handle"/>)</param> ''' <returns>True of succes, false on error</returns> ''' <remarks>This function is undocumented</remarks> Public Declare Function SetConsoleIcon Lib "Kernel32.dll" (ByVal hicon As IntPtr) As Boolean * http://support.microsoft.com/kb/124103 describes how to get handle of console window. |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <iostream> using namespace std; #include <windows.h> #pragma comment (lib, "kernel32.lib") #include <icon.ico> // Icon einbinden? bool SetConsoleIcon (HICON hIcon); // Funktionsprototyp int main () { SetConsoleIcon ("Icon.ico"); // Funktionsaufruf cin.get (); return 0; } |
Zitat von »"FLO2"«
Wie bekomme ich ein Handle auf mein Icon?
Zitat von »"FLO2"«
Und muss ich das Icon irgendwie einbinden?
Zitat von »"FLO2"«
Dieser Code funktioniert jedenfalls nicht :cry: :
C-/C++-Quelltext
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #include <iostream> using namespace std; #include <windows.h> #pragma comment (lib, "kernel32.lib") #include <icon.ico> // Icon einbinden? bool SetConsoleIcon (HICON hIcon); // Funktionsprototyp int main () { SetConsoleIcon ("Icon.ico"); // Funktionsaufruf cin.get (); return 0; }
Danke im Voraus!
C-/C++-Quelltext |
|
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 |
typedef BOOL ( WINAPI *SetConsoleIcon_t )( HICON handle ); SetConsoleIcon_t SetConsoleIcon; BOOL WINAPI SetConsoleIconDefault( HICON handle ) { return TRUE; } int main() { HMODULE hDll = LoadLibrary( _T( "kernel32" ) ); if ( hDll ) { SetConsoleIcon = ( SetConsoleIcon_t )GetProcAddress( hDll, "SetConsoleIcon" ); FreeLibrary( hDll ); } else { SetConsoleIcon = &SetConsoleIconDefault; } HICON hIcon = ( HICON )LoadImage( NULL, _T( "foo.ico" ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); if ( hIcon ) { SetConsoleIcon( hIcon ); } } |
Werbeanzeige