Disable [Dim] Close Button "X"

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Disable [Dim] Close Button "X"

Post 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

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
BPD
Convert Dream into Reality through HMG
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Disable [Dim] Close Button "X"

Post by esgici »

bpd2000 wrote:Find working example to Disable [Dim] / Enable Close Button "X"
Tested, worked fine 8-)

Thanks Dave :)

Regards
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Disable [Dim] Close Button "X"

Post by Pablo César »

Thanks Dave for sharing !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Disable [Dim] Close Button "X"

Post by Javier Tovar »

Code: Select all

By BPD2000
Gracias por el ejemplo, bueno! :)

Saludos
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Disable [Dim] Close Button "X"

Post 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 
BPD
Convert Dream into Reality through HMG
abinfra
Posts: 68
Joined: Sat Jan 25, 2014 7:25 am
DBs Used: DBF

Re: Disable [Dim] Close Button "X"

Post by abinfra »

Thank you really bpd2000.

A hug.
User avatar
LOUIS
Posts: 202
Joined: Tue Dec 11, 2012 9:05 pm
DBs Used: DBF

Re: Disable [Dim] Close Button "X"

Post by LOUIS »

bpd2000

You are a Genius !!!

Thank You very much !!!

You solved my problem of many years :ugeek:

HMG I LOVE YOU !!!
abinfra
Posts: 68
Joined: Sat Jan 25, 2014 7:25 am
DBs Used: DBF

Re: Disable [Dim] Close Button "X"

Post 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
abinfra
Posts: 68
Joined: Sat Jan 25, 2014 7:25 am
DBs Used: DBF

Re: Disable [Dim] Close Button "X"

Post 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
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Disable [Dim] Close Button "X"

Post 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
BPD
Convert Dream into Reality through HMG
Post Reply