How to use the main Window in a Visual Fortran SDI application

How to use the main Window in a Visual Fortran SDI application

Dear all,

I'm currently using Vis.Fortran 6.1a. I've done a lot of Quickwin programming and learned how to write or fraw to quickwin child windows.

Now I have to port some functions to a SDI or MDI envirnment. I have menus and toolbars including tooltips working nicely, but I do not find any way to use the remaining blank area for text or graphics output. I would prefer to open it as a Fortran logical unit and just to make formatted write to it, but any other way would also be welcome.

All examples seem to use the Quickwin functions. Even when I try to open a paint structure, with EndPaint I get a compiler error that Quickwin may not be used in a console application.

Maybe I just understand something completely wrong?

Burkhard

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

When you register your window class, you assign a window
procedure (e.g. MainWndProc) which should handle your
WM_PAINT commands for any window that you subsequently
create of that class.
These commands are issued e.g. after
invalidating the client window e.g.

retlog=getclientrect(hWnd,rc)
retlog=invalidaterect(hWnd,rc,.true.)
ret=SendMessage(hWnd,WM_PAINT,0,0)

where hWnd is the window handle and rc is a T_RECT
structure to store the co-ords of the corners of
the window.

After getting a handle, hWndDC, to a drawing context
and creating a paint structure, ps, using BeginPaint, e.g.

hWndDC=BeginPaint(hWnd,ps)
CALL IGPLOT(hWnd, hWndDC,ISTATUS)
retlog=EndPaint(hWnd,ps)

Your WM_PAINT handler should then call the routine (here called IGPLOT)
that does all your drawing using commands such as e.g.

hnewPen=CreatePen(PS_DASH,0,ICOLOR(I))
hOldPen=SelectObject(hWndDC,hnewPen)
DO  K=KBEGIN,KHALT
retlog=MoveToEx(hWndDC,IXBEG(K), IYBEG(K),NULL_POINT)
retlog=MSFWIn$LineTo(hWndDC,IXEND(K), IYEND(K))
ENDDO
hpen=SelectObject(hWndDC,hOldPen)
retlog=DeleteObject(hpen) 

where you supply hWndDC, the handle to a drawing context.
Put your text output in another routine and call
it as well. BeginPaint creates a paint structure, ps, which should
then be destroyed by a call to EndPaint when drawing is complete. HTH.

Thanks a lot. Now it works. It was the invalidation that was missing.

Burkhard

Once you figure out principles of drawing/WM_PAINT, you may want to look at my XFTGDI module. Although it's not source-level compatible with QuickWin routines, I believe you'll find it more similar and easier to use than pure APIs.

Jugoslav

Jugoslav
www.xeffort.com

Thank you for that tip. While unfortuantely the example project does not compile under VF6.1a and exits with too many errors, looking into the code immediately helped with another question. I will keep the source holy and use it as primary "how to" source.

While the documentation of VisualFortran is enourmous, it still only covers a microscopic part of this extremely powerfull language.

Thanks again for both posts.

Burkhard

Sorry for inconvenience; there are notes in XFT*.f90 about portability across various CVF versions. All errors are consequence of Windows API symbols redefined/undefined, because DFWIN(TY) modules are different.

I've never had 6.1a, but on 6.6a the following helps (on 6.1 will be something similar):
- Delete declarations of IMAGE_* and LR_* from XFTGDI; (but leave INTERFACE to LoadImageA)
- Add USE DFWINTY to XFTGDI
- Delete declarations of OFN_EXPLORER from XFTFile.

Guess I'll fix the samples to use !DEC$IF DEFINED directives, so the code would be compilable just in few steps. XFT full has a private subset of API declarations (i.e. it doesn't USE DFWIN at all), so it won't be issue there; I didn't want to burden lite version with it.

Jugoslav

Jugoslav
www.xeffort.com

Leave a Comment

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