I would like to remove the X close button on the top right corner of a dialog box.
Any help would be greatly appreciated.
Thanks In Advance Mike.
I would like to remove the X close button on the top right corner of a dialog box.
Any help would be greatly appreciated.
Thanks In Advance Mike.
Mike:
With your resource editor ( I used PellesC )
Change the your dialog properties of system menu to NOT
That is all.
DEFINE dialog oDlg STYLE WS_CAPTION
DEFINE DIALOG oDlg STYLE nOR( WS_POPUP, WS_VISIBLE )
blank DIALOG without border
Is there a way to keep a menu icon and not have the X close window in the top right corner?
Thanks Mike.
#define MF_BYPOSITION 1024 // 0x0400
#define MF_DISABLED 2
*******************************************************************************
*** FUNCTION DisableX(oWin, lDisable) to Disable X button of Window/Dialog ***
*******************************************************************************
FUNCTION DisableX(oWin, lDisable)
LOCAL hMenu := 0
LOCAL nCount := 0
IF lDisable
hMenu = GetSystemMenu(oWin:hWnd, .F.)
nCount = GetMItemCount(hMenu)
RemoveMenu(hMenu, nCount - 1, nOR( MF_BYPOSITION, MF_DISABLED) )
RemoveMenu(hMenu, nCount - 2, nOR( MF_BYPOSITION, MF_DISABLED) )
DrawMenuBar( oWin:hWnd )
ELSE
GetSystemMenu( oWin:hWnd, .T. )
DrawMenuBar( oWin:hWnd )
ENDIF
RETURN nilHow does the dialog style have to be set to have diasblex work, The dialog I am testing on is from pelles c resource and I have tried with system true and false.
Thanks Mike
Hello Mike,
This code works with the dialogs created from Borland Resource Workshop perfectly. I am very sorry, I dont know anything about pelles c resources.
I wonder out of my academic interest, either Borland or Pelles they are expected to normally respect the windows standards and accordingly they design such resource management tools. I dont' know why PELLES C is different from Borland! or vice-versa.
Regards,
Thanks Ramesh
MIke
Hello Ramesh,
I tested Your solution to hide the X ( exit ) in dialog.
It works fine with MDI. If I use it in a stand-alone Dialog,
I cannot move the dialog anymore.
Do you know a solution, to keep the dialog moving ?
Regards
Uwe ![]()
#define MF_BYPOSITION 1024 // 0x0400
#define MF_DISABLED 2
...
...
DEFINE DIALOG oDlg RESOURCE "Tools" OF oWnd TRANSPARENT ;
TITLE "Selection" FONT oProgFont
...
...
... It works !!
ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON INIT ( oDlg:Move( 30 , 50, oDlg:nWidth, oDlg:nHeight, .f. ), ;
DisableX(oDlg, .T.) ) )
RETURN NIL
*******************************************************
*** FUNCTION DisableX(oWin, lDisable) to Disable X button of Window/Dialog ***
*******************************************************
FUNCTION DisableX(oWin, lDisable)
LOCAL hMenu := 0
LOCAL nCount := 0
IF lDisable
hMenu = GetSystemMenu(oWin:hWnd, .F.)
nCount = GetMItemCount(hMenu)
RemoveMenu(hMenu, nCount - 1, nOR( MF_BYPOSITION, MF_DISABLED) )
RemoveMenu(hMenu, nCount - 2, nOR( MF_BYPOSITION, MF_DISABLED) )
DrawMenuBar( oWin:hWnd )
ELSE
GetSystemMenu( oWin:hWnd, .T. )
DrawMenuBar( oWin:hWnd )
ENDIF
RETURN nil*******************************************************************************
*** FUNCTION DisableX(oWin, lDisable) to Disable X button of Window/Dialog ***
*******************************************************************************
FUNCTION DisableX(oWin, lDisable)
LOCAL hMenu := 0
LOCAL nCount := 0
IF lDisable
hMenu = GetSystemMenu(oWin:hWnd, .F.)
nCount = GetMItemCount(hMenu)
IF oWin:ClassName() = "TDIALOG"
RemoveMenu(hMenu, 1, nOR( MF_BYPOSITION, MF_DISABLED) )
ELSE
RemoveMenu(hMenu, nCount - 1, nOR( MF_BYPOSITION, MF_DISABLED) )
RemoveMenu(hMenu, nCount - 2, nOR( MF_BYPOSITION, MF_DISABLED) )
ENDIF
DrawMenuBar( oWin:hWnd )
ELSE
GetSystemMenu( oWin:hWnd, .T. )
DrawMenuBar( oWin:hWnd )
ENDIF
RETURN nilHello RAMESHBABU,
thank You very much for Your help.
It works PERFECT now.
Regards
Uwe ![]()
Hello Mr.Uwe,
You are most welcome.
Regards,