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

How to open notepad in my GUI

royxu
Beginner
573 Views
Hi,
My program need readingdata from external data file. The default data filename is setup in the GUI. But the problem is when I want to take a look at the data file, I need to go outside to open notepad to read this data file. I wonder whether there is a way here adding a button or menu in the GUIso that data file could be opened in the notepad within GUI, then I can do some editing and saving on this work. Any idea?
Thanks!
0 Kudos
7 Replies
h-faber
Beginner
573 Views
Maybe this link helps:
The code looks like:
Code:
use kernel32
use dfwinty
implicit none

character, pointer :: AppName
type(T_STARTUPINFO) StartInfo
type(T_PROCESS_INFORMATION) ProcessInfo
logical(4) ret

StartInfo%wShowWindow = 1 !SW_NORMAL
StartInfo%cb = 68 !bytes
NULLIFY(AppName)
ret = CreateProcess(AppName,  'Notepad.exe "Filename.txt" ',
NULL_SECURITY_ATTRIBUTES, NULL_SECURITY_ATTRIBUTES, .FALSE.,
CREATE_SEPARATE_WOW_VDM, NULL, AppName, StartInfo, ProcessInfo)
But in this regard I wonder: How do you create a GUI with Fortran? Which compiler/IDE/version? Any GUI builder available? I have never seen any graphical support in Fortran77/90/95 and IVF 8.1, such as Frames, Comboboxes etc. OTOH of course I can see Intel VISUAL Fortran Compiler, but always wondered: Where can I find the graphical part? Where is it?
Could you enlighten me?
0 Kudos
Steven_L_Intel1
Employee
573 Views
I would prefer using ShellExecute for this purpose. Much easier.
0 Kudos
h-faber
Beginner
573 Views
An example is welcome. :smileywink:
Is it for console app too or only for Win/GUI/...?
0 Kudos
Steven_L_Intel1
Employee
573 Views

ShellExecute is for anyone. Here's the VF News article I wrote on it with an example.

Steve Lionel
Visual Fortran Engineering

Win32 Corner is a new feature of the newsletter that illustrates how to use Win32 API routines to do commonly requested tasks.

The ShellExecute API routine is handy for opening a web page, or any document using its natural editing tool. It's equivalent to right clicking on a file and selecting Open - or you can also choose the default action (whatever is listed first), Print or Edit. I've found it most useful for opening a web page with the user's default browser.

Open shellexecute.f90 and reference the numbered comments (!!1, etc.) below:

  1. ShellExecute is part of the Shell API and is defined in module SHELL32. You could also USE DFWIN.
  2. The hWnd argument is the handle of the owner's window. In a Console Application, NULL is the thing to use, but in a Windows Application you might want the main window, and in QuickWin, use GETHWNDQQ(QWIN$FRAMEWINDOW).
  3. lpOperation (referred to as lpVerb in newer versions of the MS documentation) is a C-string that says what to do with the file. "open" is what you'll want most often, but you could also specify "edit" or "print". If the argument is null, then the "default action" is used.
  4. lpFile is the thing we want to open. It could be an ordinary file, or a URL. Note the NUL-termination to make it a C-string.
  5. If we were opening (running) an executable file, command parameters would go here.
  6. You can specify a default directory if you want. NULL_CHARACTER passes the equivalent of a C NULL here.
  7. nShowCmd specifies how you want the window to appear. SW_SHOWNORMAL is the standard behavior, but you could also specify minimized, maximized and whether or not to hide the active window.
  8. If ShellExecute returns a value greater than 32, it succeeded, otherwise an error occurred. Note that ShellExecute returns immediately - it does not wait for the opened application to finish.

Try building and running shellexecute.f90 as a "Fortran Console Application". Enter a favorite URL, such as http://www.intel.com/, or the path to a file on your system, then watch it open!

For more information on ShellExecute, look it up in the Visual Fortran online documentation index.

Message Edited by sblionel on 04-28-2005 12:16 PM

0 Kudos
durisinm
Novice
573 Views
This forum is filled with examples of creating GUIs with Fortran. You have to make calls to the Windows API.
There are third-party tools that simplify the task. Winteracter is one example.
Mike D.
0 Kudos
blwiland
Beginner
573 Views
How does one subscribe to and/or view these newsletters?
0 Kudos
Steven_L_Intel1
Employee
573 Views
The Visual Fortran Newsletter was put out while we were DEC/Compaq and haven't been resumed. My current thought is to periodically post articles here in the forum - editing a full newsletter is rather time-consuming.
0 Kudos
Reply