IonicWind Software

Creative Basic => General Questions => Topic started by: aurelCB on February 11, 2009, 02:58:22 AM

Title: Hidden Window
Post by: aurelCB on February 11, 2009, 02:58:22 AM
Hi ...

I tried to open the window as hidden with SW_HIDE but without success.
-------------------------------------------------------
CONST SW_HIDE = 0
Window win,0,0,400,300,@minbox|SW_HIDE,0,"Hidden",main
----------------------------------------------------------------
Then I tried to take the flag from hidden button, and I managed.
----------------------------------------------------------------
0x40080001
Window win,0,0,400,300,@minbox|0x40080001,0,"Hidden",main
----------------------------------------------------------------
Does someone maybe some better idea?
So,How to create a new window as hidden without the flashing?
Title: Re: Hidden Window
Post by: LarryMc on February 11, 2009, 04:52:09 AM
create the window offscreen with something like:

Window win,-1000,0,400,300,@minbox|0x40080001,0,"Hidden",main
then use

SETSIZE win,0, 0, 400, 300

Larry
Title: Re: Hidden Window
Post by: aurelCB on February 11, 2009, 06:18:49 AM
Larry...

I dont want create window out off screen.
I want create window as hidden like in Emergance with flag @hide.

My second example work.
Window win,0,0,400,300,@minbox|0x40080001,0,"Hidden",main

But I dont uderstand how work SW_HIDE ???
Title: Re: Hidden Window
Post by: sapero on February 11, 2009, 06:51:24 AM
Zlatko, SW_HIDE and other SW_* are reserved for use in ShowWindow and a few other api's like ShellExecute, CreateProcess.
You cound try to hide the window while processing @IDCREATE by calling ShowWindow win, @SWHIDE.
def win:window
Window win,0,0,400,300,@minbox|0x40080001,0,"Hidden",main
waituntil win=0
end
sub main
select @class
case @idcreate
showwindow win, @SWHIDE
starttimer win, 2000
case @IDTIMER
stoptimer win, 1
showwindow win, @SWRESTORE
case @IDCLOSEWINDOW
closewindow win
endselect
return
But it does not work, because the runtime forces the window to be visible.

There is a 'advanced' message WM_WINDOWPOSCHANGING where you can deny or update any changes to window position, size or z-order, by manipulating members of WINDOWPOS structure pointed by @LPARAM (it should work, but I'm unhappy to compile this snippet, I'm getting errors like WINDOWPOS is undefined)
def win:window
forcehide = 1
Window win,0,0,400,300,@minbox|0x40080001,0,"Hidden",main
waituntil win=0
end

CONST WM_WINDOWPOSCHANGING = 0x46
const SWP_SHOWWINDOW = 0x40

type WINDOWPOS
    def hwnd:int
    def hwndInsertAfter:int
    def x:int
    def y:int
    def cx:int
    def cy:int
    def flags:int
endtype


sub main
def wp:WINDOWPOS
def mem:memory

select @CLASS
case @IDCREATE
' show the window with 2 second delay
starttimer win, 2000

case WM_WINDOWPOSCHANGING
if forcehide
mem = @QUAL
readmem mem, 1, wp
wp.flags = wp.flags & (0xffffffff - SWP_SHOWWINDOW): ' remove SWP_SHOWWINDOW flag
writemem mem, 1, wp
forcehide = 0
endif

case @IDTIMER
stoptimer win, 1
forcehide = 0
showwindow win, @SWRESTORE

case @IDCLOSEWINDOW
closewindow win
endselect
return
Title: Re: Hidden Window
Post by: aurelCB on February 11, 2009, 12:06:16 PM
Hi Sapero...

Hmm this is very tricky...
I dont know how this work but work.
And only work when is :
case @idcreate
centerwindow win

Really weird.
I try this hiding with Abasic runtime.exe where is main window hidden and work. ::)

Here is last try:
' main hidden
def win,win2:window
def hide:int
'const SW_HIDE=0
CONST WS_VISIBLE = 0x10000000

Window win,0,0,550,400,@minbox|0x40080001,0,"Main Window",main
Setwindowcolor win,rgb(200,200,210)
CONTROL win,"B,Show Hidden,450,50,90,20,0,1"
'hidden in start
hide=1
Window win2,10,10,400,300,@minbox,0,"Hidden",hmain
'showwindow win2,@swhide
CONTROL win2,"B,Show Hidden,300,50,90,20,0,2"
'showwindow win2,@swrestore
move win2,10,10:print win2,"Window 2"

waituntil win2=0
'IF win2<>0 then closewindow win2
END
'----------------------------
SUB main
select @class
case @IDclosewindow
closewindow win
case @idcreate
centerwindow win
case @idcontrol
IF @controlid=1
IF win2=0
closewindow win
end
ENDIF
ENDIF

endselect
RETURN
'-------------------------
SUB hmain
select @class
case @IDclosewindow
closewindow win2
case @idcreate
centerwindow win2
case @idcontrol
IF @controlid=2
IF (hide=1)
'showwindow win,@swrestore
SENDMESSAGE win,0x10000000,0,0
messagebox win,"Window 1 unable to open","Error"
Endif
ENDIF

endselect
RETURN
Title: Re: Hidden Window
Post by: aurelCB on February 12, 2009, 12:17:23 AM
Just one interesting thing ...
all controls which is created with turn off checkbox "Visible" in gui builder have
flag 0x40080001.
Is this flag universal or not?
Title: Re: Hidden Window
Post by: sapero on February 12, 2009, 01:56:14 AM
The high part 4008 (16 bits) describes system wide window styles (WS_*** constants: visible, caption, border, tabstop, minbox, maxbox) and has same meaning for any type of window. The low part 0001 (16 bits) describes individual styles for single control type or class. For buttons and checkboxes you use BS_ constants. For listview LVS_ ...
Title: Re: Hidden Window
Post by: aurelCB on February 12, 2009, 03:04:22 AM
Thanks Sapero...
I dont know that, interesting...
So catch is in first part.
ok