March 29, 2024, 09:04:01 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Eliminate Close Box on Window

Started by Bruce Peaslee, August 12, 2012, 08:42:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

Getting rid of the close box is normally a bad idea, but I am using a window for my splash screen and a close box, especially if made inoperative, is confusing to the user.

After literally days of web searching, here is IWB's easy solution:


OpenWindow wSplash, 0, 0, 484, 300, @BORDER, null, "Campanile Data Systems", null
int nStyles = GetWindowLong(wSplash.hwnd, GWL_STYLE)
nStyles = nStyles & ~WS_SYSMENU
SetWindowLong(wSplash.hwnd, GWL_STYLE, nStyles)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

LarryMc

More than one way to skin a cat.
This one displays  the splash for 5 seconds AFTER opening the main window.
There's a flash  centering the splash screen because the splash doesn't have its own @IDCREATE message handler.
window g_main,wsplash
OPENWINDOW g_main,0,0,650,650,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
OpenWindow wSplash, 0, 0, 484, 300, @BORDER, null, "Campanile Data Systems", null
centerwindow wSplash
MODIFYSTYLE wSplash, 0, @SYSMENU

REDRAWFRAME wSplash
starttimer g_main,5000
WAITUNTIL iswindowclosed(g_main)
END

SUB main(),int
    select @MESSAGE
case @IDCREATE
centerwindow g_main
case @IDTIMER
closewindow wsplash
stoptimer g_main
case @IDCLOSEWINDOW
        CLOSEWINDOW g_main
endselect
return 0
endsub


with this version the splash screen opens for 5 seconds then it closes aand the main window opens.
You can easily add a closing splash window with this scheme.

window g_main,wsplash

OpenWindow wSplash, 0, 0, 484, 300, @BORDER, null, "Campanile Data Systems", &splash
WAITUNTIL iswindowclosed(wSplash)

OPENWINDOW g_main,0,0,650,650,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
WAITUNTIL iswindowclosed(g_main)
END

SUB splash(),int
    select @MESSAGE
case @IDCREATE
centerwindow wSplash
MODIFYSTYLE wSplash, 0, @SYSMENU
REDRAWFRAME wSplash
starttimer wSplash,5000
case @IDTIMER
closewindow wsplash
stoptimer wSplash
case @IDCLOSEWINDOW
        CLOSEWINDOW wSplash
endselect
return 0
endsub
SUB main(),int
    select @MESSAGE
case @IDCREATE
centerwindow g_main
case @IDCLOSEWINDOW
        CLOSEWINDOW g_main
endselect
return 0
endsub
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ZeroDog

I have an even easier solution.  ;)

Use the following flags when creating your window:
@CAPTION|@NOCAPTION|@TOOLWINDOW

Using both @CAPTION and @NOCAPTION at the same time will remove the system menu but still have a caption bar, and using @TOOLWINDOW will keep the splash screen from being displayed on the task bar.

LarryMc

Quote from: ZeroDog on August 12, 2012, 10:02:29 PM
I have an even easier solution.  ;)

Use the following flags when creating your window:
@CAPTION|@NOCAPTION|@TOOLWINDOW

Using both @CAPTION and @NOCAPTION at the same time will remove the system menu but still have a caption bar, and using @TOOLWINDOW will keep the splash screen from being displayed on the task bar.
Neat - and I'm using that @TOOLWINDOW in the new IDe for that very reason.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Bruce Peaslee

Amazing. How did you discover that?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ZeroDog

I came across it by luck one day when trying out random combinations of windows flags.  Chances are, the two flags (@CAPTION and @NOCAPTION) were never intended on being used together, and combined they equal an existing WM flag (that I have yet to come across).

LarryMc

It works the way that it does because of the way the OPENWINDOW command is written.

The @CAPTION constant is the same as WS_CAPTION.
It is effectively passed straight through to the CreateWindow API.

The @NOCAPTION constant is an IWBasic constant that has no corresponding Windows constant.

The flags passed parameter is checked to see if @NOCAPTION  is present and sets an internal nocap flag.
It then strips @NOCAPTION  out of the flags parameter.

Later it checks the nocap flag.
If it is 0 (the @NOCAPTION  style was not passed) then it automatically adds WS_CAPTION | WS_SYSMENU to the flags passed to CreateWindow.

So it works the way it does because @NOCAPTION  doesn't add WS_CAPTION | WS_SYSMENU and @CAPTION  adds WS_CAPTION.

That way a default window with ) passed as the style will create a window with a caption and system menu.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library