Page 1 of 2
MDI & Splitter Problem
Posted: Mon Nov 19, 2007 9:48 am
by ask
Hi,
When i try to use MDI Window with splitter does not work .See for example testspl1.prg use MDI .I found a previous forum witch shows the problem
http://fivetechsoft.com/forums/viewtopi ... r+mdichild
Is there any solution for this?
Thank you
A.S.K
Posted: Mon Nov 19, 2007 11:28 am
by Antonio Linares
A.S.K.
You can do it this way. Anyhow when you try to create a Child window it GPFs and we need to find the reason
Code: Select all
#include "FiveWin.ch"
#include "Splitter.ch"
static oWnd
static oLbx, oGet
static oSplit
function Main()
local cTitle := "Testing the Splitter controls"
local cText
DEFINE WINDOW oWnd FROM 1, 1 TO 400, 600 PIXEL ;
TITLE cTitle ;
BORDER NONE MDI
SELECT 1
USE EJEMPLO1.DBF
@ 20,20 LISTBOX oLbx FIELDS SIZE 200,300 PIXEL OF oWnd ;
ON CHANGE cText := Ejemplo1->Sintax
SetParent( oLbx:hWnd, oWnd:hWnd )
@ 20,225 GET oGet VAR cText TEXT SIZE 300,300 PIXEL OF oWnd
oLbx:bChange:={|| oGet:Refresh() }
SetParent( oGet:hWnd, oWnd:hWnd )
@ 20, 220 SPLITTER oSplit ;
VERTICAL ;
PREVIOUS CONTROLS oLbx ;
HINDS CONTROLS oGet ;
LEFT MARGIN 100 ;
RIGHT MARGIN 140 ;
SIZE 4, 300 PIXEL ;
OF oWnd ;
_3DLOOK ;
UPDATE
SetParent( oSplit:hWnd, oWnd:hWnd )
ACTIVATE WINDOW oWnd
return nil
Posted: Mon Nov 19, 2007 11:37 am
by ask
thank you Antonio.
Posted: Mon Nov 19, 2007 3:58 pm
by Antonio Linares
It looks as a Windows MDI internal procedure GPF but we found a way to bypass it
Posted: Mon Nov 19, 2007 3:59 pm
by Antonio Linares
Here it is the source code:
Code: Select all
// FWH Class TOutLook2003
#include "FiveWin.ch"
#include "Splitter.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oOutLook2003, oStatusBar, oSplit, cCombo, oRad, nValue := 1
local oFont
DEFINE WINDOW oWnd TITLE "FWH new Class TOutLook2003" MDI // ;
// MENU BuildMenu()
DEFINE OUTLOOK2003 oOutLook2003 OF oWnd ;
PROMPTS "Mail", "Calendar", "Contacts", "" ;
BITMAPS "..\bitmaps\mail.bmp", "..\bitmaps\calendar.bmp", "..\bitmaps\notes.bmp"
oWnd:oLeft = nil // Because the splitter is going to control the resize
@ 1, 2 BUTTON "New" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION BuildDlg()
@ 3, 2 BUTTON "Edit" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION MsgInfo( "Edit" )
@ 5, 2 BUTTON "Search" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION MsgInfo( "Search" )
@ 1, 1 COMBOBOX cCombo ITEMS { "January", "February", "March", "April", "May" } ;
OF oOutLook2003:aDialogs[ 2 ] SIZE 170, 100
DEFINE FONT oFont NAME "Arial" SIZE 0, -10
@ 12, 10 SAY Date() OF oOutLook2003:aDialogs[ 2 ] SIZE 80, 20 FONT oFont
@ 3, 1 RADIO oRad VAR nValue OF oOutLook2003:aDialogs[ 2 ] ;
ITEMS "&Day", "&Week", "&Month" SIZE 100, 20
oRad:SetFont( oFont )
#ifndef __CLIPPER__
DEFINE STATUSBAR oStatusBar PROMPT " FWH Class TOutLook2003" OF oWnd
#else
DEFINE MESSAGE oStatusBar PROMPT " FWH Class TOutLook2003" OF oWnd
#endif
SetParent( oOutLook2003:hWnd, oWnd:hWnd )
oWnd:oClient = nil
@ 0, 191 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oOutLook2003 ;
HINDS CONTROLS oWnd:oWndClient ;
SIZE 4, oWnd:nHeight - 70 PIXEL ;
OF oWnd
SetParent( oSplit:hWnd, oWnd:hWnd )
ACTIVATE WINDOW oWnd ;
ON RESIZE oSplit:Adjust() ;
VALID PostQuitMessage( 0 )
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "&One"
MENUITEM "&Two"
MENUITEM "&Three"
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function BuildDlg()
local oDlg, oOutL2003
DEFINE DIALOG oDlg RESOURCE "Test"
REDEFINE OUTLOOK2003 oOutL2003 ID 110 OF oDlg ;
PROMPTS "One", "Two", "Three" ;
BITMAPS "..\bitmaps\mail.bmp", "..\bitmaps\calendar.bmp", "..\bitmaps\notes.bmp" ;
DIALOGS "Page1", "Page2", "Page3"
REDEFINE BUTTON ID 110 OF oOutL2003:aDialogs[ 1 ] ACTION MsgInfo( "Click" )
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function WinRun()
while NoGPF()
end
return nil
//----------------------------------------------------------------------------//
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
BOOL SysRefresh( void );
HB_FUNC( NOGPF )
{
__try
{
hb_retl( SysRefresh() );
}
__except ( ( hb_retl( TRUE ), TRUE ) )
{}
}
#pragma ENDDUMP
Posted: Tue Nov 20, 2007 12:51 am
by Silvio
Antonio,
when I run it run ok but when i close it xp professional make an error
Posted: Tue Nov 20, 2007 7:32 am
by Antonio Linares
Silvio,
What error ?
Probably the error get fixed with this code:
VALID ( PostQuitMessage( 0 ), .T. )
Posted: Tue Nov 20, 2007 8:41 am
by StefanHaupt
Antonio,
this is the error:
Code: Select all
Application
===========
Path and name: D:\FWH\samples\testspl7.exe (32 bits)
Size: 1,295,360 bytes
Time from start: 0 hours 0 mins 36 secs
Error occurred at: 11/20/07, 09:36:36
Error description: Error BASE/1066 Argument error: conditional
Args:
[ 1] = U
Stack Calls
===========
Called from: MDIFRAME.PRG => TMDIFRAME:END(0)
Called from: MDIFRAME.PRG => (b)TMDIFRAME:NEW(0)
Called from: MENU.PRG => TMENU:COMMAND(0)
Called from: WINDOW.PRG => TWINDOW:COMMAND(0)
Called from: MDIFRAME.PRG => TMDIFRAME:COMMAND(0)
Called from: => TMDIFRAME:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: testspl7.prg => NOGPF(0)
Called from: testspl7.prg => WINRUN(102)
Called from: WINDOW.PRG => TMDIFRAME:ACTIVATE(0)
Called from: testspl7.prg => MAIN(61)
Posted: Tue Nov 20, 2007 8:46 am
by StefanHaupt
Antonio,
Antonio Linares wrote:Silvio,
What error ?
Probably the error get fixed with this code:
VALID ( PostQuitMessage( 0 ), .T. )
does not work, same error.
Another problem, if you maximize the mdi window, you can´t resize it nor select other open mdi windows
Posted: Tue Nov 20, 2007 9:24 am
by Antonio Linares
This version fixes the exit error on XP (on Vista is ok):
Code: Select all
// FWH Class TOutLook2003
#include "FiveWin.ch"
#include "Splitter.ch"
static lExit := .F.
//----------------------------------------------------------------------------//
function Main()
local oWnd, oOutLook2003, oStatusBar, oSplit, cCombo, oRad, nValue := 1
local oFont
DEFINE WINDOW oWnd TITLE "FWH new Class TOutLook2003" MDI // ;
// MENU BuildMenu()
DEFINE OUTLOOK2003 oOutLook2003 OF oWnd ;
PROMPTS "Mail", "Calendar", "Contacts", "" ;
BITMAPS "..\bitmaps\mail.bmp", "..\bitmaps\calendar.bmp", "..\bitmaps\notes.bmp"
oWnd:oLeft = nil // Because the splitter is going to control the resize
@ 1, 2 BUTTON "New" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION BuildDlg()
@ 3, 2 BUTTON "Edit" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION MsgInfo( "Edit" )
@ 5, 2 BUTTON "Search" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION MsgInfo( "Search" )
@ 1, 1 COMBOBOX cCombo ITEMS { "January", "February", "March", "April", "May" } ;
OF oOutLook2003:aDialogs[ 2 ] SIZE 170, 100
DEFINE FONT oFont NAME "Arial" SIZE 0, -10
@ 12, 10 SAY Date() OF oOutLook2003:aDialogs[ 2 ] SIZE 80, 20 FONT oFont
@ 3, 1 RADIO oRad VAR nValue OF oOutLook2003:aDialogs[ 2 ] ;
ITEMS "&Day", "&Week", "&Month" SIZE 100, 20
oRad:SetFont( oFont )
#ifndef __CLIPPER__
DEFINE STATUSBAR oStatusBar PROMPT " FWH Class TOutLook2003" OF oWnd
#else
DEFINE MESSAGE oStatusBar PROMPT " FWH Class TOutLook2003" OF oWnd
#endif
SetParent( oOutLook2003:hWnd, oWnd:hWnd )
oWnd:oClient = nil
@ 0, 191 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oOutLook2003 ;
HINDS CONTROLS oWnd:oWndClient ;
SIZE 4, oWnd:nHeight - 70 PIXEL ;
OF oWnd
SetParent( oSplit:hWnd, oWnd:hWnd )
ACTIVATE WINDOW oWnd ;
ON RESIZE oSplit:Adjust() ;
VALID lExit := .T.
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "&One"
MENUITEM "&Two"
MENUITEM "&Three"
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function BuildDlg()
local oDlg, oOutL2003
DEFINE DIALOG oDlg RESOURCE "Test"
REDEFINE OUTLOOK2003 oOutL2003 ID 110 OF oDlg ;
PROMPTS "One", "Two", "Three" ;
BITMAPS "..\bitmaps\mail.bmp", "..\bitmaps\calendar.bmp", "..\bitmaps\notes.bmp" ;
DIALOGS "Page1", "Page2", "Page3"
REDEFINE BUTTON ID 110 OF oOutL2003:aDialogs[ 1 ] ACTION MsgInfo( "Click" )
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function WinRun()
while NoGPF()
if lExit
PostQuitMessage( 0 )
endif
end
return nil
//----------------------------------------------------------------------------//
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
BOOL SysRefresh( void );
HB_FUNC( NOGPF )
{
__try
{
hb_retl( SysRefresh() );
}
__except ( ( hb_retl( TRUE ), TRUE ) )
{}
}
#pragma ENDDUMP
Posted: Tue Nov 20, 2007 9:27 am
by Antonio Linares
Stefan,
> if you maximize the mdi window, you can´t resize it nor select other open mdi windows
Yes, we have noticed it.
The problem is that we are not using the FWH standard windows procedure as the MDI GPFs internally (even if we use a standard Windows procedure and not the FWH one).
Its a tricky code tu push MDI environment to its limits, but lets see if we can solve those problems
Posted: Tue Nov 20, 2007 9:31 am
by Antonio Linares
Stefan,
> if you maximize the mdi window, you can´t resize it nor select other open mdi windows
As a temporary workaround, the "cascade" MDI menu option can be selected to restore the maximized mdichild.
Posted: Tue Nov 20, 2007 9:38 am
by Antonio Linares
Also we can "restore" the mdichild:
@ 3, 2 BUTTON "Edit" OF oOutLook2003:aDialogs[ 1 ] SIZE 80, 22 ACTION oWnd:oWndClient:aWnd[ 1 ]:Restore()
Anyhow we need to find why the WM_SYSCOMMANDs are not properly being processed
Posted: Wed Nov 21, 2007 9:08 am
by StefanHaupt
Antonio,
"restoring" the window as a work around is working fine.
Cascading the windows changes their sizes to their original size, is that standard behavior?
Posted: Wed Nov 21, 2007 9:21 am
by Antonio Linares
Stefan,
> Cascading the windows changes their sizes to their original size, is that standard behavior?
Yes, I think so