Results 1 to 5 of 5

Thread: Make window vanish and return

  1. #1

    Make window vanish and return

    I wasn't in the mood to do any real work so I came up with this:

    [code=thinbasic]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
    [/code]

    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

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Make window vanish and return

    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.

    [code=thinBASIC]
    %SW_HIDE
    %SW_RESTORE
    [/code]


    Thanks,
    Petr

    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Make window vanish and return

    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.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  4. #4

    Re: Make window vanish and return

    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

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Make window vanish and return

    Thanks a lot Sandy for those examples.

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

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. FILE_Move unexpected return value
    By AlexOZ in forum thinBasic General
    Replies: 1
    Last Post: 23-05-2008, 06:45

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •