- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to associate an icon with a console app, to get rid of that awful default icon?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. Create an icon file (e.g. hello.ico) in which there should be a 32x32 pixel icon and a 16x16 one. You can use any icon editor to do it, but I normally use the one that came with Visual Studio.
2. Create a resource file (e.g. hello.rc) containing only one line:
0 ICON hello.ico
Now, if you are using the IDE, simply insert the hello.rc file into the project and rebuilt. If you are using the command line, you need to:
3. compile the resource file by: rc -r hello.rc to create hello.res
4. link your files with hello.res: DF hello.f90 hello.res
The icon will be shown in the Explorer and when the program is run outside the IDE. When the program is executed in the IDE, the "awful default" icon will still be used.
HTH,
Greg Chien
http://protodesign-inc.com
2. Create a resource file (e.g. hello.rc) containing only one line:
0 ICON hello.ico
Now, if you are using the IDE, simply insert the hello.rc file into the project and rebuilt. If you are using the command line, you need to:
3. compile the resource file by: rc -r hello.rc to create hello.res
4. link your files with hello.res: DF hello.f90 hello.res
The icon will be shown in the Explorer and when the program is run outside the IDE. When the program is executed in the IDE, the "awful default" icon will still be used.
HTH,
Greg Chien
http://protodesign-inc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to replace the 'awful default' icon in the console app's title bar also, you can use the method described in this past post with a few minor changes. Something like this would do:
hth,
John
! ... integer :: hWnd, hIcon, hr include 'resource.fd' hWnd = 0 hWnd = GetForegroundWindow() hIcon = 0; hr = 0 hIcon = LoadImage(GetModuleHandle(%val(0)), %val(MAKEINTRESOURCE(IDI_ICON1)), IMAGE_ICON, & GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); if(hIcon /= 0) then hr = SendMessage(hWnd, WM_SETICON, ICON_SMALL, hIcon); end if
hth,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, fun, it worked perfectly. Thank you!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page