This is a very specific and obscure problem with 4D when running under Windows
Remote Desktop Services (RDS) 2012 or newer — also know as Terminal Services in
Windows Server 2008. You have a 4D application deployed so that it runs as a
single window when a user logs into RDS. This is not about using Remote Desktop
to connect to a machine and then from the Desktop of that machine you start up
a 4D application.
Problem reported by users: Sometimes when I start up 4D no windows are
displayed. Or they say the main window is minimized and when I restore it the
windows inside are all screwed up and sized wrong. Sometimes it happens but not
always.
What is happening is with RDS saves the size and position of the MDI when you
quit an application. The next time you start up the application it will open
the MDI in the same location and size. Nice feature.
The problem is if a user minimized the MDI window it disappears. If they
right-click on the window in the Task Bar and choose “Close Window” it will
quit 4D. (Or some other action causes 4D to quit.) Windows will remember that
minimized MDI size and placement. When the user starts up 4D again instead of
seeing the normal big gray MDI window, the MDI window is opened minimized and
appears in the lower left corner of their Desktop. Many users don’t even notice
this, hence the “no window opens” comment. A side affect of this is that if you
open any windows inside the MDI on startup the sizing and position may be wrong.
The fix is simple. Don’t quit 4D with the MDI minimized. Win32API to the rescue
to provide a way to handle this. Here’s a method I wrote today to deal with
this. File this in your memory bank somewhere so that if you ever run into this
problem you know what it is and how to fix it.
// ===========================================
// PROJECT METHOD: RestoreWindowsMDI
// PARAMETERS: none
// DESCRIPTION: This method will check if on Windows the
// MDI window is minimized and if so, restores it.
// On Windows RDS it saves the MDI window size when
// you quit the application. Then when you start the application again it
// opens the MDI to the same size and location. This causes a problem
// because the MDI is restored in a minimized position and that causes
// the first window opened inside the MDI to be improperly resized.
// This method fixes that problem by restoring the MDI before quitting.
// CREATED BY: Tim Nevels, Innovative Solutions ©2017
// DATE: 10/30/17
// LAST MODIFIED:
// ============================================
C_LONGINT($windowHandle_l;$error)
If (Not(<>macOS)) // must be Windows OS
// Get MDI window handle
$windowHandle_l:=gui_GetWindow ("")
// check if MDI is minimized
If (gui_GetWindowState ($windowHandle_l)=IS_MINIMIZED) // yes it is
// restore the MDI
$error:=gui_RestoreMDI
End if
End if
Tim
********************************************
Tim Nevels
Innovative Solutions
785-749-3444
[email protected]
********************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************