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

Sample program REALG output is not as described

dboggs
New Contributor I
465 Views

I am trying to develop a Quickwin program that has its output in a single window (probably the project frame with menus and status bar removed; OK I can do that), with scrollbars. When I run the program I get the output in a child window, somewhat smaller than the project frame, with truncated visibility and scrollbars. When the program ends I can maximize this child window by clicking on the size box in the upper right corner, which produces the right effect. I don't want my users to have to do this manually. How can I maximize the window programmatically?

I remember minimizing a child window programmatically, but I don't remember how and I cannot find it in the documentation. I assume there is a similar command to maximize a window. Can anybody help?

0 Kudos
6 Replies
andrew_4619
Honored Contributor III
465 Views

setwsizeqq I recall

0 Kudos
dboggs
New Contributor I
465 Views

Thanks Andrew. I had already recalled that I used this before, and it does indeed help. But now I move on to the next problem: I need the exact pixel dimensions of the VISIBLE window so that I can divide it exactly in half to locate the various viewports. Or put a simpler way, I need to draw horizontal and vertical lines exactly at the half points to divide the visible area into equal quarters.

I can inquire the size of the frame window using GETWINDOWCONFIG, but this gives the "gross" size which includes window borders, titlebar, statusbar, menubar, and scrollbars. I can also inquire the "size of the visible child window" (so says the documentation) using GETWSIZEQQ, but this includes the scrollbars and--in the vertical direction--possibly the menubar and statusbar. It's hard to tell without a lot of experimentation.

So I need a way to eliminate the scrollbars or at least to get their width so that I can subtract it from the GETWSIZEQQ result. In the horizontal direction I can assume 16 pixels and that works pretty good. In the vertical direction it's not so simple. Still working on it...

0 Kudos
andrew_4619
Honored Contributor III
465 Views

The GetClientRect function  see https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx there will be an interface in IFWIN for that. You get the top bottom left right info of the drawable part of the window.

0 Kudos
dboggs
New Contributor I
465 Views

I would like to experiment with this function, but my limited knowledge of Windows programming impedes it! I am trying this:

USE IFQWIN
USE IFWIN
​TYPE (RECT) recwin
​LOGICAL lstat
​PRINT *, 'This opens a child window to unit 0'
lstat = GetClientRect (GETHWNDQQ (0), recwin) ! or LOC (recwin)?
​PRINT *, 'Left = ', recwin%left
​PRINT *, 'Top = ', recwin%top
PRINT *, 'right = ', recwin%right
​PRINT *, 'bottom = ', recwin%bottom

But I get a compile error "derived type [RECT] has not been declared."

What am I doing wrong (probably something simple due to my ignorance).

 

 

0 Kudos
andrew_4619
Honored Contributor III
465 Views

Look at the MSDN entry I quoted earlier and you will see it is in USER32 lib/dll. Open the fortran USER32.f90 in the compiler include folder and find the interface for GetClientRect . This will tell you how the interface expects things to be declared you will find it is type(t_rect)  and the function return is type integer(bool). I always look at the interface because there are different ways it can be set up to work in fortran and it is not always how you might expect it.

0 Kudos
dboggs
New Contributor I
465 Views
Thank you Andrew. Based on your message I modified my code to read

TYPE (t_rect) recwin
​and it worked. Hooray!

For the record, I had looked in ifwin.for and found nothing useful (it did include Use User32 but I didn't know to look there). In user32.for I found:

INTERFACE 
FUNCTION GetClientRect( &
        hWnd, &
        lpRect)
use ifwinty
  integer(BOOL) :: GetClientRect ! BOOL
    !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'GetClientRect' :: GetClientRect
  integer(HANDLE) hWnd ! HWND hWnd
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpRect
  TYPE (T_RECT) lpRect ! LPRECT lpRect
 END FUNCTION
END INTERFACE
INTERFACE

I'm not sure how all of this translates into the form that I used, especially the bit about hWnd and use ifwinty. I can see that use ifwin already includes user32 and that user32 already includes ifwinty, so it seems that use ifwin or use user32 is all that is necessary. As for the handle, I simply tried GETHWNDQQ(unitnumber) from another example I had. I guess that wouldn't have worked in a Console or Windows application type.

Thank you Andrew for monitoring this forum often and helping those who are well below you in expertise.

0 Kudos
Reply