Page 1 of 2

Disable [Dim] Close Button "X"

Posted: Thu Aug 21, 2014 9:06 am
by bpd2000
Find working example to Disable [Dim] / Enable Close Button "X"

Code: Select all

/* 
   HMG Sample : 

     "Demo Disable / Enable Close Button 'X'"

   By BPD2000

   August 2014 
*/

#include <hmg.ch>

PROCEDURE Main()

   define window main at 0, 0 width 400 height 300 main title "Demo Disable / Enable Close Button 'X'"
      
      define button click
         row 100
         col 10
         caption 'Click'
         action msginfo( 'Just a test' )
      end button   
      define button Disablex
         row 140
         col 10
         caption "Disable X"
         action (NOCLOSEDLG(thiswindow.handle), MSGINFO("Disabled Close Button 'X'", "Action"))
      end button   
      define button Enablex
         row 180
         col 10
         caption "Enable X"
         action (CLOSEDLG(thiswindow.handle), MSGINFO("Enabled Close Button 'X'", "Action"))
      end button   
   end window

  Main.Center
  Main.Activate
RETURN // Main()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

HB_FUNC ( NOCLOSEDLG ) // ( hWnd )

{
   HMENU hMenu = GetSystemMenu( ( HWND ) hb_parnl( 1 ), FALSE ) ;
   EnableMenuItem( hMenu, SC_CLOSE, MF_GRAYED ) ;
}


HB_FUNC ( CLOSEDLG ) // ( hWnd ) MF_ENABLED

{
HMENU hMenu = GetSystemMenu( ( HWND ) hb_parnl( 1 ), FALSE ) ;
EnableMenuItem( hMenu, SC_CLOSE, MF_ENABLED ) ;
}

#pragma ENDDUMP

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

Re: Disable [Dim] Close Button "X"

Posted: Thu Aug 21, 2014 11:01 am
by esgici
bpd2000 wrote:Find working example to Disable [Dim] / Enable Close Button "X"
Tested, worked fine 8-)

Thanks Dave :)

Regards

Disable [Dim] Close Button "X"

Posted: Thu Aug 21, 2014 11:24 am
by Pablo César
Thanks Dave for sharing !

Re: Disable [Dim] Close Button "X"

Posted: Fri Aug 22, 2014 3:29 am
by Javier Tovar

Code: Select all

By BPD2000
Gracias por el ejemplo, bueno! :)

Saludos

Re: Disable [Dim] Close Button "X"

Posted: Fri Aug 22, 2014 4:41 pm
by bpd2000
Code for Console application

Code: Select all

/*
 Disable / Enable close button in console application"
 Code by BPD2000
*/ 
   
#include "hbgtinfo.ch" 
#include "Inkey.ch"

REQUEST HB_GT_WIN_DEFAULT
function Main()
  
  LOCAL nChoice := 1
  SET WRAP ON
  SET MESSAGE TO 23 CENTER
  SET( _SET_EVENTMASK, INKEY_KEYBOARD + INKEY_LDOWN )
	setcolor( "N/W,N/GR*,,,N/W*" ) 
  SetMode( 25, 80 ) 
	CLS
  DO WHILE (LASTKEY() != K_ESC) 
        @ 6, 30 PROMPT "Disable_X" MESSAGE "Disable close button in console application"
        @ 7, 30 PROMPT "Enable_X " MESSAGE "Enable close button in console application"
        @ 9, 30 PROMPT "Quit     " MESSAGE "Return to DOS"
        MENU TO nChoice
      
        DO CASE
        CASE nChoice = 0
          QUIT
        CASE nChoice = 1
           Disable_X()
        CASE nChoice = 2
           Enable_X()
        CASE nChoice = 3
           QUIT
        ENDCASE
  ENDDO 
RETURN

Function Disable_X
 hb_GtInfo( HB_GTI_CLOSABLE, .F. ) 
Return 

Function Enable_X
 hb_GtInfo( HB_GTI_CLOSABLE, .T. ) 
Return 

Re: Disable [Dim] Close Button "X"

Posted: Fri Aug 22, 2014 5:45 pm
by abinfra
Thank you really bpd2000.

A hug.

Re: Disable [Dim] Close Button "X"

Posted: Fri Aug 22, 2014 5:47 pm
by LOUIS
bpd2000

You are a Genius !!!

Thank You very much !!!

You solved my problem of many years :ugeek:

HMG I LOVE YOU !!!

Re: Disable [Dim] Close Button "X"

Posted: Fri Aug 22, 2014 6:53 pm
by abinfra
bpd2000, could inform me that serves the following statement:

Code: Select all

SET( _SET_EVENTMASK, INKEY_KEYBOARD + INKEY_LDOWN )
Thanks in advance.
Antonio Belando

Re: Disable [Dim] Close Button "X"

Posted: Fri Aug 22, 2014 10:37 pm
by abinfra
The following example will inform INKEY() to terminate if a keyboard event occurs or the left mouse button has been clicked.

SET EVENTMASK TO INKEY_KEYBOARD + INKEY_LDOWN


abinfra wrote:bpd2000, could inform me that serves the following statement:

Code: Select all

SET( _SET_EVENTMASK, INKEY_KEYBOARD + INKEY_LDOWN )
Thanks in advance.
Antonio Belando

Re: Disable [Dim] Close Button "X"

Posted: Sat Aug 23, 2014 3:21 am
by bpd2000
abinfra wrote:The following example will inform INKEY() to terminate if a keyboard event occurs or the left mouse button has been clicked.

SET EVENTMASK TO INKEY_KEYBOARD + INKEY_LDOWN


abinfra wrote:bpd2000, could inform me that serves the following statement:

Code: Select all

SET( _SET_EVENTMASK, INKEY_KEYBOARD + INKEY_LDOWN )
Thanks in advance.
Antonio Belando
You may remove SET EVENTMASK TO INKEY_KEYBOARD + INKEY_LDOWN if you not require