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

QuickWin - setting dialog focus

davidgraham
Beginner
695 Views

I've recompiled an old QuickWin project.

It uses a dialog to specify some parameters then draws graphics in the full screen, then displays the dialog again with the results.

I'm finding that the dialog is losing focus and is behind the graphics. If I click on the screen the dialog is displayed.

How do I set focus to the dialog using Quickwin?

I have tried:

iret=SetFocus(GetDlgItem(dlg%hwnd,IDC_JOB3))

But I have a note that it didn't work before and it doesn't work this time.

Maybe the solution is to rewrite it as a proper Windows application.  

0 Kudos
12 Replies
andrew_4619
Honored Contributor II
695 Views

If that is a modal dialog I think you need to call focusqq for its parent window.

 

0 Kudos
davidgraham
Beginner
695 Views

Thanks, I had seen the documentation for focusQQ but wasn't sure what parameter I send - the example give a unit number.

I tried:

iret=focusQQ(GetDlgItem(dlg%hwnd,IDC_JOB3))

where IDC_JOB3 is the dialog I want to get focus.

Nothing happens.

0 Kudos
andrew_4619
Honored Contributor II
695 Views

https://software.intel.com/en-us/node/535326

when you open a quickwin child window is has a fortran unit number. this is not a windows handle.

0 Kudos
davidgraham
Beginner
695 Views

Looking at examples they have:

OPEN (UNIT= 12, FILE= 'USER', TITLE= 'Product Matrix')

to open a window - this gives something like a command line box with simple text.

I have a proper dialog box with labels, text boxes & buttons. The only OPEN statements I have are to OPEN files to for read & write.

Therefore I'm not sure where I get this Unit number from.  
 

0 Kudos
andrew_4619
Honored Contributor II
695 Views

Sound like you have dialogs and the Quickwin frame window (usually with menus). The unit number of the frame window is in the constant QWIN$FRAMEWINDOW

0 Kudos
davidgraham
Beginner
695 Views

Thanks for your help. I tried adding

iret=focusQQ(QWIN$FRAMEWINDOW)

but it had no effect.

I think a screen dump might help to show what is going on.

I have a dialog box where I enter some info, when I press 'Calculate' an image is then drawn on the frame window. At the end I want the dialog box to reappear showing the results. I have to click on the frame window and the dialog reappears. I have shown a screen dump showing the result after clicking on the frame window.

I think I need to be setting focus to the dialog box not the frame window.   

0 Kudos
andrew_4619
Honored Contributor II
695 Views

You can set the window Z order with an API call

            istat=SetWindowPos(ihandle,ivert,ixpos,iypos,0,0,uflags)
        !endif
        !(ivert) hWndInsertAfter  Either the handle of the window to position this window behind, or exactly one 
        ! of the following flags stating where in the Z-order to put the window:
        !HWND_BOTTOM     = 1  ! Put the window at the bottom of the Z-order.
        !HWND_NOTOPMOST  =-2  ! Put the window below all topmost windows and above all non-topmost windows.
        !HWND_TOP        = 0  ! Put the window at the top of the Z-order.
        !HWND_TOPMOST    = -1 ! Make the window topmost (above all other windows) permanently

read

https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx

 

0 Kudos
andrew_4619
Honored Contributor II
695 Views

I have not used quickwin for a long time but that seems strange. Modal dialogs created with IFLOGM I recall were always higher z order than the parent window. Do you create this dialog with DLGMODAL or DLGMODELESS  by the way?

0 Kudos
davidgraham
Beginner
695 Views

Thanks, I tried that code but nothing happened (maybe I didn't do it right)

I'm calling the dialog using DlgModal.

I think I will try to convert the program from QuickWin to an proper Windows Application. That will make it more consistent with other programs in the suite.

 

0 Kudos
andrew_4619
Honored Contributor II
695 Views

This should be an easy problem to fix.

What is the program flow I guess:

1) program create frame window

2) Create dialog via initialsettings and goes model?

3) In dialog callback routine to some user input e.g. button press) you draw to the frame window (?? using api or quickwin?)

4) At 3) frame window comes to top and on completion of callback drawing stays there.

Some bits of code might help, where are you trying to set focus/ z order. Just saying it didn't work doesn't give much option for anyone to help / comment. 

 

0 Kudos
davidgraham
Beginner
695 Views

When I started looking at this the other day it was displaying the frame window in front of the dialog window so I couldn't start entering the info on the dialog.

I therefore moved the 'Create frame window' to after creating the Dialog.

After the change, I could at least enter the data but then was not able to see the results at the end. 

From your suggested order, changing it back to what it was has worked.

When I say it works, is when the dialog is in front of the frame, saying it doesn't work means that the dialog is displayed behind the frame window.

I have taken a previous backup of the code and compiled it and it 'works' first time without any changes, i.e. the dialog is displayed in front of the frame as required.

I don't know what went wrong but it is now OK.

Thanks for your help.

0 Kudos
andrew_4619
Honored Contributor II
695 Views

you can always minimise the dialog if you have the minimise maximise etc options switched on.

0 Kudos
Reply