Announcement

Collapse
No announcement yet.

Remove close button from DOS apps

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remove close button from DOS apps

    RE: Remove close button from DOS programs http://groups.google.com/group/micro...f8dd981bf79984

    Found this link to a program that removes the close button from
    DOS programs. Anyone have a PB solution? This one doesn't
    come with source and uses VB. Think I can come up with it, but
    need to get the handle of the DOS program. This program removes
    the close button from the next console app loaded if loaded
    with the /1 option. If no option is used all close buttons
    of console and DOS apps are removed and the program stays in memory.

    Link to the exe http://www.uwe-sieber.de/files/consolenoclose.zip
    ------------------
    Code:
    if exist ConsoleNoClose.exe if exist \windows\system32\msvbvm60.dll ConsoleNoClose /1


    [This message has been edited by Mike Doty (edited July 24, 2006).]
    How long is an idea? Write it down.

  • #2
    'This seems to work.
    'shell to this or place in a batch file before main program
    'works even if program starts full screen and Alt+Enter used.
    Code:
    #COMPILE EXE "NoClose.exe"
    #CONSOLE ON
    #DIM ALL
    #INCLUDE "WIN32API.INC"
    FUNCTION PBMAIN () AS LONG
      DIM hMenu AS LONG
      hMenu = GetSystemMenu(CONSHNDL, 0)
      CALL EnableMenuItem(hMenu, %SC_CLOSE, %MF_BYCOMMAND OR %MF_GRAYED OR %MF_DISABLED)
      CALL DeleteMenu(hMenu, %SC_CLOSE, %MF_BYCOMMAND)
    END FUNCTION
    ------------------




    [This message has been edited by Mike Doty (edited July 24, 2006).]
    How long is an idea? Write it down.

    Comment


    • #3
      i posted what i think was a good program and had some help from fellow
      pb member
      check it out
      here it is again


      REM XCLOSEBX.BAS
      REM PROGRAM TO CONTROL WHETHER OR NOT A USER IS ALLOWED TO CLOSE
      REM A PROGRAM USING THE X BUTTON IN A WINDOW IN ADDITION TO ALT-F4
      REM COMPILER USED IS POWERBASIC CONSOLE COMPILER VER 4.01
      REM DATE CREATED "06/09/06"
      REM PROGRAM WRITTEN BY PAUL PURVIS


      #COMPILE EXE
      #DIM ALL
      #IF NOT %DEF(%WINAPI)
      #INCLUDE "WIN32API.INC"
      #ENDIF
      FUNCTION PBMAIN() AS LONG
      LOCAL hSysMenu AS LONG
      LOCAL sTemp AS STRING
      LOCAL COMMANDTAIL AS STRING

      COMMANDTAIL=" "+TRIM$(UCASE$(COMMAND$))
      IF LEN(COMMANDTAIL)<2 THEN GOTO ERRORLINE

      IF INSTR(1," ENABLED",COMMANDTAIL)>0 GOTO XCLOSEENABLED
      IF INSTR(1," DISABLED",COMMANDTAIL)>0 GOTO XCLOSEDISABLED

      ERRORLINE:
      STDOUT " XCLOSEBX controls the x button(close program) in a windows dos box"
      STDOUT ""
      STDOUT " error try using the following"
      STDOUT " XCLOSEBX ENABLED = x button is enabled"
      STDOUT " XCLOSEBX DISABLED = x button is disabled"
      SLEEP 2000
      EXIT FUNCTION

      XCLOSEDISABLED:
      hSysMenu = GetSystemMenu(CONSHNDL,BYVAL 0)
      STDOUT " the x button is disabled"
      GOTO XCLOSEEND

      XCLOSEENABLED:
      hSysMenu = GetSystemMenu(CONSHNDL,BYVAL 1)
      STDOUT " the x button is enabled"

      XCLOSEEND:
      DeleteMenu hSysMenu,6,%MF_BYPOSITION

      END FUNCTION

      p purvis

      Comment


      • #4
        'Found a problem with previous code.
        'Need MOUSE ON or DOS app may lose mouse support

        Code:
        #COMPILE EXE "NoClose.exe"
        #CONSOLE ON
        #DIM ALL
        #INCLUDE "WIN32API.INC"
        FUNCTION PBMAIN () AS LONG
          MOUSE ON            'or you may lose mouse support
        
          DIM hMenu AS LONG
          hMenu = GetSystemMenu(CONSHNDL, 0)
          CALL EnableMenuItem(hMenu, %SC_CLOSE, %MF_BYCOMMAND OR %MF_GRAYED OR %MF_DISABLED)
          CALL DeleteMenu(hMenu, %SC_CLOSE, %MF_BYCOMMAND)
        END FUNCTION

        ------------------
        How long is an idea? Write it down.

        Comment

        Working...
        X