GLBasic forum

Main forum => GLBasic - en => Topic started by: Robert on 2015-Apr-02

Title: How get rid of minimize button
Post by: Robert on 2015-Apr-02
I have a program that have to loop all the time and what I have understand you then must uppdate the screen in the loop but then you cant minimize without a crash. I want to either not uppdate screen or get rid of the minimized button so that the user not can crash the program. Is it possible on Windows? 
Title: Re: How get rid of minimize button
Post by: spacefractal on 2015-Apr-02
Im thinks this issue is due glb_do_pause() is called outside the main loop, etc a new thread have been created, but glbasic is not threadsafe. So its can crash sometimes. Im believe that function should only been called after or before SHOWSCREEN call.

Im did seen that in Android, and moved the calling pausemode to SHOWSCREN, which seens fixed it. Im believe its can happens on other platforms, which also include Windows (here im thinks minimize buttons is same as Hibernate).

But for Windows you should could do this to avoid it (its does not crash here):
AUTOPAUSE FALSE
AUTOESCAPE FALSE



Title: Re: How get rid of minimize button
Post by: Schranz0r on 2015-Apr-02
You have to change the Windowstyle.
I make a example later
Title: Re: How get rid of minimize button
Post by: Moru on 2015-Apr-02
If it is some background process that has no grafical output you can just compile it as a console program. See the checkbox in the project options. Ofcourse there are some limits on what commands you can use for console programs so this only works if it's some background process that does not display anything except for text.
Title: Re: How get rid of minimize button
Post by: Robert on 2015-Apr-02
Quote from: spacefractal on 2015-Apr-02
Im thinks this issue is due glb_do_pause() is called outside the main loop, etc a new thread have been created, but glbasic is not threadsafe. So its can crash sometimes. Im believe that function should only been called after or before SHOWSCREEN call.

Im did seen that in Android, and moved the calling pausemode to SHOWSCREN, which seens fixed it. Im believe its can happens on other platforms, which also include Windows (here im thinks minimize buttons is same as Hibernate).

But for Windows you should could do this to avoid it (its does not crash here):
AUTOPAUSE FALSE
AUTOESCAPE FALSE


Ok intresting but I have set the autopause and autopause false
Title: Re: How get rid of minimize button
Post by: Robert on 2015-Apr-02
Quote from: Schranz0r on 2015-Apr-02
You have to change the Windowstyle.
I make a example later

It sounds like its that I need so I am waiting.
Title: Re: How get rid of minimize button
Post by: Robert on 2015-Apr-02
Quote from: Moru on 2015-Apr-02
If it is some background process that has no grafical output you can just compile it as a console program. See the checkbox in the project options. Ofcourse there are some limits on what commands you can use for console programs so this only works if it's some background process that does not display anything except for text.

I tried that but I couldn't get it to work the way I wanted with just console commands. Its not graphic but I want it to interact in a way that wasn't possible in a console. 
Title: Re: How get rid of minimize button
Post by: Schranz0r on 2015-Apr-03
Here we go!
Sry, yesterday there was not enough time for me :/

I remove the window Menu, so you only have the windowcaption available.
Title: Re: How get rid of minimize button
Post by: Robert on 2015-Apr-03
Quote from: Schranz0r on 2015-Apr-03
Here we go!
Sry, yesterday there was not enough time for me :/

I remove the window Menu, so you only have the windowcaption available.

Thanks. It works as I wanted. I don't care about having the close button for this projekt but is it possible to modifie the inline code so that you keep it?   

Title: Re: How get rid of minimize button
Post by: Schranz0r on 2015-Apr-03
Sure, check this out:

Code (glbasic) Select
INLINE
        }
        extern "C" int __stdcall GetWindowLongA(void*, int);
        extern "C" int __stdcall SetWindowLongA(void*, int, int);
        #define GWL_STYLE                       (-16)
        #define WS_SYSMENU        0x00080000L
        #define WS_MAXIMIZEBOX 0x00010000L
        #define WS_MINIMIZEBOX 0x00020000L
        namespace __GLBASIC__ {
ENDINLINE

FUNCTION disableWindowMenu:
INLINE

    int style = ::GetWindowLongA(GLBASIC_HWND(), GWL_STYLE);
    style &= ~WS_MAXIMIZEBOX;
    style &= ~WS_MINIMIZEBOX;
::SetWindowLongA(GLBASIC_HWND(), GWL_STYLE,  style);

ENDINLINE
ENDFUNCTION
Title: Re: How get rid of minimize button
Post by: Robert on 2015-Apr-04
This was perfect because now I also see the icon in the window.