Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

More about setting a console icon

reidar
New User
379 Views

I found an example how this can be done (thanks Rob!) and I found it interesting and copied the small amount of code to create a subroutine as shown below:

Subroutine SetIcon
    
USE IFWINA, ONLY : LRESULT, fWPARAM, HANDLE , NULL, GetModuleHandle, LoadIcon, &
            GetConsoleWindow, SendMessage, WM_SETICON, ICON_BIG, ICON_SMALL
  IMPLICIT none
!
  INTEGER(KIND=HANDLE)  :: hInstance, hConsole, hIcon
  INTEGER(KIND=LRESULT) :: result
!
  hInstance = GetModuleHandle(NULL)
  hIcon     = LoadIcon(hInstance, "MY_ICON"//CHAR(0))
!
  hConsole = GetConsoleWindow()
  hConsole = GetStdHandle
  result = SendMessage(hConsole, WM_SETICON, INT(ICON_SMALL,KIND=fWPARAM), hIcon)
  result = SendMessage(hConsole, WM_SETICON, INT(ICON_BIG,KIND=fWPARAM),   hIcon)
  
  return
  end

When compiling, I got the following errors as shown below:

Compiling with Intel(R) Visual Fortran Compiler XE 14.0.4.237 [IA-32]...

SetIcon_console.f90

ifort: command line warning #10212: /fp:precise evaluates in source precision with Fortran.

C:\IVF-Fortan\TVA51-4A -May2016\TVA51-4A-2016\SetIcon_console.f90(6): error #6580: Name in only-list does not exist. [GETCONSOLEWINDOW]

C:\IVF-Fortan\TVA51-4A -May2016\TVA51-4A-2016\SetIcon_console.f90(16): error #6404: This name does not have a type, and must have an explicit type. [GETSTDHANDLE]

compilation aborted for C:\IVF-Fortan\TVA51-4A -May2016\TVA51-4A-2016\SetIcon_console.f90 (code 1)

Is the explanation that these missing function are not available in XE 14 ?

 

0 Kudos
1 Reply
Steve_Lionel
Honored Contributor III
379 Views

I'm not sure why you get the error about GetConsoleWindow, but it's possible that name wasn't defined in the 14.0 API modules, though that would astonish me. You have two assignments in sequence to hConsole. The second one, if you wanted it, is incorrect. GetStdHandle is a function that takes one argument, the identifier of the standard handle you want. Nevertheless, I don't thing GetStdHandle is appropriate to use here.

If you need to add a declaration to GetConsoleWindow it is easy:

interface
function GetConsoleWindow()
use ifwinty
integer(HANDLE) :: GetConsoleWindow
!DEC$ ATTRIBUTES STDCALL, DECORATE, NAME="GetConsoleWindow" :: GetConsoleWindow
end function GetConsoleWindow
end interface

 

0 Kudos
Reply