<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Print a BMP-file using Intel Fortran in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783398#M28862</link>
    <description>&lt;P&gt;Thanks for the reply, but I have still problem with DrawIconEx. The attached program gives the following response.&lt;/P&gt;&lt;P&gt;ICON = -1778055127&lt;/P&gt;&lt;P&gt;ires = 0&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;/Hkan&lt;/P&gt;&lt;P&gt; program PrintImage&lt;/P&gt;&lt;P&gt; USE gdi32&lt;BR /&gt; USE comdlg32&lt;BR /&gt; USE IFWIN&lt;BR /&gt;CC USE IFQWIN&lt;/P&gt;&lt;P&gt; integer*4 :: hDCPrn ! Handle for printer DC.&lt;BR /&gt; integer*4 :: cxPage, cyPage ! Size of page printed area.&lt;BR /&gt; integer*4 :: cPage ! minimum dimension of page.&lt;BR /&gt; real*8 :: pwfract ! Fraction of page width to use for printed image&lt;BR /&gt; character*40 :: DocName&lt;BR /&gt; type (T_DOCINFO) :: di ! DOCINFO structure.&lt;BR /&gt; type (T_PRINTDLG) :: pd ! Print Dialog structure&lt;BR /&gt;!***************************************************************************&lt;/P&gt;&lt;P&gt;! Initialise PRINTDLG structure.&lt;/P&gt;&lt;P&gt; pd.lStructSize = SIZEOF(pd)&lt;BR /&gt; pd.hwndOwner = hWnd&lt;BR /&gt; pd.Flags = PD_RETURNDC .OR. PD_NOPAGENUMS.OR.PD_NOSELECTION .OR. PD_PRINTSETUP &lt;BR /&gt; pd.nFromPage = 1 ! not appear. &lt;BR /&gt; pd.nToPage = 1&lt;BR /&gt; pd.nMinPage = 1&lt;BR /&gt; pd.nMaxPage = 1&lt;BR /&gt; pd.nCopies = 1&lt;BR /&gt; pd.hInstance = NULL&lt;BR /&gt; pd.lpfnSetupHook = NULL&lt;BR /&gt; pd.lpSetupTemplateName = NULL&lt;BR /&gt; pd.lpfnPrintHook = NULL&lt;BR /&gt; pd.lpPrintTemplateName = NULL&lt;/P&gt;&lt;P&gt; retlog=PrintDlg(pd)&lt;BR /&gt;!&lt;BR /&gt;! Get handle to the device context for PRINTDLG Structure.&lt;BR /&gt;!&lt;BR /&gt; hdcPrn = pd.hDC&lt;/P&gt;&lt;P&gt; ihoriz=GetDeviceCaps(pD%hDc, PHYSICALWIDTH)&lt;BR /&gt; ivert=GetDeviceCaps(pD%hDc, PHYSICALHEIGHT)&lt;/P&gt;&lt;P&gt;!***********************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! Set DocInfo data.&lt;BR /&gt;!&lt;BR /&gt; DocName = 'Your title here'C&lt;BR /&gt; di.cbSize = sizeof(di)&lt;BR /&gt; di.lpszDocName = loc(DocName)&lt;BR /&gt; di.lpszOutput = NULL&lt;BR /&gt; di.lpszDatatype = NULL&lt;BR /&gt; di.fwType = NULL&lt;BR /&gt;!&lt;BR /&gt;! Get size of printable area of page.&lt;BR /&gt;!&lt;BR /&gt; cxPage = GetDeviceCaps(hdcPrn, HORZRES)&lt;BR /&gt; cyPage = GetDeviceCaps(hdcPrn, VERTRES)&lt;BR /&gt;!&lt;BR /&gt;! select a fraction of the minimum page dimension to &lt;BR /&gt;! which the plot will be scaled.., default this to 3/4&lt;BR /&gt; pwfract=0.75&lt;BR /&gt; cpage=min(cxpage, cypage)*pwfract&lt;BR /&gt;!***********************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! Prepare to plot to the printer.&lt;BR /&gt;!&lt;BR /&gt; retint = StartDoc(hdcPrn, di)&lt;BR /&gt; retint = StartPage(hdcPrn)&lt;BR /&gt;!&lt;BR /&gt; retint=SetMapMode(hdcPrn, MM_TEXT)&lt;BR /&gt;! &lt;BR /&gt; retlog=SetViewPortExtEx(hdcPrn,ihoriz, ivert, NULL)&lt;BR /&gt; &lt;BR /&gt;!***********************************************************************************&lt;/P&gt;&lt;P&gt; ICON = LoadImage( NULL, 'HELLO.BMP'C, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE )&lt;BR /&gt; write(*,*) ' ICON = ',ICON&lt;/P&gt;&lt;P&gt; ires = DrawIconEx( hdcPrn, 10, 10, ICON, 0, 0, 0, NULL, DI_NORMAL )&lt;BR /&gt; write(*,*) ' ires = ',ires&lt;/P&gt;&lt;P&gt; retint = EndPage(hDCPrn)&lt;BR /&gt; retint = EndDoc(hDCprn) &lt;BR /&gt;! Release the printer resources&lt;BR /&gt; retlog = DeleteDC(hDCprn)&lt;/P&gt;&lt;P&gt; end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Mar 2012 15:02:24 GMT</pubDate>
    <dc:creator>H_2</dc:creator>
    <dc:date>2012-03-30T15:02:24Z</dc:date>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783396#M28860</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have tried to print a BMP-file on printer using DrawIconEx , without any success. &lt;BR /&gt;The source code has the following style.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;USE IFWIN&lt;BR /&gt;ICON = LoadImage( 0, 'RP.BMP'C, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE )&lt;BR /&gt;ires = DrawIconEx( ihDC, 10, 10, ICON, 0, 0, 0, NULL, DI_NORMAL )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The return value from DrawIconEx is zero and nothing is printed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have ideas how to solve this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hkan&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2012 08:12:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783396#M28860</guid>
      <dc:creator>H_2</dc:creator>
      <dc:date>2012-03-28T08:12:56Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783397#M28861</link>
      <description>Ok, so where is all the code where you generate a handle to a printer device context (which has to go in place of your 'ihDC')? Is ihDC a handle to a valid device context? Because that is where the 'drawing' takes place.&lt;BR /&gt;Where is the code for Initialising a PrintDialog structure? e.g.&lt;BR /&gt;&lt;BR /&gt;!&lt;BR /&gt;! Print Dialog stuff...&lt;BR /&gt;!&lt;BR /&gt;integer*4 :: hDCPrn ! Handle for printer DC.&lt;BR /&gt;integer*4 :: cxPage, cyPage ! Size of page printed area.&lt;BR /&gt;integer*4 :: cPage    ! minimum dimension of page.&lt;BR /&gt;real*8   :: pwfract    ! Fraction of page width to use for printed image&lt;BR /&gt;character*40  :: DocName&lt;BR /&gt;type (T_DOCINFO) :: di ! DOCINFO structure.&lt;BR /&gt;type (T_PRINTDLG) :: pd     ! Print Dialog structure&lt;BR /&gt;!***************************************************************************&lt;BR /&gt;.....&lt;BR /&gt;....&lt;BR /&gt;! Initialise PRINTDLG structure.&lt;BR /&gt;!&lt;BR /&gt;   pd.lStructSize = SIZEOF(pd)&lt;BR /&gt;   pd.hwndOwner = hWnd&lt;BR /&gt;   pd.Flags = PD_RETURNDC .OR. PD_NOPAGENUMS .OR. &amp;amp;&lt;BR /&gt;          PD_NOSELECTION .OR. PD_PRINTSETUP &lt;BR /&gt;   pd.nFromPage = 1 ! not appear. &lt;BR /&gt;   pd.nToPage = 1&lt;BR /&gt;   pd.nMinPage = 1&lt;BR /&gt;   pd.nMaxPage = 1&lt;BR /&gt;   pd.nCopies = 1&lt;BR /&gt;   pd.hInstance = NULL&lt;BR /&gt;   pd.lpfnSetupHook = NULL&lt;BR /&gt;   pd.lpSetupTemplateName = NULL&lt;BR /&gt;   pd.lpfnPrintHook = NULL&lt;BR /&gt;   pd.lpPrintTemplateName = NULL&lt;BR /&gt;&lt;BR /&gt;   retlog=PrintDlg(pd)&lt;BR /&gt;!&lt;BR /&gt;! Get handle to the device context for PRINTDLG Structure.&lt;BR /&gt;!&lt;BR /&gt;   hdcPrn = pd.hDC&lt;BR /&gt;&lt;BR /&gt;   ihoriz=GetDeviceCaps(pD%hDc, PHYSICALWIDTH)&lt;BR /&gt;   ivert=GetDeviceCaps(pD%hDc, PHYSICALHEIGHT)&lt;BR /&gt;&lt;BR /&gt;!***********************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! Set DocInfo data.&lt;BR /&gt;!&lt;BR /&gt;   DocName = 'Your title here'C&lt;BR /&gt;   di.cbSize = sizeof(di)&lt;BR /&gt;   di.lpszDocName = loc(DocName)&lt;BR /&gt;   di.lpszOutput = NULL&lt;BR /&gt;   di.lpszDatatype = NULL&lt;BR /&gt;   di.fwType = NULL&lt;BR /&gt;!&lt;BR /&gt;! Get size of printable area of page.&lt;BR /&gt;!&lt;BR /&gt;   cxPage = GetDeviceCaps(hdcPrn, HORZRES)&lt;BR /&gt;   cyPage = GetDeviceCaps(hdcPrn, VERTRES)&lt;BR /&gt;!&lt;BR /&gt;! select a fraction of the minimum page dimension to &lt;BR /&gt;! which the plot will be scaled.., default this to 3/4&lt;BR /&gt;   pwfract=0.75&lt;BR /&gt;   cpage=min(cxpage, cypage)*pwfract&lt;BR /&gt;!***********************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! Prepare to plot to the printer.&lt;BR /&gt;!&lt;BR /&gt;   retint = StartDoc(hdcPrn, di)&lt;BR /&gt;   retint = StartPage(hdcPrn)&lt;BR /&gt;!&lt;BR /&gt;   retint=SetMapMode(hdcPrn, MM_TEXT)&lt;BR /&gt;! &lt;BR /&gt;   retlog=SetViewPortExtEx(hdcPrn,ihoriz, ivert, PXY)&lt;BR /&gt;!***********************************************************************************&lt;BR /&gt;&lt;BR /&gt;[add your drawing code here to drawon hdcPrn]&lt;BR /&gt;...&lt;BR /&gt;retint = EndPage(hDCPrn)&lt;BR /&gt;retint = EndDoc(hDCprn) &lt;BR /&gt;! Release the printer resources&lt;BR /&gt;   retlog = DeleteDC(hDCprn)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Mar 2012 10:43:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783397#M28861</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2012-03-28T10:43:09Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783398#M28862</link>
      <description>&lt;P&gt;Thanks for the reply, but I have still problem with DrawIconEx. The attached program gives the following response.&lt;/P&gt;&lt;P&gt;ICON = -1778055127&lt;/P&gt;&lt;P&gt;ires = 0&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;/Hkan&lt;/P&gt;&lt;P&gt; program PrintImage&lt;/P&gt;&lt;P&gt; USE gdi32&lt;BR /&gt; USE comdlg32&lt;BR /&gt; USE IFWIN&lt;BR /&gt;CC USE IFQWIN&lt;/P&gt;&lt;P&gt; integer*4 :: hDCPrn ! Handle for printer DC.&lt;BR /&gt; integer*4 :: cxPage, cyPage ! Size of page printed area.&lt;BR /&gt; integer*4 :: cPage ! minimum dimension of page.&lt;BR /&gt; real*8 :: pwfract ! Fraction of page width to use for printed image&lt;BR /&gt; character*40 :: DocName&lt;BR /&gt; type (T_DOCINFO) :: di ! DOCINFO structure.&lt;BR /&gt; type (T_PRINTDLG) :: pd ! Print Dialog structure&lt;BR /&gt;!***************************************************************************&lt;/P&gt;&lt;P&gt;! Initialise PRINTDLG structure.&lt;/P&gt;&lt;P&gt; pd.lStructSize = SIZEOF(pd)&lt;BR /&gt; pd.hwndOwner = hWnd&lt;BR /&gt; pd.Flags = PD_RETURNDC .OR. PD_NOPAGENUMS.OR.PD_NOSELECTION .OR. PD_PRINTSETUP &lt;BR /&gt; pd.nFromPage = 1 ! not appear. &lt;BR /&gt; pd.nToPage = 1&lt;BR /&gt; pd.nMinPage = 1&lt;BR /&gt; pd.nMaxPage = 1&lt;BR /&gt; pd.nCopies = 1&lt;BR /&gt; pd.hInstance = NULL&lt;BR /&gt; pd.lpfnSetupHook = NULL&lt;BR /&gt; pd.lpSetupTemplateName = NULL&lt;BR /&gt; pd.lpfnPrintHook = NULL&lt;BR /&gt; pd.lpPrintTemplateName = NULL&lt;/P&gt;&lt;P&gt; retlog=PrintDlg(pd)&lt;BR /&gt;!&lt;BR /&gt;! Get handle to the device context for PRINTDLG Structure.&lt;BR /&gt;!&lt;BR /&gt; hdcPrn = pd.hDC&lt;/P&gt;&lt;P&gt; ihoriz=GetDeviceCaps(pD%hDc, PHYSICALWIDTH)&lt;BR /&gt; ivert=GetDeviceCaps(pD%hDc, PHYSICALHEIGHT)&lt;/P&gt;&lt;P&gt;!***********************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! Set DocInfo data.&lt;BR /&gt;!&lt;BR /&gt; DocName = 'Your title here'C&lt;BR /&gt; di.cbSize = sizeof(di)&lt;BR /&gt; di.lpszDocName = loc(DocName)&lt;BR /&gt; di.lpszOutput = NULL&lt;BR /&gt; di.lpszDatatype = NULL&lt;BR /&gt; di.fwType = NULL&lt;BR /&gt;!&lt;BR /&gt;! Get size of printable area of page.&lt;BR /&gt;!&lt;BR /&gt; cxPage = GetDeviceCaps(hdcPrn, HORZRES)&lt;BR /&gt; cyPage = GetDeviceCaps(hdcPrn, VERTRES)&lt;BR /&gt;!&lt;BR /&gt;! select a fraction of the minimum page dimension to &lt;BR /&gt;! which the plot will be scaled.., default this to 3/4&lt;BR /&gt; pwfract=0.75&lt;BR /&gt; cpage=min(cxpage, cypage)*pwfract&lt;BR /&gt;!***********************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! Prepare to plot to the printer.&lt;BR /&gt;!&lt;BR /&gt; retint = StartDoc(hdcPrn, di)&lt;BR /&gt; retint = StartPage(hdcPrn)&lt;BR /&gt;!&lt;BR /&gt; retint=SetMapMode(hdcPrn, MM_TEXT)&lt;BR /&gt;! &lt;BR /&gt; retlog=SetViewPortExtEx(hdcPrn,ihoriz, ivert, NULL)&lt;BR /&gt; &lt;BR /&gt;!***********************************************************************************&lt;/P&gt;&lt;P&gt; ICON = LoadImage( NULL, 'HELLO.BMP'C, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE )&lt;BR /&gt; write(*,*) ' ICON = ',ICON&lt;/P&gt;&lt;P&gt; ires = DrawIconEx( hdcPrn, 10, 10, ICON, 0, 0, 0, NULL, DI_NORMAL )&lt;BR /&gt; write(*,*) ' ires = ',ires&lt;/P&gt;&lt;P&gt; retint = EndPage(hDCPrn)&lt;BR /&gt; retint = EndDoc(hDCprn) &lt;BR /&gt;! Release the printer resources&lt;BR /&gt; retlog = DeleteDC(hDCprn)&lt;/P&gt;&lt;P&gt; end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Mar 2012 15:02:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783398#M28862</guid>
      <dc:creator>H_2</dc:creator>
      <dc:date>2012-03-30T15:02:24Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783399#M28863</link>
      <description>I tried converting your code to gfortran because you had some declarations that were not 64-bit safe and also an assumption throughout of initialization to zero. It should still compile in ifort, however:&lt;BR /&gt;[bash]!DEC$ IF(.FALSE.)
module gdi32
   use ISO_C_BINDING
   implicit none
   private
   public GetDeviceCaps
   interface
      function GetDeviceCaps(hdc, nIndex) bind(C,name='GetDeviceCaps')
         import
         implicit none
!gcc$ attributes STDCALL :: GetDeviceCaps
         integer(C_INT) GetDeviceCaps
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: nIndex
      end function GetDeviceCaps
   end interface
   integer(C_INT), parameter, public :: PHYSICALWIDTH = 110
   integer(C_INT), parameter, public :: PHYSICALHEIGHT = 111
   integer(C_INT), parameter, public :: HORZRES = 8
   integer(C_INT), parameter, public :: VERTRES = 10
   type, public, bind(C) :: T_DOCINFO
      integer(C_INT) cbSize
      type(C_PTR) lpszDocName
      type(C_PTR) lpszOutput
      type(C_PTR) lpszDatatype
      integer(C_INT32_T) fwType
   end type T_DOCINFO
   public StartDoc
   interface
      function StartDoc(hdc, lpdi) bind(C,name='StartDocA')
         import
         implicit none
!gcc$ attributes stdcall :: StartDoc
         integer(C_INT) StartDoc
         integer(C_INTPTR_T), value :: hdc
         type(T_DOCINFO) lpdi
      end function StartDoc
   end interface
   public StartPage
   interface
      function StartPage(HDC) bind(C,name='StartPage')
         import
         implicit none
!gcc$ attributes stdcall :: StartPage
         integer(C_INT) StartPage
         integer(C_INTPTR_T), value :: HDC
      end function StartPage
   end interface
   public SetMapMode
   interface
      function SetMapMode(hdc, fnMapMode) bind(C,name='SetMapMode')
         import
         implicit none
!gcc&amp;amp; attributes stdcall :: SetMapMode
         integer(C_INT) SetMapMode
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: fnMapMode
      end function SetMapMode
   end interface
   integer(C_INT), parameter, public :: MM_TEXT = 1
   type, public, bind(C) :: T_SIZE
      integer(C_LONG) cx
      integer(C_LONG) cy
   end type T_SIZE
   public SetViewportExtEx
   interface
      function SetViewportExtEx(hdc, nXExtent, nYExtent, &amp;amp;
         lpSize) bind(C,name='SetViewportExtEx')
         import
         implicit none
!gcc$ attributes stdcall :: SetViewportExtEx
         integer(C_INT) SetViewportExtEx
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: nXExtent
         integer(C_INT), value :: nYExtent
         type(T_SIZE) lpSize
      end function SetViewportExtEx
   end interface
   public EndPage
   interface
      function EndPage(hdc) bind(C,name='EndPage')
         import
         implicit none
!gcc$ attributes stdcall :: EndPage
         integer(C_INT) EndPage
         integer(C_INTPTR_T), value :: hdc
      end function EndPage
   end interface
   public EndDoc
   interface
      function EndDoc(hdc) bind(C,name='EndDoc')
         import
         implicit none
!gcc$ attributes stdcall :: EndDoc
         integer(C_INT) EndDoc
         integer(C_INTPTR_T), value :: hdc
      end function EndDoc
   end interface
   public DeleteDC
   interface
      function DeleteDC(hdc) bind(C,name='DeleteDC')
         import
         implicit none
!gcc$ attributes stdcall :: DeleteDC
         integer(C_INT) DeleteDC
         integer(C_INTPTR_T), value :: hdc
      end function DeleteDC
   end interface
   public DeleteObject
   interface
      function DeleteObject(hObject) bind(C,name='DeleteObject')
         import
         implicit none
!gcc$ attributes stdcall :: DeleteObject
         integer(C_INT) DeleteObject
         integer(C_INTPTR_T), value :: hObject
      end function DeleteObject
   end interface
end module gdi32

module IFWIN
   use ISO_C_BINDING
   implicit none
   private
   public LoadImage
   interface
      function LoadImage(hinst, lpszName, uType, &amp;amp;
         cxDesired, cyDesired, fuLoad) bind(C,name='LoadImageA')
         import
         implicit none
!gcc$ attributes stdcall :: LoadImage
         integer(C_INTPTR_T) LoadImage
         integer(C_INTPTR_T), value :: hinst
         character(kind=C_CHAR) :: lpszName(*)
         integer(C_INT), value :: uType
         integer(C_INT), value :: cxDesired
         integer(C_INT), value :: cyDesired
         integer(C_INT), value :: fuLoad
      end function LoadImage
   end interface
   integer(C_INT), parameter, public :: IMAGE_BITMAP = 0
   integer(C_INT), parameter, public :: LR_LOADFROMFILE = int(Z'00000010',C_INT)
   public DrawIconEx
   interface
      function DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, &amp;amp;
         cyWidth, istepIfAniCur, hbrFlickerFreeDraw, &amp;amp;
         diFlags) bind(C, name='DrawIconEx')
         import
         implicit none
!gcc&amp;amp; attributes stdcall :: DrawIconEx
         integer(C_INT) DrawIconEx
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: xLeft
         integer(C_INT), value :: yTop
         integer(C_INTPTR_T), value :: hIcon
         integer(C_INT), value :: cxWidth
         integer(C_INT), value :: cyWidth
         integer(C_INT), value :: istepIfAniCur
         integer(C_INTPTR_T), value :: hbrFlickerFreeDraw
         integer(C_INT), value :: diFlags
      end function DrawIconEx
   end interface
   integer(C_INT), parameter, public :: DI_IMAGE = int(Z'0002',C_INT)
   integer(C_INT), parameter, public :: DI_NORMAL = int(Z'0003',C_INT)
   integer(C_INT), parameter, public :: DI_DEFAULTSIZE = int(Z'0008',C_INT)
   public GetLastError
   interface
      function GetLastError() bind(C,name='GetLastError')
         import
         implicit none
!gcc$ attributes STDCALL :: GetLastError
         integer(C_INT32_T) GetLastError
      end function GetLastError
   end interface
   type, public, bind(C) :: T_POINT
      integer(C_LONG) x
      integer(C_LONG) y
   end type T_POINT
   public MoveToEx
   interface
      function MoveToEx(hdc, X, Y, lpPoint) bind(C,name='MoveToEx')
         import
         implicit none
!gcc$ attributes stdcall :: MoveToEx
         integer(C_INT) MoveToEx
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: X
         integer(C_INT), value :: Y
         type(T_POINT) lpPoint
      end function MoveToEx
   end interface
   public LineTo
   interface
      function LineTo(hdc, X, Y) bind(C,name='LineTo')
         import
         implicit none
!gcc$ attributes stdcall :: LineTo
         integer(C_INT) LineTo
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: X
         integer(C_INT), value :: Y
      end function LineTo
   end interface
end module IFWIN

module comdlg32
   use ISO_C_BINDING
   implicit none
   private
   type, public, bind(C) :: T_PRINTDLG
      integer(C_INT32_T) lStructSize
      integer(C_INTPTR_T) hwndOwner
      integer(C_INTPTR_T) hDevMode
      integer(C_INTPTR_T) hDevNames
      integer(C_INTPTR_T) hDC
      integer(C_INT32_T) Flags
      integer(C_INT16_T) nFromPage
      integer(C_INT16_T) nToPage
      integer(C_INT16_T) nMinPage
      integer(C_INT16_T) nMaxPage
      integer(C_INT16_T) nCopies
      integer(C_INTPTR_T) hInstance
      integer(C_INTPTR_T) lCustData
      type(C_FUNPTR) lpfnPrintHook
      type(C_FUNPTR) lpfnSetupHook
      type(C_PTR) lpPrintTemplateName
      type(C_PTR) lpSetupTemplateName
      integer(C_INTPTR_T) hPrintTemplate
      integer(C_INTPTR_T) hSetupTemplate
   end type T_PRINTDLG
   public PrintDlg
   interface
      function PrintDlg(lppd) bind(C,name='PrintDlgA')
         import
         implicit none
!gcc$ attributes STDCALL :: PrintDlg
         integer(C_INT) PrintDlg
         type(T_PRINTDLG) lppd
      end function PrintDlg
   end interface
   integer(C_INT32_T), parameter, public :: PD_RETURNDC = int(Z'00000100',C_INT32_T)
   integer(C_INT32_T), parameter, public :: PD_NOPAGENUMS = int(Z'00000002',C_INT32_T)
   integer(C_INT32_T), parameter, public :: PD_NOSELECTION = int(Z'00000004',C_INT32_T)
   integer(C_INT32_T), parameter, public :: PD_PRINTSETUP = int(Z'00000040',C_INT32_T)
end module comdlg32

!DEC$ ENDIF
program PrintImage
   use ISO_C_BINDING

   USE gdi32
   USE comdlg32
   USE IFWIN
!CC       USE IFQWIN

   implicit none
   integer(C_INT) retlog
   integer(C_INT) retint
   integer(C_INT) ires
   integer(C_INTPTR_T) :: hDCPrn       ! Handle for printer DC.
   integer(C_INT) ihoriz, ivert
   character(40,C_CHAR), target ::    DocName
   integer(C_INT)     ::    cxPage,     cyPage  ! Size of page printed area.
   integer(C_INT)     ::    cPage      ! minimum dimension of page.
   real(C_DOUBLE)     ::    pwfract    ! Fraction of page width to use for printed image
   type(T_DOCINFO)     ::    di        ! DOCINFO structure.
   type(T_PRINTDLG)    ::    pd        ! Print Dialog structure
   type(T_SIZE) :: ps
   type(T_POINT) :: pt
   integer(C_INTPTR_T) ICON
!***************************************************************************

! Initialise PRINTDLG structure.

   pd = T_PRINTDLG( &amp;amp;
      lStructSize = C_SIZEOF(pd), &amp;amp;
      hwndOwner = 0, &amp;amp;
      hDevMode = 0, &amp;amp;
      hDevNames = 0, &amp;amp;
      hDC = 0, &amp;amp;
      Flags = iany([PD_RETURNDC,PD_NOPAGENUMS, &amp;amp;
         PD_NOSELECTION,PD_PRINTSETUP]), &amp;amp;
      nFromPage = 1, &amp;amp;
      nToPage = 1, &amp;amp;
      nMinPage = 1, &amp;amp;
      nMaxPage = 1, &amp;amp;
      nCopies = 1, &amp;amp;
      hInstance = 0, &amp;amp;
      lCustData = 0, &amp;amp;
      lpfnPrintHook = C_NULL_FUNPTR, &amp;amp;
      lpfnSetupHook = C_NULL_FUNPTR, &amp;amp;
      lpPrintTemplateName = C_NULL_PTR, &amp;amp;
      lpSetupTemplateName = C_NULL_PTR, &amp;amp;
      hPrintTemplate = 0, &amp;amp;
      hSetupTemplate = 0)

   retlog=PrintDlg(pd)
write(*,*) 'retlog=',retlog
!
! Get handle to the device context for PRINTDLG Structure.
!
   hdcPrn = pd%hDC
write(*,*) 'hdcPrn=',hdcPrn

   ihoriz=GetDeviceCaps(pD%hDc, PHYSICALWIDTH)
write(*,*) 'ihoriz=',ihoriz
   ivert=GetDeviceCaps(pD%hDc, PHYSICALHEIGHT)
write(*,*) 'ivert=',ivert

!***********************************************************************************
!
! Set DocInfo data.
!
   DocName         = 'Your title here'//achar(0)
   di = T_DOCINFO( &amp;amp;
      cbSize       = C_SIZEOF(di), &amp;amp;
      lpszDocName  = C_LOC(DocName(1:1)), &amp;amp;
      lpszOutput   = C_NULL_PTR, &amp;amp;
      lpszDatatype = C_NULL_PTR, &amp;amp;
      fwType       = 0)
!
! Get size of printable area of page.
!
   cxPage = GetDeviceCaps(hdcPrn, HORZRES)
write(*,*) 'cxpage=',cxpage
   cyPage = GetDeviceCaps(hdcPrn, VERTRES)
write(*,*) 'cypage=',cypage
!
! select a fraction of the minimum page dimension to 
! which the plot will be scaled.., default this to 3/4
   pwfract=0.75
   cpage=min(cxpage, cypage)*pwfract
write(*,*) 'cpage=',cpage
!***********************************************************************************
!
! Prepare to plot to the printer.
!
   retint  = StartDoc(hdcPrn, di)
write(*,*) 'retint=',retint
   retint  = StartPage(hdcPrn)
write(*,*) 'retint=',retint
!
   retint=SetMapMode(hdcPrn, MM_TEXT)
write(*,*) 'retint=',retint
!
! Should be ignored because MapMode = MM_TEXT
   retlog=SetViewPortExtEx(hdcPrn,ihoriz, ivert, ps)
write(*,*) 'retlog=',retlog
   
!***********************************************************************************

   ICON = LoadImage(0_C_INTPTR_T, 'HELLO.BMP'//achar(0), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
   write(*,*) ' ICON = ',ICON
   write(*,'(a,z0)') ' ICON = ',ICON

!   ires = DrawIconEx(hdcPrn, 10, 10, ICON, 0, 0, 0, 0_C_INTPTR_T, DI_NORMAL)
!   ires = DrawIconEx(hdcPrn, 10, 10, ICON, 0, 0, 0, 0_C_INTPTR_T, DI_IMAGE)
   ires = DrawIconEx(hdcPrn, 10, 10, ICON, 0, 0, 0, 0_C_INTPTR_T, iany([DI_DEFAULTSIZE,DI_NORMAL]))
   write(*,*) ' ires = ',ires
   ires = GetLastError()
   write(*,*) ' ires = ',ires
   ires = DeleteObject(ICON)
   write(*,*) ' ires = ',ires

   ires = MoveToEx(hdcPrn, cPage, cPage, pt)
   write(*,*) ' ires = ',ires
   ires = LineTo(hdcPrn, 0, 0)
   write(*,*) ' ires = ',ires

   retint = EndPage(hDCPrn)
write(*,*) 'retint=',retint
   retint = EndDoc(hDCprn)    
write(*,*) 'retint=',retint
! Release the printer resources
   retlog = DeleteDC(hDCprn)
write(*,*) 'retlog=',retlog

end program PrintImage
[/bash]&lt;BR /&gt;The output was:&lt;BR /&gt;[bash] retlog=           1
 hdcPrn=             35721141
 ihoriz=        5100
 ivert=        6600
 cxpage=        4900
 cypage=        6400
 cpage=        3675
 retint=          16
 retint=           1
 retint=           1
 retlog=           1
  ICON =           -2080043277
 ICON = FFFFFFFF84050EF3
  ires =            0
  ires =         1402
  ires =            1
  ires =            1
  ires =            1
 retint=           1
 retint=           1
 retlog=           1[/bash]&lt;BR /&gt;The MoveToEx/LineTo sequence succeeded in printing out a diagonal line, but I still got a 1402 (ERROR_INVALID_CURSOR_HANDLE) from DrawIconEx. So at least the hdcPrn is working correctly, but I can't tell you why DrawIconEx fails.</description>
      <pubDate>Sun, 01 Apr 2012 03:07:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783399#M28863</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-04-01T03:07:37Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783400#M28864</link>
      <description>OK, I copied an example from Petzold and got the bitmap to print. It comes out really tiny so maybe StretchBlt would have been more appropriate, but at least it isn't the white page of death.&lt;BR /&gt;&lt;BR /&gt;[bash]!DEC$ IF(.FALSE.)
module gdi32
   use ISO_C_BINDING
   implicit none
   private
   public GetDeviceCaps
   interface
      function GetDeviceCaps(hdc, nIndex) bind(C,name='GetDeviceCaps')
         import
         implicit none
!gcc$ attributes STDCALL :: GetDeviceCaps
         integer(C_INT) GetDeviceCaps
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: nIndex
      end function GetDeviceCaps
   end interface
   integer(C_INT), parameter, public :: PHYSICALWIDTH = 110
   integer(C_INT), parameter, public :: PHYSICALHEIGHT = 111
   integer(C_INT), parameter, public :: HORZRES = 8
   integer(C_INT), parameter, public :: VERTRES = 10
   type, public, bind(C) :: T_DOCINFO
      integer(C_INT) cbSize
      type(C_PTR) lpszDocName
      type(C_PTR) lpszOutput
      type(C_PTR) lpszDatatype
      integer(C_INT32_T) fwType
   end type T_DOCINFO
   public StartDoc
   interface
      function StartDoc(hdc, lpdi) bind(C,name='StartDocA')
         import
         implicit none
!gcc$ attributes stdcall :: StartDoc
         integer(C_INT) StartDoc
         integer(C_INTPTR_T), value :: hdc
         type(T_DOCINFO) lpdi
      end function StartDoc
   end interface
   public StartPage
   interface
      function StartPage(HDC) bind(C,name='StartPage')
         import
         implicit none
!gcc$ attributes stdcall :: StartPage
         integer(C_INT) StartPage
         integer(C_INTPTR_T), value :: HDC
      end function StartPage
   end interface
   public SetMapMode
   interface
      function SetMapMode(hdc, fnMapMode) bind(C,name='SetMapMode')
         import
         implicit none
!gcc&amp;amp; attributes stdcall :: SetMapMode
         integer(C_INT) SetMapMode
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: fnMapMode
      end function SetMapMode
   end interface
   integer(C_INT), parameter, public :: MM_TEXT = 1
   type, public, bind(C) :: T_SIZE
      integer(C_LONG) cx
      integer(C_LONG) cy
   end type T_SIZE
   public SetViewportExtEx
   interface
      function SetViewportExtEx(hdc, nXExtent, nYExtent, &amp;amp;
         lpSize) bind(C,name='SetViewportExtEx')
         import
         implicit none
!gcc$ attributes stdcall :: SetViewportExtEx
         integer(C_INT) SetViewportExtEx
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: nXExtent
         integer(C_INT), value :: nYExtent
         type(T_SIZE) lpSize
      end function SetViewportExtEx
   end interface
   public EndPage
   interface
      function EndPage(hdc) bind(C,name='EndPage')
         import
         implicit none
!gcc$ attributes stdcall :: EndPage
         integer(C_INT) EndPage
         integer(C_INTPTR_T), value :: hdc
      end function EndPage
   end interface
   public EndDoc
   interface
      function EndDoc(hdc) bind(C,name='EndDoc')
         import
         implicit none
!gcc$ attributes stdcall :: EndDoc
         integer(C_INT) EndDoc
         integer(C_INTPTR_T), value :: hdc
      end function EndDoc
   end interface
   public DeleteDC
   interface
      function DeleteDC(hdc) bind(C,name='DeleteDC')
         import
         implicit none
!gcc$ attributes stdcall :: DeleteDC
         integer(C_INT) DeleteDC
         integer(C_INTPTR_T), value :: hdc
      end function DeleteDC
   end interface
   public DeleteObject
   interface
      function DeleteObject(hObject) bind(C,name='DeleteObject')
         import
         implicit none
!gcc$ attributes stdcall :: DeleteObject
         integer(C_INT) DeleteObject
         integer(C_INTPTR_T), value :: hObject
      end function DeleteObject
   end interface
   type, public, bind(C) :: T_BITMAP
      integer(C_LONG) bmType
      integer(C_LONG) bmWidth
      integer(C_LONG) bmHeight
      integer(C_LONG) bmWidthBytes
      integer(C_INT16_T) bmPlanes
      integer(C_INT16_T) bmBitsPixel
      type(C_PTR) bmBits
   end type T_BITMAP
   public GetObject
   interface
      function GetObject(hgdiobj, cbBuffer, lpvObject) bind(C,name='GetObjectA')
         import
         implicit none
!gcc$ attributes stdcall :: GetObject
         integer(C_INT) GetObject
         integer(C_INTPTR_T), value :: hgdiobj
         integer(C_INT), value :: cbBuffer
         type(C_PTR), value :: lpvObject
      end function GetObject
   end interface
   public CreateCompatibleDC
   interface
      function CreateCompatibleDC(hdc) bind(C,name='CreateCompatibleDC')
         import
         implicit none
!gcc$ attributes stdcall :: CreateCompatibleDC
         integer(C_INTPTR_T) CreateCompatibleDC
         integer(C_INTPTR_T), value :: hdc
      end function CreateCompatibleDC
   end interface
   public SelectObject
   interface
      function SelectObject(hdc, hgdiobj) bind(C,name='SelectObject')
         import
         implicit none
!gcc$ attributes stdcall :: SelectObject
         integer(C_INTPTR_T) SelectObject
         integer(C_INTPTR_T), value :: hdc
         integer(C_INTPTR_T), value :: hgdiobj
      end function SelectObject
   end interface
   public BitBlt
   interface
      function BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, &amp;amp;
         hdcSrc, nXSrc, nYSrc, dwRop) bind(C,name='BitBlt')
         import
         implicit none
!gcc$ attributes stdcall :: BitBlt
         integer(C_INT) BitBlt
         integer(C_INTPTR_T), value :: hdcDest
         integer(C_INT), value :: nXDest
         integer(C_INT), value :: nYDest
         integer(C_INT), value :: nwidth
         integer(C_INT), value :: nHeight
         integer(C_INTPTR_T), value :: hdcSrc
         integer(C_INT), value :: nXSrc
         integer(C_INT), value :: nYSrc
         integer(C_INT32_T), value :: dwRop
      end function BitBlt
   end interface
   integer(C_INT32_T), parameter, public :: SRCCOPY = int(Z'00CC0020',C_INT32_T)
end module gdi32

module IFWIN
   use ISO_C_BINDING
   implicit none
   private
   public LoadImage
   interface
      function LoadImage(hinst, lpszName, uType, &amp;amp;
         cxDesired, cyDesired, fuLoad) bind(C,name='LoadImageA')
         import
         implicit none
!gcc$ attributes stdcall :: LoadImage
         integer(C_INTPTR_T) LoadImage
         integer(C_INTPTR_T), value :: hinst
         character(kind=C_CHAR) :: lpszName(*)
         integer(C_INT), value :: uType
         integer(C_INT), value :: cxDesired
         integer(C_INT), value :: cyDesired
         integer(C_INT), value :: fuLoad
      end function LoadImage
   end interface
   integer(C_INT), parameter, public :: IMAGE_BITMAP = 0
   integer(C_INT), parameter, public :: LR_CREATEDIBSECTION = int(Z'00002000',C_INT)
   integer(C_INT), parameter, public :: LR_LOADFROMFILE = int(Z'00000010',C_INT)
   public DrawIconEx
   interface
      function DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, &amp;amp;
         cyWidth, istepIfAniCur, hbrFlickerFreeDraw, &amp;amp;
         diFlags) bind(C, name='DrawIconEx')
         import
         implicit none
!gcc&amp;amp; attributes stdcall :: DrawIconEx
         integer(C_INT) DrawIconEx
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: xLeft
         integer(C_INT), value :: yTop
         integer(C_INTPTR_T), value :: hIcon
         integer(C_INT), value :: cxWidth
         integer(C_INT), value :: cyWidth
         integer(C_INT), value :: istepIfAniCur
         integer(C_INTPTR_T), value :: hbrFlickerFreeDraw
         integer(C_INT), value :: diFlags
      end function DrawIconEx
   end interface
   integer(C_INT), parameter, public :: DI_IMAGE = int(Z'0002',C_INT)
   integer(C_INT), parameter, public :: DI_NORMAL = int(Z'0003',C_INT)
   integer(C_INT), parameter, public :: DI_DEFAULTSIZE = int(Z'0008',C_INT)
   public GetLastError
   interface
      function GetLastError() bind(C,name='GetLastError')
         import
         implicit none
!gcc$ attributes STDCALL :: GetLastError
         integer(C_INT32_T) GetLastError
      end function GetLastError
   end interface
   type, public, bind(C) :: T_POINT
      integer(C_LONG) x
      integer(C_LONG) y
   end type T_POINT
   public MoveToEx
   interface
      function MoveToEx(hdc, X, Y, lpPoint) bind(C,name='MoveToEx')
         import
         implicit none
!gcc$ attributes stdcall :: MoveToEx
         integer(C_INT) MoveToEx
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: X
         integer(C_INT), value :: Y
         type(T_POINT) lpPoint
      end function MoveToEx
   end interface
   public LineTo
   interface
      function LineTo(hdc, X, Y) bind(C,name='LineTo')
         import
         implicit none
!gcc$ attributes stdcall :: LineTo
         integer(C_INT) LineTo
         integer(C_INTPTR_T), value :: hdc
         integer(C_INT), value :: X
         integer(C_INT), value :: Y
      end function LineTo
   end interface
end module IFWIN

module comdlg32
   use ISO_C_BINDING
   implicit none
   private
   type, public, bind(C) :: T_PRINTDLG
      integer(C_INT32_T) lStructSize
      integer(C_INTPTR_T) hwndOwner
      integer(C_INTPTR_T) hDevMode
      integer(C_INTPTR_T) hDevNames
      integer(C_INTPTR_T) hDC
      integer(C_INT32_T) Flags
      integer(C_INT16_T) nFromPage
      integer(C_INT16_T) nToPage
      integer(C_INT16_T) nMinPage
      integer(C_INT16_T) nMaxPage
      integer(C_INT16_T) nCopies
      integer(C_INTPTR_T) hInstance
      integer(C_INTPTR_T) lCustData
      type(C_FUNPTR) lpfnPrintHook
      type(C_FUNPTR) lpfnSetupHook
      type(C_PTR) lpPrintTemplateName
      type(C_PTR) lpSetupTemplateName
      integer(C_INTPTR_T) hPrintTemplate
      integer(C_INTPTR_T) hSetupTemplate
   end type T_PRINTDLG
   public PrintDlg
   interface
      function PrintDlg(lppd) bind(C,name='PrintDlgA')
         import
         implicit none
!gcc$ attributes STDCALL :: PrintDlg
         integer(C_INT) PrintDlg
         type(T_PRINTDLG) lppd
      end function PrintDlg
   end interface
   integer(C_INT32_T), parameter, public :: PD_RETURNDC = int(Z'00000100',C_INT32_T)
   integer(C_INT32_T), parameter, public :: PD_NOPAGENUMS = int(Z'00000002',C_INT32_T)
   integer(C_INT32_T), parameter, public :: PD_NOSELECTION = int(Z'00000004',C_INT32_T)
   integer(C_INT32_T), parameter, public :: PD_PRINTSETUP = int(Z'00000040',C_INT32_T)
end module comdlg32

!DEC$ ENDIF
program PrintImage
   use ISO_C_BINDING

   USE gdi32
   USE comdlg32
   USE IFWIN
!CC       USE IFQWIN

   implicit none
   integer(C_INT) retlog
   integer(C_INT) retint
   integer(C_INT) ires
   integer(C_INTPTR_T) :: hDCPrn       ! Handle for printer DC.
   integer(C_INT) ihoriz, ivert
   character(40,C_CHAR), target ::    DocName
   integer(C_INT)     ::    cxPage,     cyPage  ! Size of page printed area.
   integer(C_INT)     ::    cPage      ! minimum dimension of page.
   real(C_DOUBLE)     ::    pwfract    ! Fraction of page width to use for printed image
   type(T_DOCINFO)     ::    di        ! DOCINFO structure.
   type(T_PRINTDLG)    ::    pd        ! Print Dialog structure
   type(T_SIZE) :: ps
   type(T_POINT) :: pt
   integer(C_INTPTR_T) ICON
   type(T_BITMAP), target :: bmp
   integer(C_INTPTR_T) hdcMem
   integer(C_INTPTR_T) old_hgdi
!***************************************************************************

! Initialise PRINTDLG structure.

   pd = T_PRINTDLG( &amp;amp;
      lStructSize = C_SIZEOF(pd), &amp;amp;
      hwndOwner = 0, &amp;amp;
      hDevMode = 0, &amp;amp;
      hDevNames = 0, &amp;amp;
      hDC = 0, &amp;amp;
      Flags = iany([PD_RETURNDC,PD_NOPAGENUMS, &amp;amp;
         PD_NOSELECTION,PD_PRINTSETUP]), &amp;amp;
      nFromPage = 1, &amp;amp;
      nToPage = 1, &amp;amp;
      nMinPage = 1, &amp;amp;
      nMaxPage = 1, &amp;amp;
      nCopies = 1, &amp;amp;
      hInstance = 0, &amp;amp;
      lCustData = 0, &amp;amp;
      lpfnPrintHook = C_NULL_FUNPTR, &amp;amp;
      lpfnSetupHook = C_NULL_FUNPTR, &amp;amp;
      lpPrintTemplateName = C_NULL_PTR, &amp;amp;
      lpSetupTemplateName = C_NULL_PTR, &amp;amp;
      hPrintTemplate = 0, &amp;amp;
      hSetupTemplate = 0)

   retlog=PrintDlg(pd)
write(*,*) 'retlog=',retlog
!
! Get handle to the device context for PRINTDLG Structure.
!
   hdcPrn = pd%hDC
write(*,*) 'hdcPrn=',hdcPrn

   ihoriz=GetDeviceCaps(pD%hDc, PHYSICALWIDTH)
write(*,*) 'ihoriz=',ihoriz
   ivert=GetDeviceCaps(pD%hDc, PHYSICALHEIGHT)
write(*,*) 'ivert=',ivert

!***********************************************************************************
!
! Set DocInfo data.
!
   DocName         = 'Your title here'//achar(0)
   di = T_DOCINFO( &amp;amp;
      cbSize       = C_SIZEOF(di), &amp;amp;
      lpszDocName  = C_LOC(DocName(1:1)), &amp;amp;
      lpszOutput   = C_NULL_PTR, &amp;amp;
      lpszDatatype = C_NULL_PTR, &amp;amp;
      fwType       = 0)
!
! Get size of printable area of page.
!
   cxPage = GetDeviceCaps(hdcPrn, HORZRES)
write(*,*) 'cxpage=',cxpage
   cyPage = GetDeviceCaps(hdcPrn, VERTRES)
write(*,*) 'cypage=',cypage
!
! select a fraction of the minimum page dimension to 
! which the plot will be scaled.., default this to 3/4
   pwfract=0.75
   cpage=min(cxpage, cypage)*pwfract
write(*,*) 'cpage=',cpage
!***********************************************************************************
!
! Prepare to plot to the printer.
!
   retint  = StartDoc(hdcPrn, di)
write(*,*) 'retint=',retint
   retint  = StartPage(hdcPrn)
write(*,*) 'retint=',retint
!
   retint=SetMapMode(hdcPrn, MM_TEXT)
write(*,*) 'retint=',retint
!
! Should be ignored because MapMode = MM_TEXT
   retlog=SetViewPortExtEx(hdcPrn,ihoriz, ivert, ps)
write(*,*) 'retlog=',retlog
   
!***********************************************************************************

   ICON = LoadImage(0_C_INTPTR_T, 'HELLO.BMP'//achar(0), IMAGE_BITMAP, 0, 0, &amp;amp;
      iany([LR_LOADFROMFILE,LR_CREATEDIBSECTION]))
   write(*,*) ' ICON = ',ICON
   write(*,'(a,z0)') ' ICON = ',ICON

   ires = GetObject(ICON, int(C_SIZEOF(bmp),C_INT), C_LOC(bmp))
   write(*,*) ' ires = ',ires
   hdcMem = CreateCompatibleDC(hdcPrn)
   write(*,*) 'hdcMem=',hdcMem
   old_hgdi = SelectObject(hdcMem, ICON)
   write(*,*) 'old_hgdi=',old_hgdi
   ires = BitBlt(hdcPrn, 0, 0, bmp%bmWIdth, bmp%bmHeight, hdcMem, 0, 0, SRCCOPY)
   write(*,*) ' ires = ',ires
   ires = DeleteObject(hdcMem)
   write(*,*) ' ires = ',ires

!   ires = DrawIconEx(hdcPrn, 10, 10, ICON, 0, 0, 0, 0_C_INTPTR_T, DI_NORMAL)
!   ires = DrawIconEx(hdcPrn, 10, 10, ICON, 0, 0, 0, 0_C_INTPTR_T, DI_IMAGE)
!   ires = DrawIconEx(hdcPrn, 10, 10, ICON, 0, 0, 0, 0_C_INTPTR_T, iany([DI_DEFAULTSIZE,DI_NORMAL]))
!   write(*,*) ' ires = ',ires
!   ires = GetLastError()
!   write(*,*) ' ires = ',ires
   ires = DeleteObject(ICON)
   write(*,*) ' ires = ',ires

   ires = MoveToEx(hdcPrn, cPage, cPage, pt)
   write(*,*) ' ires = ',ires
   ires = LineTo(hdcPrn, 0, 0)
   write(*,*) ' ires = ',ires

   retint = EndPage(hDCPrn)
write(*,*) 'retint=',retint
   retint = EndDoc(hDCprn)    
write(*,*) 'retint=',retint
! Release the printer resources
   retlog = DeleteDC(hDCprn)
write(*,*) 'retlog=',retlog

end program PrintImage
[/bash]</description>
      <pubDate>Sun, 01 Apr 2012 05:31:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783400#M28864</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-04-01T05:31:00Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783401#M28865</link>
      <description>&lt;P&gt;Very interesting, but I had problems with compilation. What do you use as compiling options? I tried with&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IFORT /4L132 /libs:qwin printimage3.f90 /traceback&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I get the message&lt;/P&gt;&lt;P&gt;&lt;EM&gt;printimage3.f90(276): error #6404: This name does not have a type, and must have&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;an explicit type. [C_SIZEOF&lt;/EM&gt;]&lt;/P&gt;&lt;P&gt; &lt;EM&gt;lStructSize = C_SIZEOF(pd), &amp;amp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Hkan&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2012 13:39:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783401#M28865</guid>
      <dc:creator>H_2</dc:creator>
      <dc:date>2012-04-02T13:39:01Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783402#M28866</link>
      <description>I am surprised by that error. The interface to C_SIZEOF should have been made explicit by the line&lt;BR /&gt;&lt;BR /&gt;use ISO_C_BINDING&lt;BR /&gt;&lt;BR /&gt;Maybe ifort doesn't define the T_PRINTDLG structure to have the BIND(C) attribute? Then C_SIZEOF wouldn't work on pd except as an extension. I compiled in gfortran via&lt;BR /&gt;&lt;BR /&gt;gfortran draw.f90 -lgdi32 -lcomdlg32 -odraw&lt;BR /&gt;&lt;BR /&gt;If you have a 64-bit system you should be able to remove the two !DEC$ lines and compile my code with ifort. Otherwise leave them in there and try changing C_SIZEOF to SIZEOF and recompile.</description>
      <pubDate>Mon, 02 Apr 2012 15:23:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783402#M28866</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-04-02T15:23:49Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783403#M28867</link>
      <description>None of the Win32 API declarations use BIND(C), but that doesn't matter because C_SIZEOF wouldn't care. But the problem is that C_SIZEOF is a F2008 feature not yet in Intel Fortran. Use the extension SIZEOF as a workaround.</description>
      <pubDate>Mon, 02 Apr 2012 15:41:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783403#M28867</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-04-02T15:41:19Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783404#M28868</link>
      <description>Another workaround would be to create an ISO_C_BINDING.f90 file&lt;BR /&gt;&lt;BR /&gt;[bash]module ISO_C_BINDING_EXT
   intrinsic SIZEOF
end module ISO_C_BINDING_EXT

module ISO_C_BINDING
   use, intrinsic :: ISO_C_BINDING
   use ISO_C_BINDING_EXT, C_SIZEOF=&amp;gt;SIZEOF
end module ISO_C_BINDING
[/bash]&lt;BR /&gt;The advantage being that you could leave code that had lots of usage of C_SIZEOF unchanged as long asifort looked for the ISO_C_BINDING.mod file it generated from the above code rather than its intrinsic version. When ifort catches up you can just delete the non-intrinsic ISO_C_BINDING.mod file.</description>
      <pubDate>Mon, 02 Apr 2012 16:07:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783404#M28868</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-04-02T16:07:24Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783405#M28869</link>
      <description>Interesting idea, but it won't work the way you have it. You cannot write your own ISO_C_BINDING that USEs the intrinsic module. And there's no way to use renaming to map a different name onto an intrinsic. Unfortunately, the "size of" concept is one that does not lend itself to being added by user code.</description>
      <pubDate>Mon, 02 Apr 2012 17:46:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783405#M28869</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-04-02T17:46:38Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783406#M28870</link>
      <description>Why not? Works fine in gfortran. I thought the point of "use, intrinsic ::" vs. "use ::" was that it allows the compiler to distinguish between the intrinsic module supplied by the compiler and any user-defined module with the same name. Consider this example:&lt;BR /&gt;&lt;BR /&gt;[bash]module old_stuff
   contains
   function marklar(x)
      real x
      real marklar
      marklar = 3*x+2
   end function marklar
end module old_stuff

module new_stuff
   use old_stuff, sizeof=&amp;gt;marklar
end module new_stuff

program test
   use new_stuff
   real a

   a = 7
   write(*,'(a,f0.0)') 'sizeof(a) = ', sizeof(a)
end program test
[/bash]&lt;BR /&gt;In both gfortran and ifort it prints "sizeof(a) = 23.". By this technique, all functions may be named marklar.</description>
      <pubDate>Mon, 02 Apr 2012 23:00:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783406#M28870</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-04-02T23:00:10Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783407#M28871</link>
      <description>Your latest program does something very different than your proposal - it does not rename an intrinsic. Show me how you would turn this code into something that does what C_SIZEOF does.</description>
      <pubDate>Mon, 02 Apr 2012 23:33:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783407#M28871</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-04-02T23:33:28Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783408#M28872</link>
      <description>FWIW - a post on c.l.f on renaming of intrinsics: &lt;A href="http://groups.google.com/group/comp.lang.fortran/msg/6ca00d004e385e77"&gt;http://groups.google.com/group/comp.lang.fortran/msg/6ca00d004e385e77.&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Apr 2012 00:25:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783408#M28872</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2012-04-03T00:25:46Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783409#M28873</link>
      <description>intrinsics /= module intrinsics&lt;BR /&gt;&lt;BR /&gt;The big problem here is that the compiler has to treat C_SIZEOF as essentially the same as the SIZEOF extension intrinsic, which includes allowing that in initialization expressions, and allowing most anything with compile-time known size as the argument. The way we currently implement intrinsic modules such as ISO_C_BINDING does not provide a hook for that. We know we have to create such a hook and pretty much know how we're going to do it.</description>
      <pubDate>Tue, 03 Apr 2012 01:06:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783409#M28873</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-04-03T01:06:48Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783410#M28874</link>
      <description>[bash]module old_stuff
   intrinsic sizeof
end module old_stuff

module new_stuff
   use old_stuff, marklar=&amp;gt;sizeof
end module new_stuff

program test
   use new_stuff
   integer k(2)
   integer, parameter :: m = marklar(k)
   integer(m) x

   write(*,*) huge(x)
end program test
[/bash]&lt;BR /&gt;In program test, marklar is used in an initialization expression just as we might have used C_SIZEOF. gfortran doesn't like it because it doesn't allow SIZEOF in initialization expressions, but ifort prints out&lt;BR /&gt;&lt;BR /&gt;9223372036854775807&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Apr 2012 02:20:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783410#M28874</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2012-04-03T02:20:35Z</dc:date>
    </item>
    <item>
      <title>Print a BMP-file using Intel Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783411#M28875</link>
      <description>That's very interesting - I would not have guessed that would work. I modified your program to print out m, as otherwise it doesn't demonstrate what is needed, and it worked. Thanks.</description>
      <pubDate>Tue, 03 Apr 2012 14:07:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-a-BMP-file-using-Intel-Fortran/m-p/783411#M28875</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2012-04-03T14:07:39Z</dc:date>
    </item>
  </channel>
</rss>

