AutoHotkey Community

It is currently May 26th, 2012, 1:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [function] ShowModal
PostPosted: December 19th, 2007, 9:02 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Code:
;----------------------------------------------------------------------------------------------
; Function:     ShowModal
;               Show GUI modaly. The script continues after the GUI is closed.
;
; Parameters:
;               hGui    - GUI number of the window to be shown
;               hParent - Parents GUI number. Parent will be disabled while hGui is active
;
; Remarks: 
;               When the function returns, default gui will be set to hGui.
;
ShowModal( hGui, hParent ) {
    gui %hParent%:+Disabled
    gui %hParent%:+LastFound
    hp := WinExist()
    Gui, %hGui%:Default
    Gui, +LastFound
    hc := WinExist()
    ShowModal_OnA(hc,hp,"set",0)

    Gui %hGui%:Show
    old := OnMessage(6, "ShowModal_OnA")
    WinWaitClose, ahk_id %hc%
    gui %hParent%:-Disabled
    OnMessage(6, old)
}

ShowModal_OnA(wparam, lparam, msg, hwnd){
    static hc, hp   
   
    if msg = set
        return hc := wparam, hp := lparam
       
    if (wparam & 0xFF) and (hwnd = hp)
        WinActivate ahk_id %hc%
}


Example:

Code:
   Gui, 2:add, button, gOnbutton, open modal window
   Gui, 2:Show, autsize
return

Create(){
   Gui, 3:add, text, , some text
   Gui, 3:Show, x400 y400 Hide autsize
}

GuiClose:
   ExitApp
return

OnButton:
   hwnd := Create()
   ShowModal(3, 2)
   msgbox after
return

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 27 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group