PDA

View Full Version : Make window vanish and return



sandyrepope
09-08-2007, 19:55
I wasn't in the mood to do any real work so I came up with this:


uses "UI" 'use UI module

DIM hDlg AS DWORD 'dialog number assigned by OS
dim Msg, wparam,lparam as dword 'parameters used for os messages
%id_button = 10 'assign number to button to identify it
'make a window
DIALOG NEW 0, "Something FUN", -1, -1, 150, 100, _
%WS_DLGFRAME OR %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU OR %WS_OVERLAPPEDWINDOW, _
0 TO hDlg
'add a button to it
control add button, hDlg, %id_button, "CLICK ME", 5, 5, 50, 50, %ws_border

DIALOG SHOW modeless hDlg 'make window visible

while isWindow(hDlg) 'while loop to handle messages from OS
Msg = GetMessage(hDlg, wParam, lParam) 'get latest message

select case Msg 'message that was recieved
case %wm_command 'check command
select case wParam 'it will be here
case %id_button 'was button clicked?
dialog show state hDlg, 0 'make window invisible
sleep 1000 'do a little wait and then
dialog show state hDlg, 1 'make window visible again
end select
CASE %WM_SYSCOMMAND 'system command?
SELECT CASE wParam 'check variable
CASE %SC_CLOSE 'if close button in bar clicked then
EXIT WHILE 'exit while which will end program
END SELECT
END SELECT

wend

DIALOG END hDlg 'ends the program


What does it do? When the button is clicked the window vanishes and then after a few milliseconds returns. I know that is a silly thing to do but it does show how to use the command "dialog show state". I just learned how to do this.

Thanks
Sandy

Petr Schreiber
09-08-2007, 20:17
Thanks for sharing Sandy !,

you can also use following equates to not use directly numbers in DIALOG SHOW STATE.
I think I have seen them in helpfile somewhere.



%SW_HIDE
%SW_RESTORE



Thanks,
Petr

kryton9
10-08-2007, 01:23
Thanks Sandy, seeing these kind of useful snippets of code are great for everyone. Hiding and unhiding a window can be very important so nice example.

sandyrepope
10-08-2007, 02:50
Thanks, Petr. I tried the two % variables and they make the two lines clearer as to what is happening.

Kryton9. Thanks for the kind words. I hoped that this might be useful to someone. I wish I could get more ideas for things like this. Maybe when I learn even more.

Thanks
Sandy

ErosOlmi
10-08-2007, 09:52
Thanks a lot Sandy for those examples.

I've moved your post in this more appropriate forum.

Ciao
Eros