Re: "Dialogs" in AppGraphics

Klaus,

You shouldn't have to call setdialoghotkeys(.FALSE.) when closing your window.  That setting is specific only to the current window, so it shouldn't affect any other windows that may be open.  Furthermore, any new window will always default to .FALSE. regardless of earlier calls to ensure compatibility.

If you do find some problems, let me know.  I'll get them fixed up ASAP.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Thanks Jeff,
I am developing more dlg's and every is thing working as suspected and I'll delete setdialoghotkeys(.FALSE.) in my sources.

Klaus

Re: "Dialogs" in AppGraphics

Jeff,
In a application using the full screen window is opened a child window, for instance a dialog window. A mouse click per accident not  in the window but outside causes that the main window is on the foreground and the child window below it. Is it possible to avoid that the child goes to the background an how can I manage it?
Klaus

Re: "Dialogs" in AppGraphics

Klaus,

No, it isn't possible in AppGraphics right now.  I think what you'd like is either:

1. Modal windows - where you couldn't interact with anything except the current window until you close it.
2. Stay-on-top windows - where a window, even if not the current, always appears topmost

Both could be added to AppGraphics.  Is there one you'd prefer?

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Jeff,
For all my applications, the intention is that users only should interact with the current child window but not with other windows (except to have to look only in window below)
So I prefer the first option.
Klaus

Re: "Dialogs" in AppGraphics

Jeff,

I concur with Klaus.  A modal window option would be a useful addition to AppGraphics.

Frank

Re: "Dialogs" in AppGraphics

Jeff,
I have implemented enablewindow and it works pretty well!
Thanks, Klaus

Re: "Dialogs" in AppGraphics

Klaus,

I'm glad to hear it! If you run into any problems using enablewindow, let me know.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Jeff,

I've implemented Enablewindow throughout my application and thus far it works seamlessly.

Thank you for taking the time to develop Enablewindow for AppGraphics and following up on member suggestions.

Much appreciated,

Frank

Re: "Dialogs" in AppGraphics

Jef, I have two dialogs:

        call dlgmessage(DIALOG_info,pre//'number of tanks found')
        item = dlgrequestselection (testmen_txt,testmen_txt(1), 'tank    to investigate:')     

The first appears on the foreground ; but the second is hidden behind the active window. Why

regards Klaus

Re: "Dialogs" in AppGraphics

Klaus,

It sounds like a bug.  The two dialogs are very different things behind the scenes.  I'll see if I can recreate it and fix the problem.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Klaus,

The list selection and text entry dialogs never defined a parent when created, which meant both were never displayed "above" the current window.  It should be fixed in version 2.41 when it is released.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Jeff,

To manage the layout of multiple line dialogs, I started to add a CR character at the end of my text line to avoid a random new line like my example:

Subroutine about
use appgraphics
Character*1 cr
cr=char(13)
call dlgmessage(DIALOG_INFO,'_______  HeatCat _______'//cr//&
   '      Copyright by ASC '//cr//&
   ' Computer aided structual design procedure'//cr// &
   ' For vessels with independent cargo tanks '//cr//&
   ' To generated vessels basic data use CASTOR'//cr//&
   ' generating a principal structure model   '//cr//&
   '____________________________________________'//cr//&
   ' This is a test and demo for a standard vessel '//cr//&
   '             beta version 8/1/2018')
end Subroutine about

Is this the best way to do or is there a more straight forward way?

regards Klaus

Re: "Dialogs" in AppGraphics

Klaus,

Yes, that's what's necessary in Windows to construct multiline messages for use in message boxes.  The Conway's Game of Life example included with Simply Fortran does the same thing in the subroutine aboutgame in control.f90.

You could consider using the constant C_CARRIAGE_RETURN available in the iso_c_binding module as well to be more explicit rather than using CHAR(13).  I'm not sure there's any real advantage, though.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Jeff,
A nasty problem I got:
From the main window a second window is opened
In this second window  a dialog is opened.
After closing the dialog different returns are found
Using the program from simply fortran for testing control returns with the second window on top.
But if the program runs directly under windows, without using SF, the main window appears on the foreground and that is not the intention.

How can I try to tackle the problem?

The dialog in the second window (initW) starts as follows:

initW = getcurrentwindow()  ! keep the previous window in memory for later return
Call enablewindow(initW,.false.)
! ______________________ open dlg-window__________________________________
dlg_screen = initwindow(250, 360, title = "Secundary Stiffening", closeflag = .false.)
CAll setdialoghotkeys(.TRUE.)
…..........
….........
And it ends with:
call loop()
   Call enablewindow(initW,.true.)
   Call closewindow(CURRENT_WINDOW)
   Call setcurrentwindow (initW)
!____________________________________________________________________________
Contains
.....
May be this info is too short to give a hint and I have to make a tiny testprogram first?

Regards, Klaus

Re: "Dialogs" in AppGraphics

Klaus,

Let me work on that this weekend to see if I can both replicate the problem and come up with a solution.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Klaus,

The problem is related to setcurrentwindow.   When you're calling that subroutine, the description (and subroutine name, quite frankly) sound as if it should also bring that window to the foreground.  In reality, all the call does is set the internal indicator within the library to point at that window for any subsequent graphics calls.  The library should also raise the indicated window to the top when setcurrentwindow is called.

I'll make the change and release a new build with the fix within the week.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Thanks Jeff,
Klaus

Re: "Dialogs" in AppGraphics

Jeff, I wrote a window with a scroll bar to list a lot of rows and saved it by calling enablewindow(initW,.false.) to avoid that the window moves to the background by hitting the mouse outside the scroll window as follows:
.....
initW = getcurrentwindow()  ! keep the main window in memory for return to it
Call enablewindow(initW,.false.)
dlg_screen  = initwindow(660, 900, title = "Structural parts defined on cross sections", closeflag=.false.)
.....
Unfortunately it does not work like in all my other dialogs: The window moves to the background but  requires action in it. Other windows are not accepting input.
The only difference with other dialogs is a menu I did add to the scoll window to make it possible to leave the scoll window.

Whats wrong with it?
Klaus

Re: "Dialogs" in AppGraphics

Klaus,

I'm not exactly sure I understand the problem.  After you call enablewindow(initW,.false.), what seems to be the problem?  You're creating a new window after that which should get all user input, but some is going to the background window?

I think it might be safer to reverse the two calls:

initW = getcurrentwindow()  ! keep the main window in memory for return to it
dlg_screen  = initwindow(660, 900, title = "Structural parts defined on cross sections", closeflag=.false.)
Call enablewindow(initW,.false.)

Disabling a window when there is no foreground window doesn't quite look right, though I might be wrong.  I'll try some experiments on my end too.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Ok Jeff,
That was the problem. Its not correct to disable the current window
thanks
Klaus

47 (edited by weixing1531 2020-09-18 18:34:10)

Re: "Dialogs" in AppGraphics

program main
    use appgraphics
    implicit none
   
    integer::myscreen,i,i1,i2,i3,i4,i5,i6
    character(1)::s
   
    myscreen = initwindow(800, 400, "整数加、减、乘法简单程序", closeflag=.TRUE.)!动画必须dbflag=.TRUE.
    call setcolor(WHITE) !前景色
    call setbkcolor(GREEN) !背景色
    call setmatchthemetextstyle()
    call settextstyle(SERIF_FONT, HORIZ_DIR, 25) !设置字体、文字方向、字号
    call settextjustify(CENTER_TEXT,CENTER_TEXT) !文本居中对齐
    call clearviewport()!清屏
   
    i1=createtextbox(100,200,50,25)!文本框
    call settextboxcontents(i1, "1")!初始值

    i2=createtextbox(200,200,50,25)!文本框
    call settextboxcontents(i2, "2")!初始值
   
    i3=createscrollbar (155, 185, 40, 56, SCROLL_VERTICAL, test) !垂直滚动条
    call setscrollrange(i3,1,3) !设置垂直滚动条档位范围
    call setscrollposition(i3,1) !设置垂直滚动条当前档位
   
    i4=createtextbox (155, 200, 40, 25)!文本框
    call settextboxcontents(i4, "+")!初始值
   
    i5=createtextbox(250, 200,50,25)!文本框
    call settextboxcontents(i5, "=")!初始值
    i6=createtextbox(300, 200,100,25)!文本框
    call settextboxcontents(i6, "3")!初始值
   
    i = createbutton(450, 200, 50, 25, "Run", start)!按钮
    i = createbutton(600, 200, 60, 25, "Close", quit)!按钮
   
    call loop()
    call closewindow(myscreen) !关闭窗口
contains
    subroutine Quit()
        call stopidle()
    end subroutine
   
    subroutine start()
        integer::i,j,k,m=0
        character(80)::s1,s2,s3
       
        i=gettextboxcontents(i1,s1) !i返回字符串长度 s1返回文本字符串
        j=gettextboxcontents(i2,s2)
        read(s1,*)i !字符串转换为整数
        read(s2,*)j
       
        k=getscrollposition (i3)!返回滚动条当前位置

        select case(k)
        case(1)
            m=i+j
        case(2)
            m=i-j
        case(3)
            m=i*j
        end select
       
        write(s3,"(i0)")m !整数转换为字符串
        call settextboxcontents (i4, s)!设置文本框内容
        call settextboxcontents (i6, trim(adjustl(s3)))!设置文本框内容
    end subroutine
   
    subroutine test(j) !j返回滚动条位置
        integer::j

        write(*,*)j
        select case(j)
        case(1)
            s="+"
        case(2)
            s="-"
        case(3)
            s="*"
        end select
       
        call settextboxcontents (i4, s)!设置文本框内容
    End subroutine
end program main


In the subroutine test, why "write(*,*)j" run twice in the console when i change the scrollbar?

Re: "Dialogs" in AppGraphics

The subroutine test is actually run twice when scrolling.  The problem is that AppGraphics was triggering calling the scroll subroutine whenever a WM_HSCROLL or WM_VSCROLL message was sent by Windows.  While this might seem to make sense, Windows will send these messages with the "scroll request" for SB_SCROLLEND to indicate that scrolling has ended.  Scrolling ending isn't a particularly good reason in AppGraphics to trigger a scrollbar callback.

So calling the subroutine test twice is a bug.  We've fixed it, and it should be included in Simply Fortran 3.15, which we're finishing up now.

Jeff Armstrong
Approximatrix, LLC

Re: "Dialogs" in AppGraphics

Thanks Jeff!
I hope AppGraphics is useful as well as Qt.
Come on!

Re: "Dialogs" in AppGraphics

Hi Jeff,
I am restarting developement of my program for costing for shipstructures using the latest version of SF.
I did not use it for a longer time and found an unwanted reaction on hitting the windows cross on top of dioalogs: It causes a crash or it does not return to the calling window. All my dialogs  have buttons to exit and return to the calling window. The cross at top is not needed. Is it possible te deactivate it?
Regards Klaus