Here's a modified demo.prg from \hmg\SAMPLES\Controls\Button\BUTTON_3 with termination error as:
The program went bananas when windows1, windows2 and windows3 are maximized.ToolBar's Parent Window Can't Be a 'Virtual Dimensioned' Window (Use 'Virtual Dimensioned' SplitChild Instead). Program terminated
Here's the modified code:
Code: Select all
/*
* HMG - Harbour Win32 GUI library
* Copyright 2002-2008 Roberto Lopez <mail.box.hmg@gmail.com>
* http://www.hmgforum.com//
*/
#include "hmg.ch"
***************
Function Main()
PRIVATE hWndName := ""
PRIVATE hCtrlTbar := ""
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 200 ;
HEIGHT 200 ;
MAIN;
TITLE 'Button Test'
DEFINE MAIN MENU
POPUP 'Test'
ITEM 'Disable button' ACTION Form_1.Button_1.Enabled := .f.
ITEM 'Enable button' ACTION Form_1.Button_1.Enabled := .t.
SEPARATOR
ITEM "Window 1" ACTION WIND( "window1" )
ITEM "Window 2" ACTION WIND( "window2" )
ITEM "Window 3" ACTION WIND( "window3" )
END POPUP
END MENU
@ 70,70 CHECKBUTTON Button_1 PICTURE "button.bmp" WIDTH 50 HEIGHT 50
END WINDOW
Form_1.Maximize
ACTIVATE WINDOW Form_1
Return
******************************
static function wind( cParam )
IF PCOUNT() = 1
hWndName := cParam
hTbarCtrl := "tBar" + cParam
ENDIF
DEFINE WINDOW &(hWndName) ;
AT 0,0 ;
WIDTH 200 ;
HEIGHT 200 ;
TITLE "&hWndName";
ON INIT WinAutoAdjust( ThisWindow.Name );
ON SIZE WinAutoAdjust( ThisWindow.Name );
ON MAXIMIZE WinAutoAdjust( ThisWindow.Name );
ON PAINT ( hWndName := ThisWindow.Name );
ON GOTFOCUS ( hWndName := ThisWindow.Name )
DEFINE TOOLBAR &(hTbarCtrl) OF &(hWndName) BUTTONSIZE 20, 24 FONT "Arial" SIZE 8 BORDER
BUTTON tbtnNExit CAPTION "E&xit";
ACTION ( MSGINFO( hWndName, "x" ), DOMETHOD( hWndName,"Release") )
BUTTON tbtnNew CAPTION "&New Record" ;
ACTION NIL
BUTTON tbtnEdit CAPTION "E&dit Record" ;
ACTION nil
BUTTON tbtnPrint CAPTION "&Print" ;
ACTION NIL TOOLTIP "Print list"
END TOOLBAR
DEFINE MAIN MENU
POPUP 'Test'
ITEM 'Disable button' ACTION tstAct( .F. )// ACTION &(hWndName).Button_1.Enabled := .f.
ITEM 'Enable button' ACTION tstAct( .T. )// ACTION &(hWndName).Button_1.Enabled := .t.
END POPUP
END MENU
@ 70,70 CHECKBUTTON Button_1 OF &(hWndName) PICTURE "button.bmp" WIDTH 50 HEIGHT 50
END WINDOW
&(hWndName).CENTER
&(hWndName).ACTIVATE
RETURN NIL
******************************
static function tstAct(lvalue)
SetProperty(hWndName,"Button_1","Enabled",lvalue)
************************
Function ISAPPXPTHEMED()
RETURN ( OS_ISWINXP_OR_LATER() .AND. IsAppThemed() )
*******************************
function WinAutoAdjust( cForm )
LOCAL hWnd := GetFormHandle( cForm )
LOCAL i // Form Number
LOCAL k // Control Number
LOCAL ParentForm
LOCAL ControlCount
LOCAL ControlName
LOCAL ControlType
LOCAL nWidth
LOCAL nHeight
LOCAL lvisible:= .T.
LOCAL nDivw
LOCAL nDivh
IF GetDesktopWidth() < GetWindowWidth ( hWnd )
nWidth := GetDesktopWidth()
ELSE
nWidth := GetWindowWidth ( hWnd )
ENDIF
IF GetDesktopHeight() < GetWindowHeight ( hWnd )
nHeight := GetDesktopHeight()
ELSE
nHeight := GetWindowHeight ( hWnd )
ENDIF
IF IsWindowVisible ( hWnd ) .And. ! IsAppXPThemed()
HideWindow ( hWnd )
ELSE
lvisible := .F.
ENDIF
i := ASCAN ( _HMG_SYSDATA[ 67 ] , hWnd )
ParentForm := _HMG_SYSDATA[ 66, i ]
IF _HMG_SYSDATA[ 92, i ] > 0 .and. _HMG_SYSDATA[ 91, i ] > 0
nDivw := nWidth / _HMG_SYSDATA[ 92, i ]
nDivh := nHeight / _HMG_SYSDATA[ 91, i ]
ELSE
nDivw := 1
nDivh := 1
ENDIF
ControlCount := LEN ( _HMG_SYSDATA[ 3 ] )
FOR k := 1 To ControlCount
ControlName := _HMG_SYSDATA[ 2, k ]
IF _IsControlDefined ( ControlName, ParentForm )
ControlType := _HMG_SYSDATA[ 1, k ]
IF !EMPTY( ControlName ) .AND. ;
!( ControlType $ "MENU,HOTKEY,TOOLBAR,MESSAGEBAR,ITEMMESSAGE,TIMER" )
DO CASE
//CASE ControlType == "RADIOGROUP"
// _HMG_aControlSpacing := _HMG_SYSDATA[ 22 ]
// _HMG_aControlMiscData1 := _HMG_SYSDATA[ 8 ]
// _HMG_aControlSpacing [k] := _HMG_aControlSpacing [k] * IIF(_HMG_aControlMiscData1 [k], nDivw, nDivh)
CASE ControlType == "SLIDER" // do nothing
CASE ControlType == "STATUSBAR" // do nothing
CASE ControlType == "LABEL"
_SetControlSizePos( ControlName, ParentForm,;
_GetControlRow( ControlName, ParentForm ) * nDivh, ; // row
_GetControlCol ( ControlName, ParentForm ) * nDivw ,; // column
_GetControlWidth( ControlName, ParentForm ) * nDivw,; // with
_GetControlHeight ( ControlName, ParentForm ) ) // height
CASE ControlType $ "TEXT,RADIOGROUP"
_SetControlSizePos( ControlName, ParentForm,;
_GetControlRow( ControlName, ParentForm ) * nDivh, ; // row
_GetControlCol ( ControlName, ParentForm ) * nDivw ,; // column
_GetControlWidth( ControlName, ParentForm ) * nDivw,; // with
_GetControlHeight ( ControlName, ParentForm ) ) // height
CASE ControlType == "BUTTON"
_SetControlSizePos( ControlName, ParentForm,;
_GetControlRow( ControlName, ParentForm ) * nDivh, ;
_GetControlCol ( ControlName, ParentForm ) * nDivw ,;
_GetControlWidth( ControlName, ParentForm ) * nDivw,;
_GetControlHeight ( ControlName, ParentForm ) ) // _GetControlHeight ( ControlName, ParentForm ) * nDivh )
CASE !ControlType $ "TOOLBUTTON"
_SetControlSizePos ( ControlName, ParentForm,;
_GetControlRow ( ControlName, ParentForm ) * nDivh, _GetControlCol ( ControlName, ParentForm ) * nDivw,;
_GetControlWidth ( ControlName, ParentForm ) * nDivw, _GetControlHeight ( ControlName, ParentForm ) * nDivh )
OTHERWISE
IF EMPTY( _HMG_SYSDATA[ 28, k ] )
_SetFontSize ( ControlName, ParentForm , 8 * nDivh )
ELSE
//_SetFontSize ( ControlName, ParentForm , _HMG_SYSDATA[28] [k] * nDivh )
ENDIF
ENDCASE
ENDIF
ENDIF
NEXT k
_HMG_SYSDATA[ 92, i ] := nWidth
_HMG_SYSDATA[ 91, i ] := nHeight
IF lvisible
ShowWindow ( hWnd )
ENDIF
RETURN NIL
Code: Select all
Date:10/31/14 Time: 15:15:40
Error: HMG 3.3.1 Stable Patch 1 (32 bits)
ToolBar's Parent Window Can't Be a 'Virtual Dimensioned' Window (Use 'Virtual Dimensioned' SplitChild Instead). Program terminated
Called from EVENTS(1074)
Called from _HMG_PRINTER_SETVSCROLLVALUE(0)
Called from VIRTUALCHILDCONTROLFOCUSPROCESS(6268)
Called from EVENTS(1965)
Called from SETFOCUS(0)
Called from EVENTS(942)
Called from C_MSGSTOP(0)
Called from SHOWERROR(168)
Called from MSGHMGERROR(81)
Called from EVENTS(1074)
Called from _HMG_PRINTER_SETVSCROLLVALUE(0)
Called from VIRTUALCHILDCONTROLFOCUSPROCESS(6268)
Called from EVENTS(1965)
Called from SETFOCUS(0)
Called from EVENTS(942)
Called from C_MSGINFO(0)
Called from MSGINFO(118)
Called from (b)WIND(63)
Called from _DOCONTROLEVENTPROCEDURE(5745)
Called from EVENTS(1649)
Called from DOMESSAGELOOP(0)
Called from _ACTIVATEWINDOW(5413)
Called from DOMETHOD(8032)
Called from WIND(87)
Called from (b)MAIN(29)
Called from _DOCONTROLEVENTPROCEDURE(5745)
Called from EVENTS(1642)
Called from DOMESSAGELOOP(0)
Called from _ACTIVATEWINDOW(5413)
Called from DOMETHOD(8032)
Called from WIND(87)
Called from (b)MAIN(28)
Called from _DOCONTROLEVENTPROCEDURE(5745)
Called from EVENTS(1642)
Called from DOMESSAGELOOP(0)
Called from _ACTIVATEWINDOW(5413)
Called from MAIN(39)
To compile, use the build.bat from \hmg\SAMPLES\Controls\Button\BUTTON_3 folder or block comment the original code on your demo.prg in the same folder and paste the code above, save and compile.
To replicate the error, click Test then select Window 1 then again select Window 2 and Window 3. Maximized all windows and if they are not visible, click on the taskbar select the window to bring it into focus then maximized. Once you're done trigger the error from the toolbar control of windows1,2 or 3 and click the button "Exit". Also when you restore those windows, the program loose tracked of which window is which. (Hmm... perhaps I should also add ON MOUSE click windows event).
The error should not happen because its just a recursive call however is there anything more missing?
To terminate the program after the call trace use Windows Taskmanager.
TIA.