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

Graphs in a Fortran Windows application (simple dialog based application)

hpb
Beginner
5,399 Views

Hello,

I posted allready a similar question for a quickwin application.

Now I have Fortran Windows Project, which is configured as a "Simple Dialog Based Application". In this application I also want to show the result of a calculation as a graph.

So my questions are:

Is there a possibility to show the resulting graph in the same dialogwhere the user enters the input data? If yes, which dialog elements do I have to use andwhich functions canI use to show the graph?

If this is not possible, how can I show the graphin adiagram with axes on the screen in a seperate window?Which is the "best" way of working to solve that problem? Are there more than one possibilities? Which one ise the easiest to use?

If I try to use the scigraph utility, no additional window gets opened.Doesthe Scigraph utility work with this kind of application at all or is there a mistake in my program?

I'm using CVF 6.1. Does this revision has restrictions concerning showing graphs?

Any help or example would be great.

Thanks in advance. hpb

0 Kudos
36 Replies
hpb
Beginner
2,024 Views

Hello Jugoslav, yes, repositioning works now also.

I decided to try the XeffortLite as you suggest. In a first step I tried to built the sample "as it is". Then I got errors. Some of them I corrected by deletimg the area with the obsolete directives. At the moment I' ve the following messages:

--------------------Konfiguration: XeffortLite - Win32 Debug--------------------
D:src_fortran estxeffortliteXftGDI.f90(146): Datei "XFTTYPES.mod" nicht gefunden.
D:src_fortran estxeffortliteXftGDI.f90(147): Datei "XFTAPI.mod" nicht gefunden.
Ressourcen werden kompiliert...
Compiling Fortran...
D:src_fortran estxeffortliteXFTStrings.f90
D:src_fortran estxeffortliteXFTStrings.f90(128) : Error: This name does not have a type, and must have an explicit type. [PXUNQUOTEDLEN]
CHARACTER(LEN=PXUnquotedLen(sString)):: s
--------------^
D:src_fortran estxeffortliteXFTStrings.f90(273) : Error: This name does not have a type, and must have an explicit type. [PXLOADSTRINGLEN]
CHARACTER(LEN=PXLoadStringLen(ID, hModule)):: s
--------------^
D:src_fortran estxeffortliteXFTStrings.f90(373) : Error: This name does not have a type, and must have an explicit type. [PXLOG]
CHARACTER(LEN=PXLog(iVal, iBase)):: s
--------------^
D:src_fortran estxeffortliteXFTFile.f90
D:src_fortran estxeffortliteXFTFile.f90(265) : Error: Error in opening the Library module file. [XFTSTRINGS]
USE XFTStrings
----^
D:src_fortran estxeffortliteXFTFile.f90(505) : Error: Error in opening the Library module file. [XFTSTRINGS]
USE XFTStrings
----^
D:src_fortran estxeffortliteXFTFile.f90(586) : Error: Error in opening the Library module file. [XFTSTRINGS]
USE XFTStrings
----^
D:src_fortran estxeffortliteXFTFile.f90(577) : Error: This name does not have a type, and must have an explicit type. [XC2F]
sDir=XC2F(sDir)
-----^
D:src_fortran estxeffortliteXFTFile.f90(577) : Error: A CHARACTER data type is required in this context. [XC2F]
sDir=XC2F(sDir)
-----^
D:src_fortran estxeffortliteXFTFile.f90(629) : Error: This name does not have a type, and must have an explicit type. [XC2F]
sSubDir = TRIM(sDir)//""//XC2F(WFDdir%cFileName)
---------------------------------------------------^
D:src_fortran estxeffortliteXFTFile.f90(629) : Error: A CHARACTER data type is required in this context. [XC2F]
sSubDir = TRIM(sDir)//""//XC2F(WFDdir%cFileName)
---------------------------------------------------^
D:src_fortran estxeffortliteXFTFile.f90(644) : Error: A CHARACTER data type is required in this context. [XC2F]
sSubDir = TRIM(sDir)//""//XC2F(WFDfile%cFileName)
---------------------------------^
D:src_fortran estxeffortliteXftGDI.f90
D:src_fortran estxeffortliteXftGDI.f90(1668) : Error: The type of the actual argument differs from the type of the dummy argument. [0]
iSt = ScrollWindow (hWindow, iDx, iDy, 0, 0 )
---------------------------------------^
D:src_fortran estxeffortliteXftGDI.f90(1668) : Error: The type of the actual argument differs from the type of the dummy argument. [0]
iSt = ScrollWindow (hWindow, iDx, iDy, 0, 0)
------------------------------------------^
D:src_fortran estxeffortliteXFLOGM.F90
D:src_fortran estxeffortliteMain.f90
D:src_fortran estxeffortliteMain.f90(61) : Error: Error in opening the Library module file. [XFTGDI]
USE XFTGDI
----^
D:src_fortran estxeffortliteMain.f90(69) : Error: This derived type name has not been declared. [X_DC]
TYPE(X_DC):: xDC
-----^
D:src_fortran estxeffortliteMain.f90(96) : Error: This name does not have a type, and must have an explicit type. [XDC]
xDC%hDC = PD%hDC
------^
D:src_fortran estxeffortliteMain.f90(136) : Error: Error in opening the Library module file. [XFTGDI]
USE XFTGDI
----^
D:src_fortran estxeffortliteMain.f90(137) : Error: Error in opening the Library module file. [XFTFILE]
USE XFTFILE
----^
D:src_fortran estxeffortliteMain.f90(145) : Error: This derived type name has not been declared. [X_DC]
TYPE(X_DC):: xDC
-----^
D:src_fortran estxeffortliteMain.f90(152) : Error: This name does not have a type, and must have an explicit type. [XGETSAVEFILE]
IF (XGetSaveFile(Dlg%hWnd,sFileDir,sFileName,sExts=(/"*.wmf"/),sTypes=(/"Windows metafile (*.wmf)"/), &
----^
D:src_fortran estxeffortliteMain.f90(152) : Error: A logical data type is required in this context. [XGETSAVEFILE]
IF (XGetSaveFile(Dlg%hWnd,sFileDir,sFileName,sExts=(/"*.wmf"/),sTypes=(/"Windows metafile (*.wmf)"/), &
----^
D:src_fortran estxeffortliteMain.f90(155) : Error: This name does not have a type, and must have an explicit type. [XDC]
xDC%hDC = CreateMetaFile(TRIM(sFileDir)//""//TRIM(sFileName)//CHAR(0))
---^
D:src_fortran estxeffortliteMain.f90(182) : Error: Error in opening the Library module file. [XFTGDI]
USE XFTGDI
----^
D:src_fortran estxeffortliteMain.f90(184) : Error: Error in opening the Library module file. [XFTFILE]
USE XFTFILE
----^
D:src_fortran estxeffortliteMain.f90(191) : Error: This derived type name has not been declared. [X_DC]
TYPE(X_DC):: xDC
-----^
D:src_fortran estxeffortliteMain.f90(192) : Error: This derived type name has not been declared. [X_BITMAP]
TYPE(X_BITMAP):: xBmp
-----^
D:src_fortran estxeffortliteMain.f90(202) : Error: This name does not have a type, and must have an explicit type. [XGETSAVEFILE]
IF (XGetSaveFile(Dlg%hWnd,sFileDir,sFileName,sExts=(/"*.bmp"/),sTypes=(/"Windows bitmap (*.bmp)"/), &
----^
D:src_fortran estxeffortliteMain.f90(202) : Error: A logical data type is required in this context. [XGETSAVEFILE]
IF (XGetSaveFile(Dlg%hWnd,sFileDir,sFileName,sExts=(/"*.bmp"/),sTypes=(/"Windows bitmap (*.bmp)"/), &
----^
D:src_fortran estxeffortliteMain.f90(207) : Er ror: This name does not have a type, and must have an explicit type. [XDC]
xDC = XMemoryDC(Rect%Right, Rect%Bottom)
---^
D:src_fortran estxeffortliteMain.f90(207) : Error: This name does not have a type, and must have an explicit type. [XMEMORYDC]
xDC = XMemoryDC(Rect%Right, Rect%Bottom)
---------^
D:src_fortran estxeffortliteMain.f90(210) : Error: This name does not have a type, and must have an explicit type. [XGETBITMAP]
iSt = XGetBitmap(xDC, xBmp, Rect%Left, Rect%Top, Rect%Right, Rect%Bottom)
---------^
D:src_fortran estxeffortliteMain.f90(211) : Error: This name does not have a type, and must have an explicit type. [XSAVEBITMAP]
iSt = XSaveBitmap(xBmp, TRIM(sFileDir)//""//sFileName, 8)
---------^
D:src_fortran estxeffortliteMain.f90(213) : Error: This name does not have a type, and must have an explicit type. [XDELETEDC]
iSt = XDeleteDC(xDC)
---------^
D:src_fortran estxeffortliteMain.f90(214) : Error: This name does not have a type, and must have an explicit type. [XDELETEBITMAP]
iSt = XDeleteBitmap(xBmp)
---------^
D:src_fortran estxeffortliteMain.f90(223) : Error: Error in opening the Library module file. [XFTGDI]
USE XFTGDI
----^
D:src_fortran estxeffortliteMain.f90(231) : Error: This derived type name has not been declared. [X_DC]
TYPE(X_DC):: xDC
-----^
D:src_fortran estxeffortliteMain.f90(236) : Error: This variable or component must be of a derived or structure type [XDC]
xDC%hDC = hDC
^
D:src_fortran estxeffortliteMain.f90(236) : Error: This is not a field name that is defined in the encompassing structure. [HDC]
xDC%hDC = hDC
----^
D:src_fortran estxeffortliteMain.f90(248) : Error: Error in opening the Library module file. [XFTGDI]
USE XFTGDI
----^
D:src_fortran estxeffortliteMain.f90(252) : Error: This derived type name has not been declared. [X_DC]
TYPE(X_DC):: xDC
-----^
D:src_fortran estxeffortliteMain.f90(259) : Error: This name does not have a type, and must have an explicit type. [XDC]
CALL XSetWindow(xDC, 0., 0., 200., 200.)
----------------^
D:src_fortran estxeffortliteMain.f90(264) : Error: This name does not have a type, and must have an explicit type. [XCOLOR_LTRED]
CALL XSetPen(xDC, XCOLOR_LTRED, iWidth=3, iStyle=PS_DOT)
------------------^
D:src_fortran estxeffortliteMain.f90(264) : Error: Keyword arguments are invalid without an explicit interface. [IWIDTH]
CALL XSetPen(xDC, XCOLOR_LTRED, iWidth=3, iStyle=PS_DOT)
--------------------------------^
(313) : Severe: Too many errors, exiting
Fehler beim Ausfhren von df.exe.

XeffortLite.exe - 43 Fehler, 0 Warnung(en)

Can you help again?

Thanks in advance hpb

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,024 Views
Ah yes, XFTStrings Open-mouthed smiley [:-D] has some "advanced" f95 features that are difficult to swallow even for CVF 6.6. The remaining errors are mostly the consequence of that, in an avalanche manner.

I think that only the function XC2F is used in the rest of the code; you can safely get rid of the rest from XFTStrings.

Last two arguments of ScrollWindow in XFTGDI.f90 should be NULL_RECT rather than zeros.

I don't see any other "independent" errors in the forest you posted -- I hope there isn't any.

'Bye 'til tomorrow smiley [:-)]




0 Kudos
hpb
Beginner
2,024 Views

Hello,

again I'm a step further now. The XeffortLite Example works (with the xflogm.f90 from my dialogtest project).

My next step is to add the XeffortLite fuctionality to my test project which is derived from my productive project.

I added XFLOGM.f90,XFTLITE.f90,XFTGDI.f90, XFTSTRINGS.f90 and XFTWIND.f90 to my project and tried to built.

Then I got the following messages (only the first messages, the complete output is in the appended file):

--------------------Konfiguration: EKKR - Win32 Debug--------------------
Compiling Fortran...
D:src_fortran est_dialog_graphXftGDI.f90
D:src_fortran est_dialog_graphXftGDI.f90(147) : Error: Error in opening the Library module file. [XFTTYPES]
USE XFTTYPES
----^
D:src_fortran est_dialog_graphXftGDI.f90(148) : Error: Error in opening the Library module file. [XFTAPI]
USE XFTAPI
----^
D:src_fortran est_dialog_graphXftGDI.f90(284) : Error: This derived type name has not been declared. [X_DC]
TYPE (X_DC), INTENT(INOUT):: xDC
------^
D:src_fortran est_dialog_graphXftGDI.f90(282) : Error: This name does not have a type, and must have an explicit type. [XDC]
RECURSIVE SUBROUTINE XSetPen_1(xDC, iColor, iStyle, iWidth)
-------------------------------^
D:src_fortran est_dialog_graphXftGDI.f90(307) : Error: This derived type name has not been declared. [X_DC]
TYPE (X_DC), INTENT(INOUT):: xDC
------^
D:src_fortran est_dialog_graphXftGDI.f90(308) : Error: This derived type name has not been declared. [X_PEN]
TYPE (X_PEN), INTENT(IN):: xPen
------^

Has that again to do with the directives inside? Which directives area can I delete?

Or is there another problem?

Thanks in advance hpb

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,024 Views
Either add !DEC$DEFINE XLITE at the top of XFT*.f90 files, or add XLITE to Project/Settings/Fortran/Preprocessor. This is documented... somewhere.
0 Kudos
hpb
Beginner
2,024 Views

Hello Jugoslav,

meanwhile my testproject, which is derived from the complete project is running well.

In my complete project I also replaced all "use dflogm" and "use dialogm" with "use xflogm". I also XLITE to my project settings. So I'm able tu compile and to link the project. But now I have the following problem:

When I reach

if ( DlgDoModal ( dlg, dlg % dlgid, dlg % list(UBOUND(dlg % list, 1)) % id, &
hwndParent, DlgModalProc, .false. ) .eq. -1 ) then

my program does not respond any more.

Do you have any idea what I can check? Do you know this effect? Or is this question to unspecific?

Thanks in advance hpb

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,024 Views
Well, define "does not respond any more" :-).

DlgModal is a "modal" function, in the sense that it will continue to "loop" within system code, "waking up" every time when a message is received to the dialog. Whenever that happens, DlgCommonProc (if I recall the name correctly) will be called; one of the first messages will be WM_INITDIALOG, and DlgSomethingProc will dispatch it to your DLG_INIT callback.

So, few things to check:
* does it enter case(WM_INITDIALOG) block within the Xflogm code?
* does it call DlgInit?
* does it re-enter DlgSomethingProc after that.

An auxiliary tool you can use is Spy++ from the CVF program group -- it shows you the list of active windows (try to find your dialog in there) and you may inspect properties and messages for each.

The problem I had with your code is that it moves the frame window out of the screen but the dialog is given "Center" style -- Xflogm will attempt to center it relative to the parent window (rather than screen), rendering it "invisible" (i.e. out of screen), and Spy++ will show WS_VISIBLE style, but coordinates around (4000, 4000). If that's the case, simply remove the "Center" style.
0 Kudos
hpb
Beginner
2,024 Views

Hello Jugoslav,

yes, again your tip helped me further. In my test project I had removed the center flag. Now I went back to my original project, where the center style flag was still set. Sorry, for that. Now I can draw graphs in my dialog and I can write texts. Your advices were very helpfull.

Most of the things which I still need are to improve the appearence of the dialog. So do you have a further tip, how I can set the color of the control field from grey at the moment to white?

Thanks in advance hpb

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,024 Views
Xflogm has DLG_COLOR and DLG_BKCOLOR control indices, applicable to most types of controls (except, notably, buttons and group boxes). The argument should be in form #BBGGRR, (see the XFLOGM reference linked above).
0 Kudos
hpb
Beginner
2,024 Views

Hello Jugoslav,

I try to get theIDC_OWNERDRAW control background with a self defined color. I use the following code:

bRet = DlgInit(PKDFPRA0G, dlg_g)
bret = DLGSET (dlg_g, IDC_OWNERDRAW, #888800, DLG_BKCOLOR)
bret = DLGSETSUB (dlg_g, IDOK, ButtonSUB)
bret = DLGSETSUB (dlg_g, IDC_BUTTONF16, ButtonSUB)
bret = DLGSETSUB (dlg_g, IDCANCEL, ButtonSUB)
bRet = DLGSETSUB (dlg_g, Dlg_g%dlgid , OnDlgInit)
bRet = DLGSETSUB (dlg_g, IDC_OWNERDRAW, OnDrawItem)
iRet = DlgModal(dlg_g)

I think

bret = DLGSET (dlg_g, IDC_OWNERDRAW, #888800, DLG_BKCOLOR)

should change the background color of the control. Somwhere I read that I have to update the dialog to get the new color setting. I tried to do thatwith dlgflush and with updatewindow in the OnDlgInit and in the OnDrawItem functions. But nothing happened, I still get the grey background. Do you know why?

Thanks in advance hpb

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,024 Views
Ah, it was a misunderstanding; I thought you asked about some another control.

To clear the background of the owner-drawn control, just draw a rectangle (Rectangle or MSFWIN$Rectangle, depending on if you use DFWINA or DFWIN) in an appropriate color (CreatePen), over the entire surface of the control (GetClientRect(GetDlgItem(Dlg%hWnd,IDC_OWNERDRAW))).
0 Kudos
hpb
Beginner
2,024 Views

Hello,

meanwhile I'm nearly ready with my application. So I want to thank all the people who helped me with the problem. Especially Jugoslavdujic gave me essential advice to bring my application from a completely non graphical mode to a state where I can create dialogs with graphical elements. For those whoare interested in the result, I've added a screenshot of an exemplarily dialog with a diagram containing axes and graphs.

greetings hpb

0 Kudos
hpb
Beginner
2,024 Views

Hello,

a further question to this application:

I have several graphs in the dialog and I want to chose the visibility of the graphs with check boxes. So I use a function OnCheck wherein I draw the graphs if the checkbox control has the status checked. But my modification is only visable when Iminimize and maximize the window orwhen I cover thewindow with anotherwindow and recover it again.

Is there a function to do that job, to update the control or the complete dialog? I tried DLGFLUSHALL, but that did not helped.

Thanks in advance hpb

0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,024 Views
Yes, that's how drawing in Windows works -- whenever (a part of the) window needs to be redrawn, it sends a WM_PAINT message, which will eventually trigger the OnOwnerDraw callback.

To force redrawing of the dialog (i.e. achieve the same effect as minimizing+maximizing the window), call InvalidateRect(Dlg%hWnd, NULL_RECT). You need to do that only when you want the drawing changed; but the actual drawing has to be done in OnOwnerDraw.
There, you can check the states of the checkboxes, e.g. DlgGet(Dlg, IDC_CHECK1, bChecked) and draw the graph only if bChecked is true. In the OnCheck function, the only thing to do is to call InvalidateRect.
0 Kudos
hpb
Beginner
2,024 Views

Hello Jugoslav,

great. Again you gave me the essential advice.

I used retlog = InvalidateRect(Dlg%hWnd, NULL_RECT , .false.) and that works.

Thank you very much. hpb

0 Kudos
anthonyrichards
New Contributor III
2,024 Views
May I compliment you on your smart-looking dialog! Well done.
0 Kudos
hpb
Beginner
2,024 Views

Hello,

again a question. I don't know if this is a very stupid question, but I can not explain the behaviour of the following code:

is_checked = .TRUE.
iRet = DlgSet(dlg_g , IDC_CHECK1test , is_checked)
bRet = DlgSetLog(dlg_g , IDC_CHECK1test , .TRUE. , DLG_ENABLE)

iRet = DlgModal(dlg_g)

lRet = DLGGET(dlg_g, IDC_CHECK1test , is_checked)

I'm setting the value of a checkbox cotrol to .true. In the dialog afterwards it's ok. But when I query the value after the modal dialog I get always .FALSE. as a result. There are no other functions which use or modify the control IDC_CHECK1test while the dialog is in work.

Can you tell me why I don't get true in this case as a result?

Thanks in advance hpb

0 Kudos
Reply