• Disable Title bar close button with GTWin

    From Rob Fum@21:1/5 to All on Sun Oct 20 23:32:16 2024
    Hello,

    is there a way to disable or hide the close button on the title bar of a
    Gtwin application?

    If proven, I've found something that would be a weird bug: I suspect
    that sometimes when the user closes the application using the close
    button, one or two new appended records are not written to the dbf.

    Any help is appriciated!
    Many thanks,
    Roberto

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Mon Oct 21 12:48:01 2024
    Il 21/10/2024 12:41, Rob Fum ha scritto:

    Yes a console program.

    From Copilot (warning: not tested):

    FUNCTION Main()
    // Altre inizializzazioni
    DisableCloseButton()
    // Il resto del codice del programma
    RETURN NIL


    #pragma BEGINDUMP

    #include <windows.h>


    HB_FUNC( DISABLE_CLOSE_BUTTON )
    {
    HWND hConsole = GetConsoleWindow();
    if (hConsole != NULL)
    {
    HMENU hMenu = GetSystemMenu(hConsole, FALSE);
    if (hMenu != NULL)
    {
    RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
    DrawMenuBar(hConsole);
    }
    }
    }

    #pragma ENDDUMP

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Mon Oct 21 12:27:04 2024
    Il 20/10/2024 23:32, Rob Fum ha scritto:

    Hello,

    is there a way to disable or hide the close button on the title bar of a Gtwin application?

    What is a "Gtwin application"? Do you mean a console program?

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Fum@21:1/5 to Enrico Maria Giordano on Mon Oct 21 12:41:46 2024
    On 21-Oct-24 12:27, Enrico Maria Giordano wrote:


    Il 20/10/2024 23:32, Rob Fum ha scritto:

    Hello,

    is there a way to disable or hide the close button on the title bar of
    a Gtwin application?

    What is a "Gtwin application"? Do you mean a console program?


    Yes a console program.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Fum@21:1/5 to Enrico Maria Giordano on Mon Oct 21 19:39:55 2024
    On 21-Oct-24 12:48, Enrico Maria Giordano wrote:
    #include <windows.h>
    Thank you, but it doesn't work.

    GetConsoleWindow() is unresolved.
    I tried with GetActiveWindow(); but nothing happens.

    #pragma BEGINDUMP

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

    HB_FUNC( DISABLECLOSEBUTTON )
    {
    HWND hConsole = GetActiveWindow();
    if (hConsole != NULL)
    {
    HMENU hMenu = GetSystemMenu(hConsole, FALSE);
    if (hMenu != NULL)
    {
    RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
    DrawMenuBar(hConsole);
    }
    }
    }


    #pragma ENDDUMP



    I've also tried with this code but the close button is always there.

    #pragma BEGINDUMP

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

    HB_FUNC( DISABLECLOSEBUTTON )
    {

    HWND hwnd = GetActiveWindow();

    if (hwnd != NULL)
    {
    SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
    }

    }
    #pragma ENDDUMP

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Mon Oct 21 21:18:24 2024
    This is working fine here:

    FUNCTION MAIN()

    SETMODE( 25, 80 )

    DISABLECLOSEBUTTON()

    ALERT( "Hello" )

    RETURN NIL


    #pragma BEGINDUMP

    #include "windows.h"


    HB_FUNC( DISABLECLOSEBUTTON )
    {
    HWND hConsole = GetConsoleWindow();

    if ( hConsole != NULL )
    {
    HMENU hMenu = GetSystemMenu( hConsole, FALSE );

    if ( hMenu != NULL )
    {
    RemoveMenu( hMenu, SC_CLOSE, MF_BYCOMMAND );
    DrawMenuBar( hConsole );
    }
    }
    }

    #pragma ENDDUMP

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Fum@21:1/5 to Enrico Maria Giordano on Tue Oct 22 14:57:04 2024
    On 21-Oct-24 21:18, Enrico Maria Giordano wrote:
    This is working fine here:

    Thank you, but as I got the unresolved external warning, I suppose the
    problem is that I'm using an old commercial (xharbour.com) version. This
    is the output of xBuild.


    Type: C >>>xhb.exe -o"obj\NoClose.c" -v -m -n -w1 -es2 -DxHARBOUR -I"C:\xhb\include" -I"C:\xhb\include\w32" "NoClose.prg"<<<

    xHarbour 1.2.3 Intl. (SimpLex) (Build 20180529)
    Copyright 1999-2018, http://www.xharbour.org http://www.harbour-project.org/ Compiling 'NoClose.prg'...
    Generating C source output to 'obj\NoClose.c'...
    Generating object output to 'obj\NoClose.obj'...
    NoClose.prg(20): warning #2027: Missing prototype for 'GetConsoleWindow'. NoClose.prg(20): warning #2052: Conversion from 'struct HWND__ *' to
    'int' is undefined.
    Done.

    Lines 12, Functions/Procedures 1, pCodes 19

    Type: C >>>xlink.exe -NOEXPOBJ -MAP -FORCE:MULTIPLE -NOIMPLIB -subsystem:console -LIBPATH:"C:\xhb\lib" -LIBPATH:"C:\xhb\c_lib" -LIBPATH:"C:\xhb\c_lib\win" "obj\NoClose.obj" "xhb.lib" "dbf.lib"
    "nsx.lib" "ntx.lib" "cdx.lib" "rmdbfcdx.lib" "ct3comm.lib" crt.lib
    kernel32.lib user32.lib winspool.lib ole32.lib oleaut32.lib odbc32.lib odbccp32.lib uuid.lib wsock32.lib ws2_32.lib wininet.lib advapi32.lib shlwapi.lib msimg32.lib mpr.lib OleDlg.lib version.lib -out:"NoClose.exe"<<<

    Creating object: NoClose.EXP
    Creating library: NoClose.LIB
    xLINK: error: Unresolved external symbol '_GetConsoleWindow referenced
    from (NoClose.obj)'.
    xLINK: fatal error: 1 unresolved external(s).

    Type: C >>>Couldn't build: NoClose.exe<<<
    Type: C >>>TMAKEPROJECT<<<
    Type: C >>>TMAKEPROJECT:REFRESH<<<
    Type: N >>> 1428<<<

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Tue Oct 22 17:02:56 2024
    Il 22/10/2024 14:57, Rob Fum ha scritto:

    This is working fine here:

    Thank you, but as I got the unresolved external warning, I suppose the problem is that I'm using an old commercial (xharbour.com) version. This
    is the output of xBuild.

    NoClose.prg(20): warning #2027: Missing prototype for 'GetConsoleWindow'.

    Search all of your *.h for "GetConsoleWindow" and let me know what you find.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Fum@21:1/5 to Enrico Maria Giordano on Wed Oct 23 10:46:21 2024
    On 22-Oct-24 17:02, Enrico Maria Giordano wrote:

    Search all of your *.h for "GetConsoleWindow" and let me know what you
    find.



    Wincon.h

    #if (_WIN32_WINNT >= 0x0500)
    ....
    ....
    ....
    WINBASEAPI HWND APIENTRY GetConsoleWindow(VOID);
    #endif /* _WIN32_WINNT >= 0x0500 */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Wed Oct 23 11:51:04 2024
    Il 23/10/2024 10:46, Rob Fum ha scritto:

    Search all of your *.h for "GetConsoleWindow" and let me know what you
    find.

    Wincon.h

    #if (_WIN32_WINNT >= 0x0500)
    ....
    ....
    ....
    WINBASEAPI HWND APIENTRY GetConsoleWindow(VOID);
    #endif /* _WIN32_WINNT >= 0x0500 */

    Try to add

    #include "windows.h"
    #include "wincon.h" <-- THIS

    and report back.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Fum@21:1/5 to All on Wed Oct 23 20:07:14 2024

    Try to add

    #include "windows.h"
    #include "wincon.h" <-- THIS

    and report back.

    Finally I found the solution!

    #define _WIN32_WINNT 0x0500
    #include "windows.h"
    #include "wincon.h"


    HB_FUNC( DISABLECLOSEBUTTON )
    {


    Thank you for you support!

    Roberto

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Wed Oct 23 20:25:01 2024
    Il 23/10/2024 20:07, Rob Fum ha scritto:

    Finally I found the solution!

    #define _WIN32_WINNT 0x0500
    #include "windows.h"
    #include "wincon.h"


    HB_FUNC( DISABLECLOSEBUTTON )
    {


    Thank you for you support!

    Great! :-)

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)