<?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 I appreciate the help.  But I in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048254#M114569</link>
    <description>&lt;P&gt;I appreciate the help.&amp;nbsp; But I'm not sure how to do this.&amp;nbsp; I am not a Windows programmer.&amp;nbsp; &amp;nbsp;I went into the print routine and changed the line:&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;PRINTDLG_Struct%hwndOwner&amp;nbsp;= NULL to PRINTDLG_Struct%hwndOwner = GetForegroundWindow()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;The compiler gives me this error:&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;Error&amp;nbsp;1&amp;nbsp; error #6404: This name does not have a type, and must have an explicit type.&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I am not sure how to declare the "Type" or if this is the correct location to make the change.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Apr 2015 23:29:15 GMT</pubDate>
    <dc:creator>Ken2</dc:creator>
    <dc:date>2015-04-30T23:29:15Z</dc:date>
    <item>
      <title>Print window keeps coming up behind my application window</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048251#M114566</link>
      <description>&lt;P&gt;I use the FORTRAN_WINPRINT.F90 to print from my applications, but the print window (the one&amp;nbsp;that allows you to&amp;nbsp;select your printer) opens almost always behind my applications window.&amp;nbsp; Not every time, but more probably more than 70% of the time.&amp;nbsp; So users think the program has stopped when it is actually&amp;nbsp;waiting for input.&amp;nbsp; How do I get this Print&amp;nbsp;window to always come up in front of my applications window?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2015 00:21:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048251#M114566</guid>
      <dc:creator>Ken2</dc:creator>
      <dc:date>2015-04-30T00:21:22Z</dc:date>
    </item>
    <item>
      <title>Hello</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048252#M114567</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I don't know FORTRAN_WINPRINT.F90 but I think that you must have to pass the handle of your window to the print dialog in order for it to be displayed in the foreground.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2015 06:15:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048252#M114567</guid>
      <dc:creator>GVautier</dc:creator>
      <dc:date>2015-04-30T06:15:05Z</dc:date>
    </item>
    <item>
      <title>Right - in the initialization</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048253#M114568</link>
      <description>&lt;P&gt;Right - in the initialization of PRINTDLG_Struct, the hwnd component needs to be set to your window handle. You could modify the code to pass that in, or perhaps replace NULL with GetForegroundWindow(), though that is said to have issues in some cases.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2015 14:28:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048253#M114568</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-04-30T14:28:17Z</dc:date>
    </item>
    <item>
      <title>I appreciate the help.  But I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048254#M114569</link>
      <description>&lt;P&gt;I appreciate the help.&amp;nbsp; But I'm not sure how to do this.&amp;nbsp; I am not a Windows programmer.&amp;nbsp; &amp;nbsp;I went into the print routine and changed the line:&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;PRINTDLG_Struct%hwndOwner&amp;nbsp;= NULL to PRINTDLG_Struct%hwndOwner = GetForegroundWindow()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;The compiler gives me this error:&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;Error&amp;nbsp;1&amp;nbsp; error #6404: This name does not have a type, and must have an explicit type.&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I am not sure how to declare the "Type" or if this is the correct location to make the change.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2015 23:29:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048254#M114569</guid>
      <dc:creator>Ken2</dc:creator>
      <dc:date>2015-04-30T23:29:15Z</dc:date>
    </item>
    <item>
      <title>You need to add "use user32"</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048255#M114570</link>
      <description>&lt;P&gt;You need to add "use user32" as a line next to the other "use" statements.&lt;/P&gt;

&lt;P&gt;FWIW, I'm working on a revised version of this that uses PrintDlgEx, as Microsoft is hinting that PrintDlg will go away in some unspecified future version of Windows. One thing I noticed is that PrintDlgEx won't accept NULL as the owner HWND. I hate to use GetForegroundWindow as a default, but I may not have a better choice. I am adding OwnerWindow as an optional argument so if you have a GUI app you can pass the correct handle.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2015 00:59:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048255#M114570</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-05-01T00:59:53Z</dc:date>
    </item>
    <item>
      <title>That works.  Now the print</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048256#M114571</link>
      <description>&lt;P&gt;That works.&amp;nbsp; Now the print window pops up over the application window, I click on print or hit return, the print window closes then I can not return to the application window which is still open.&amp;nbsp; Clicking on it does not make the window active again.&amp;nbsp; Any suggestions?&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2015 02:15:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048256#M114571</guid>
      <dc:creator>Ken2</dc:creator>
      <dc:date>2015-05-01T02:15:46Z</dc:date>
    </item>
    <item>
      <title>I haven't seen that behavior</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048257#M114572</link>
      <description>&lt;P&gt;I haven't seen that behavior when I've been testing. Is your application a console app or GUI? If GUI, you will need to supply the HWND of your application window - using GetForegroundWindow for this purpose will probably have ill effects in such cases.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2015 13:01:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048257#M114572</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-05-01T13:01:15Z</dc:date>
    </item>
    <item>
      <title>Steve, thanks for the heads</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048258#M114573</link>
      <description>&lt;P&gt;Steve, thanks for the heads-up on the future deprecation of PrintDlg(), I haven't paid any attention to that function for years.&amp;nbsp; I have now reworked my apps to use PrintDlgEx().&amp;nbsp; The following module shows my initialization of the dialog; note that flags are set to remove most of the options so the presentation is like that of PrintDlg().&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;MODULE printfunc
	SAVE

	!	this is a reworked version of a STRUCTURE
	TYPE T_DEVMODE_KT
		integer(BYTE) dmDeviceName(32)		! knowns  BYTE 
		integer(WORD) dmSpecVersion			! knowns  WORD 
		integer(WORD) dmDriverVersion		! knowns  WORD 
		integer(WORD) dmSize				! knowns  WORD 
		integer(WORD) dmDriverExtra			! knowns  WORD 
		integer(DWORD) dmFields				! knowns  DWORD 
		integer(SHORT) dmOrientation		! knowns  short 
		integer(SHORT) dmPaperSize			! knowns  short 
		integer(SHORT) dmPaperLength		! knowns  short 
		integer(SHORT) dmPaperWidth			! knowns  short 
		integer(SHORT) dmScale				! knowns  short 
		integer(SHORT) dmCopies				! knowns  short 
		integer(SHORT) dmDefaultSource		! knowns  short 
		integer(SHORT) dmPrintQuality		! knowns  short 
		integer(SHORT) dmColor				! knowns  short 
		integer(SHORT) dmDuplex				! knowns  short 
		integer(SHORT) dmYResolution		! knowns  short 
		integer(SHORT) dmTTOption			! knowns  short 
		integer(SHORT) dmCollate			! knowns  short 
		integer(BYTE)  dmFormName(32)		! knowns  BYTE 
		integer(WORD)  dmLogPixels			! knowns  WORD 
		integer(DWORD) dmBitsPerPel			! knowns  DWORD 
		integer(DWORD) dmPelsWidth			! knowns  DWORD 
		integer(DWORD) dmPelsHeight		    ! knowns  DWORD 
		integer(DWORD) dmDisplayFlags		! knowns  DWORD 
		integer(DWORD) dmDisplayFrequency   ! knowns  DWORD 
		integer(DWORD) dmICMMethod          ! knowns  DWORD 
		integer(DWORD) dmICMIntent          ! knowns  DWORD 
		integer(DWORD) dmMediaType          ! knowns  DWORD 
		integer(DWORD) dmDitherType         ! knowns  DWORD 
		integer(DWORD) dmReserved1          ! knowns  DWORD 
		integer(DWORD) dmReserved2          ! knowns  DWORD 
		integer(DWORD) dmPanningWidth       ! knowns  DWORD 
		integer(DWORD) dmPanningHeight      ! knowns  DWORD 
	END TYPE T_DEVMODE_KT
    
    !   copied from comdlg32.f90, where this function
    !   is only available for 64-bit builds
    INTERFACE 
    FUNCTION PrintDlgEx( &amp;amp;
            arg1)
    use ifwinty
      integer(LONG) :: PrintDlgEx ! HRESULT
      !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'PrintDlgExA' :: PrintDlgEx
      !DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: arg1
      TYPE (T_PRINTDLGEX) arg1 ! LPPRINTDLGEXA arg1
     END FUNCTION
    END INTERFACE
    
    !   these WinAPI constants are not present in ifwinty.f90
    INTEGER, PARAMETER      :: PD_RESULT_PRINT          = 1
    INTEGER, PARAMETER      :: START_PAGE_GENERAL       = -1
    INTEGER, PARAMETER      :: PD_EXCLUSIONFLAGS        = Z'01000000'
    INTEGER, PARAMETER      :: PD_NOCURRENTPAGE         = Z'00800000'
    INTEGER, PARAMETER      :: PD_EXCL_COPIESANDCOLLATE = IOR(DM_COPIES, DM_COLLATE)

CONTAINS

	FUNCTION printer_setup (hwin, hdc, orientation) RESULT (ok)
		IMPLICIT NONE
		INTEGER(HANDLE),INTENT(IN)   :: hwin
		INTEGER(HANDLE),INTENT(OUT)  :: hdc
		INTEGER, INTENT(OUT)         :: orientation
		INTEGER                      :: lret
		LOGICAL                      :: ok
		TYPE(T_PRINTDLGEX)           :: pdx
		TYPE(T_DOCINFO)              :: di
		TYPE(T_DEVMODE_KT)		     :: devmode
		POINTER(dm, devmode)

        !   PrintDlgEx data structure   
        pdx%lStructSize         = SIZEOF(pdx) 
        pdx%hwndOwner           = hwin
        pdx%hDevMode            = NULL
        pdx%hDevNames           = NULL
        pdx%hDC                 = NULL
        pdx%Flags               = MOR(PD_RETURNDC,         PD_NOPAGENUMS,     &amp;amp;
                                      PD_HIDEPRINTTOFILE,  PD_EXCLUSIONFLAGS, &amp;amp;
                                      PD_USEDEVMODECOPIES, PD_NOSELECTION,    &amp;amp;
                                      PD_NOCURRENTPAGE                        )
        pdx%Flags2              = 0
        pdx%ExclusionFlags      = PD_EXCL_COPIESANDCOLLATE 
        pdx%nPageRanges         = 0     ! all these
        pdx%nMaxPageRanges      = 1     !  items are
        pdx%lpPageRanges        = NULL  !   ignored when 
        pdx%nMinPage            = 0     !    PD_NOPAGENUMS is
        pdx%nMaxPage            = 0     !     included in %flags
        pdx%nCopies             = 1
        pdx%hInstance           = NULL
        pdx%lpPrintTemplateName = NULL
        pdx%lpCallback          = NULL
        pdx%nPropertyPages      = 0
        pdx%lphPropertyPages    = NULL
        pdx%nStartPage          = START_PAGE_GENERAL
        pdx%dwResultAction      = 0

		ok = .FALSE.
		IF (PrintDlgEx(pdx) == S_OK) THEN       ! S_OK = 0
		    IF (pdx%dwResultAction == PD_RESULT_PRINT) THEN
			    hdc             = pdx%hdc
			    di%cbSize       = SIZEOF (di)
			    di%lpszDocName  = LOC("Program output"C) 
			    di%lpszOutput   = NULL
    	
			    !	a DevMode structure is returned with information about
			    !	the selected page orientation: portrait=1, landscape=2
			    dm = GlobalLock (pdx%hDevMode)
			    orientation = INT4(devmode%dmOrientation)
			    IF (orientation /= 2) orientation = 1	! just in case
    			
			    ok = (StartDoc(hdc, di) /= SP_ERROR)
			    IF (.NOT.ok) lret = MessageBox (hwin, "Printer Problem"C,"Error!"C, MB_OK)
			    
		    END IF
		END IF
		
		!   free the memory allocated by PrintDlgEx
		lret = GlobalFree (pdx%hDevMode)
		lret = GlobalFree (pdx%hDevNames)
		 
	END FUNCTION printer_setup

END MODULE printfunc
  


&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2015 20:02:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048258#M114573</guid>
      <dc:creator>Paul_Curtis</dc:creator>
      <dc:date>2015-05-04T20:02:27Z</dc:date>
    </item>
    <item>
      <title>You guys are great</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048259#M114574</link>
      <description>&lt;P&gt;You guys are great programmers,&amp;nbsp;unfortunately&amp;nbsp;both of you&amp;nbsp;are over my head&amp;nbsp;a ways.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;With the code above I'm not sure how to use it in FORTRAN.&amp;nbsp; It has errors when I try to compile.&amp;nbsp; &amp;nbsp;An in the FORTRAN_Winprint.f90 routine I am not sure how to get the main program's window handle and then&amp;nbsp;how to pass it&amp;nbsp;into this routine.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If you guys have any examples I would appreciate it.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2015 21:43:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048259#M114574</guid>
      <dc:creator>Ken2</dc:creator>
      <dc:date>2015-05-05T21:43:00Z</dc:date>
    </item>
    <item>
      <title>You can continue to use the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048260#M114575</link>
      <description>&lt;P&gt;You can continue to use the existing code for now - it still works,. Paul's code just puts up the printer selection dialog, it doesn't do the printing.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2015 23:57:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-window-keeps-coming-up-behind-my-application-window/m-p/1048260#M114575</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-05-05T23:57:30Z</dc:date>
    </item>
  </channel>
</rss>

