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

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

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

37 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Scigraph is QuickWin only - it does not work with any other project type. CVF has no specific graphing support at all - you can do most anything you want in a window with Win32 calls.

Do a web search for "pgplot" - it may be of interest. Or there are third party libraries such as Winteracter and GINOMENU that can help.

Steve - Intel Developer Support

I use CVF 6.6D. Here isa Fortran Windows project developed with itthat displays a dialog box and draws on it by way of a static text control that has been given the Owner-Draw property, after its creation, by editing the resource script. Every time the control needs to be redrawn (because some or all of it has been made visible, or because you want to change the data plotted there), a WM_DRAWITEM Windows message is sent to, or must be sent by you, to the dialog box's window procedure (by default this is called DefDlgProc which you do not need to concern yourself with). Because the control has the Owner-draw property, Windows will not draw it for you. This means that you must intercept the WM_DRAWITEM message and draw the control's background and any other features (such as a graph) you want on it. This is done by what is called sub-classing, where you substitute a new dialog box procedure (called NewDlgProc in the attached code)for the default one. Then you intercept the WM_DRAWITEM message in your new procedure and then pass on all other Windows messages to the original dialog box procedure so that the rest of the dialog box continues to be drawn and function correctly. After you intercept the WM_DRAWITEM message, you do your sums, generate your data and then drawyour graph (or graphs)onto the control's 'device context', which is just a specially-set aside area of memory where a bitmap image of the control is kept, along with details of what background 'brush' and line-drawing 'pen' is to be used. These latter two things can be changed, as the included code shows, so that graphs in various colours can be drawn onto the control.

In order for you to generate a WM_DRAWITEM message to redraw the control and hence replot your new data, you use the InvalidateRect Windows function (giving windows the handle to the Owner-drawn control) to tell Windows to redraw the whole of it. Windows then issues the WM_DRAWITEM command for you.

I have added a couple of buttons to show how you can modify and recompute the graphed data and redisplay it. A screen shot is included in the attached archive. To use the attached code, just unzip it and it should become a useable workspace and project. called OWNERDRAW.If you have any problems with the code, just e-mail me.

Attachments: 

AttachmentSize
Downloadapplication/zip ownerdraw.zip29.56 KB
anthonyrichards:I use CVF 6.6D.

6.6D???

Steve - Intel Developer Support

Oops! 6.6C actually!

Hello,

my problem still exists. I did meanwhile the following:

I loaded the example project ofanthonyrichards (thank you for your help) and had a look on it. Therein I found a dialog with a rectangular area where the graph(s) should get displaydI think. Seems to be what I need. But unfortunately I cannot built the project, because I get errors while compiling/linking.The error messages are documented in the attached Zip-File in messages.txt.

I also reduced my existing project to a minimumand included it also in the zip-file. In the project there is a dialog with a rectangular area where I want to draw my graphs. Can anybody help me further what kind of object I have to use in the dialog and how I can draw in that area with my existing project. Which functions can I use? Can anyonedraw a sample line in my project?Whatever I try, I'm not successfull. So, is my project anyway applicable to do what I plan? Do I have to configure my project differently?

Thanks in advance hpb

Attachments: 

AttachmentSize
Downloadapplication/zip test_dialog_graph.zip557.18 KB

The problem is that you're using CVF6.1, which is ancient by all reasonable means of measuring. Its DFWIN headers don't contain all the API functions and constants used in Tony's code. I'll give you an overview of necessary changes:

1)
D:src_fortranownerdrawOWNERDRAW.f90(191) : Error: The type of the actual argument differs from the type of the dummy argument. [0]
retint=InvalidateRect(GetDlgItem(dlg%hWnd,IDC_OWNER),0, .true.)

Replace the zero with NULL_RECT

2)
D:src_fortranownerdrawONOWNERDRAW.F90(32) : Error: Not a valid attribute for the DEC$ ATTRIBUTES directive. [DECORATE]
!DEC$ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS: 'SetDCPenColor':: SetDCPenColor

Replace the last line with

!DEC$ATTRIBUTES DEFAULT, STDCALL, ALIAS: '_SetDCPenColor@8':: SetDCPenColor

3) Add
INTEGER, PARAMETER:: DC_PEN = 19

Independently of Tony's code, you might also take a look at the old XFLOGM of mine; apart from other things, it allows for DLG_DRAWITEM callback, for drawing on the owner-drawn static controls. I think it would compile under 6.1 (no guarantees). You may also be interested in XGraph sample; although you could not compile it, you could reuse some tricky code for graph drawing and scaling.

Both XFLOGM and XFTGDI are contained in the XeffortLite sample, which demonstrates drawing in the dialog. Again, I'm not sure if it compiles with 6.1, but you can give it a try.

Jugoslav
www.xeffort.com

Hello Jugoslavdujic,

thank you for your quick answer. I will try that.

Can you tell me, if my projec I posted is applicable to draw lines in a dialog? Or do I have to reconfigure it with other settings?

Thanks in advance hpb

Try XFLOGM; first try to build my samples separately, and if they succeed, copy the Xflogm.f90 to your project, and replace all USE DFLOGM with USE XFLOGM. Then, follow the instructions (see DLG_DRAWITEM section, and Remarks therein -- you have to manually edit the .rc file to convert the static control into SS_OWNERDRAW).

For the drawing itself, you have to use DFWIN (Windows API) routines (MSFWIN$Rectangle, SelectObject etc.). Alternatively, you can use the XFTGDI routines, (again, if you manage to compile the XFTGDI.f90 from XeffortLite), as they're simpler to use and offer easier scaling (because they come in _W pairs, similar to QuickWin ones). Good luck, and post here if you have problems.

Jugoslav
www.xeffort.com

Sorry to hear you have problems with the code. Why not try upgrading? Here's the site:

http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=8008d7c682f02110d7c682f02110275d6e10RCRD

CVF 6.1 can't be upgraded for free. You'd have to buy a 6.5 or 6.6 upgrade from soneome who still has an unused copy to sell.

Steve - Intel Developer Support

Hello JugoslavDujic,

I did as you suggested. I loaded the DialogTest.zip from the page I which I reached with your link (XFlogm). Afterwards I unzipped the file and opened the DialogTest.dsp therein.

But I get the following errors:

--------------------Konfiguration: DialogTest - Win32 Release--------------------
Ressourcen werden kompiliert...
Compiling Fortran...
D:src_fortranDialogTestXFLOGM.F90
D:src_fortranDialogTestDlgTest.f90
D:src_fortranDialogTestDlgTest.f90(61) : Error: The attributes of this name conflict with those made accessible by a USE statement. [IMAGE_BITMAP]
INTEGER,PARAMETER:: IMAGE_BITMAP =0
--------------------^
D:src_fortranDialogTestDlgTest.f90(62) : Error: The attributes of this name conflict with those made accessible by a USE statement. [IMAGE_ICON]
INTEGER,PARAMETER:: IMAGE_ICON =1

and so on until = 8000

What am I doing wrong?

Thanks hpb

You aren't doing anything wrong -- as noted in the code, these declarations are needed only for CVF (DVF) 5.0. For some reason, your compiler does not recognize the preceding !DEC$IF statement -- just delete the offending lines.

Please bear with us -- the problem is that your compiler, or, precisely, Windows API declarations provided with it, are incomplete (they were upgraded by Compaq/Intel in all subsequent versions, step by step). Since we don't have 6.1 anymore, we're forced to guess what's in there.

The good news is that Xflogm.f90 compiles. The remainder is just the test code.

Please try the same with XeffortLite sample later (it's supposed to have a newer version of Xflogm, as well as Xftgdi.f90); you might encounter similar problems, but I think it's reasonably close to be compilable with 6.1.

Jugoslav
www.xeffort.com

Hello,

I did as suggested and the errors mentioned disappeared. Now I get the following message:

D:src_fortranDialogTestXFLOGM.F90
D:src_fortranDialogTestDlgTest.f90
Linker-Vorgang luft...
LINK : fatal error LNK1104: Datei "iflogm.lib" kann nicht geoeffnet werden

In a next step I removed the following lines:

!DEC$ IF (.NOT.DEFINED(__INTEL_COMPILER_))
!DEC$ OBJCOMMENT lib: "iflogm.lib"
!DEC$ENDIF

because I think iflogm.lib is for Intel Fortran. The result is:

Compiling Fortran...
D:src_fortranDialogTestXFLOGM.F90
D:src_fortranDialogTestDlgTest.f90
Linker-Vorgang luft...
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGGETRES@12
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGPARSERES@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGID2HWND@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGSENDMESSAGE@16
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGENABLEWINDOW@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGISWINDOWENABLED@4
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGDOCALLBACK@16
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGHWND2ID@4
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGEXECUTEDLGINIT@12
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGDOMODAL@20
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGCREATEFORTDIALOGCLASS@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGDOMODELESS@28
DialogTest.exe : fatal error LNK1120: 12 unaufgeloeste externe Verweise

Then I tried to use dflogm.lib instead of iflogm.lib:

!DEC$ OBJCOMMENT lib: "dflogm.lib"
!DEC$ OBJCOMMENT lib: "user32.lib"
!DEC$ OBJCOMMENT lib: "comctl32.lib"
The result is now:

Compiling Fortran...
D:src_fortranDialogTestXFLOGM.F90
D:src_fortranDialogTestDlgTest.f90
Linker-Vorgang luft...
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGDOMODAL@20
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGCREATEFORTDIALOGCLASS@8
DialogTest.exe : fatal error LNK1120: 2 unaufgeloeste externe Verweise

Any idea what I can do now to get the project running?

Thanks in advance hpb

hpb:

Compiling Fortran...
D:src_fortranDialogTestXFLOGM.F90
D:src_fortranDialogTestDlgTest.f90
Linker-Vorgang luft...
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGDOMODAL@20
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _DLGCREATEFORTDIALOGCLASS@8
DialogTest.exe : fatal error LNK1120: 2 unaufgeloeste externe Verweise

I think I see what happened: at some point, Compaq changed some prototypes of functions from Dflogm.lib (DlgDoModal received an extra argument, and DlgCreateFortDialogClass was deleted; type DialogExtraBytes was extended). When I was adapting the Xflogm, I didn't know when exactly -- I thought it was in CVF 6.5, but judging on your link errors it was some time between 6.0 and 6.1.

Please open your original Dflogm.f90 (C:Program filesMicrosoft Visual StudioDfInclude) and the Xflogm.f90; compare the lines where the string "650" occurs in the latter -- the test (_DF_VERSION_ < 650 refers to the compiler older than 6.5); change "650" to "610" accordingly (or delete the offending lines).

Jugoslav
www.xeffort.com

Hello Jugoslav,

I did as you suggested. Now the example program is working .

In the next step I added the xflogm.f90 to my test project.and I was able to compile it. Unfortunately I have linker errors, where I don't kow how to resolve:

Ressourcen werden kompiliert...
Compiling Fortran...
D:src_fortran est est_dialog_graphXFLOGM.F90
df: info: Some interprocedural optimizations may be disabled when compiling into separate object files
D:src_fortran est est_dialog_graphluk_int_str.for
D:src_fortran est est_dialog_graphekkr.for
D:src_fortran est est_dialog_graphcbfunctions.for
Linker-Vorgang luft...
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlggetres_@12
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgparseres_@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgid2hwnd_@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgsendmessage_@16
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgenablewindow_@8
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgiswindowenabled_@4
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgdocallback_@16
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlghwnd2id_@4
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgexecutedlginit_@12
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _gethwndqq_@4
XFLOGM.OBJ : error LNK2001: Nichtaufgeloestes externes Symbol _dlgdomodal_@24

Do you know a solution?

Thanks in advance hpb

Boy those are strange -- you seem to have "append underscore to external names" and "external name representation: lowercase" in Project/Settings/Fortran/External procedures. Is there a particular reason for that?

If there is, please switch those off for Xflogm.f90 (in the same Project settings page). Alternatively, !DEC$ATTRIBUTES DEFAULT should be specified for those routines in Xflogm.f90, but (again) I'm not sure in which CVF version !DEC$ATTRIBUTES DEFAULT was introduced.

Jugoslav
www.xeffort.com

Hello,

yes, you are right. I'm impressed. I changed the settings for the Xflogm.f90 and now I can compile and link my project. When I run it, I get a runtime error if pressing the OK button:

forrtl: severe (157): Program exception - access violation

Image PC Routine Line Source

USER32.dll 7E433513 Unknown Unknown Unknown

.....

When I debug the project I find the routine Dialog2Data where the following function callfailes(xflogm,f90):

!=== end JD's revision =======
case (ctrl_edit)
dummyi = DlgSendMessage( hwndControl, WM_GETTEXT, &
STRSZ, loc(dlg % list(index) % charvalue(1)) )

with

hwndControl = 2557476 and with

dlg % list(index) % charvalue(1) = Undefined adress.

I think "dlg % list(index) % charvalue(1) = Undefined adress" is the problem. But why? Do you know?

Thanks in advance hpb

I took your code and inserted the Xflogm.f90, but I can't reproduce it.

1) Are you sure you replaced USE XFLOGM everywhere? In your code, you had USE DIALOGM twice and USE DFLOGM once (those are equivalent mutually, but not equivalent with XFLOGM). (I also managed to get a crash if I had USE DFLOGM within ButtonSUB routine).

2) There's an additional catch: XFLOGM will attempt to center the dialog relative to the parent window, not to the screen; since your frame window is at (5000, 5000) you won't see the dialog. Please replace it with (500, 500) for the time being; (there's a better cure, but let's get it to work first).

3) Please take declaration of Dlg out of forms.cmn and move it to the body of PROGRAM; it's not a good idea to have it in a common in general.

4) Minor style note: DlgModal will return IDOK or IDCANCEL, so there's no need for KEY global variable. If you want to manipulate return value, use DlgSetReturn.

Jugoslav
www.xeffort.com

Hello,

meanwhile my sample project is running with xflogm.

To point 2):My frame window is now in the visible area of the screen, but as you can see in my example code, I always positioned the (new) windows with the upper left corner on the same position as the predecessor. Thats why the users start the application more than one time simultaniously and with the new behaviour all windows are on the same place. Is there a possibility to position the window in the OnDlgInit-Function?

To point 3): I'm forced to remove the declaration of dlg from the common block, otherwise there are compiler errors.

To point 4): The variable key is declared as global, because in the complete project it is used in other routines.

My next questions are now, which controll do I vave to add in the dialog now, and how can I draw lines or write text in it.

Further help would be great.

Thanks in advance hpb

2) Yes, you can reposition the dialog in OnDlgInit, but remove the "Center" style from the dialog before that.

As for the drawing:
a) add an identifier other than IDC_STATIC to the current frame control, e.g. IDC_DRAWING
b) open the .rc file as text (File->Open->Open as) and replace SS_BLACKFRAME with SS_OWNERDRAW for IDC_DRAWING. Save & close.
c) install the "callback" throug DlgSetSub(Dlg, IDC_DRAWING, OnOwnerDraw)
d) See the OnOwnerDraw routine for how the actual drawing is made (for the start, it is erased by MSFWIN$Rectangle)

Have in mind that:
* OnOwnerDraw is called every time when (a part of) the drawing is physically revealed on the screen
* However, it is not refreshed automatically; when you want to change the drawing, call iSt=InvalidateRect(GetDlgItem(Dlg, IDC_DRAWING), NULL_RECT,.FALSE.)
to "force" OnOwnerDraw to be called (don't CALL it directly!)
* XFTGDI is generally simpler to use than DFWIN drawing routines (which are prone to memory leaks if you're not careful enough to DeleteObject for every thing you create). The XeffortLite sample is more elaborate than DlgTest, and also contains routines for image printing, exporting into WMF and BMP formats (should you ever need it). If you can compile that (replace the Xflogm.f90 with your adapted one), it could be a better place to start.

And, finally, if you don't ever need the QuickWin frame window, it would be better to rebuild your application as "Windows Application" -- just replace PROGRAM with WinMain, as in XeffortLite sample. You will have to re-create the project workspace, though (in order to eliminate "QuickWin application").

Jugoslav
www.xeffort.com

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

Ah yes, XFTStrings 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

Jugoslav
www.xeffort.com

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

Attachments: 

AttachmentSize
Downloadtext/plain MessagesEkkrXeffortLite.txt5.88 KB

Either add !DEC$DEFINE XLITE at the top of XFT*.f90 files, or add XLITE to Project/Settings/Fortran/Preprocessor. This is documented... somewhere.

Jugoslav
www.xeffort.com

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

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.

Jugoslav
www.xeffort.com

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

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).

Jugoslav
www.xeffort.com

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

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))).

Jugoslav
www.xeffort.com

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

Attachments: 

AttachmentSize
Downloadapplication/zip dfspg_2.zip36.27 KB

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

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.

Jugoslav
www.xeffort.com

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

May I compliment you on your smart-looking dialog! Well done.

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

Leave a Comment

Please sign in to add a comment. Not a member? Join today