mIRC Home    About    Download    Register    News    Help

Print Thread
B
Balla
Balla
B
Hi,

how to prevent dialog from closing from ESC key, or x Button? how to take control over it?

BR,
Balla.

Joined: Jul 2006
Posts: 4,020
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,020
You can't prevent that with mIRC scripting, you can use a dll to do it if you want, such as cwnd.dll (doc is going to be in french but i can show an example)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
B
Balla
Balla
B
can you please show me an example? and from where i can get cwnd.dll ?

Joined: Dec 2015
Posts: 147
D
Vogon poet
Offline
Vogon poet
D
Joined: Dec 2015
Posts: 147
You can kind of do it without a DLL, just keep track on the close event and open the dialog again if it gets closed. You can still cancel it out by pressing CTRL+pause/break, or break it by holding ESC.

Code:
dialog -l helloworld {
  title "Hello world!"
  size -1 -1 100 50
  option dbu
  text "Hello world!", 1, 0 10 100 8, center
  button "HALP!", 2, 0 38 100 12
}

alias helloworld noop $dialog(helloworld,helloworld,-2)

on *:dialog:helloworld*:*:*: {
  if ($devent == close) noop $dialog(helloworld $+ $ticks,helloworld,-2)
  elseif ($devent == sclick) && ($did == 2) dialog -x $dname
}

Joined: Jul 2006
Posts: 4,020
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,020
Here is an example:

Code:
dialog test {
  size -1 -1 200 200
}
alias test_dialog {
  dialog -dm test test
  noop $dll(cwnd.dll,subclass,mysubclass $dialog(test).hwnd 1 mysubclass) $dll(cwnd.dll,block,mysubclass 1 SYSCOMMAND) $& 
  $dll(cwnd.dll,ignore,mysubclass 1 *) $dll(cwnd.dll,ignore,mysubclass 0 SYSCOMMAND)
}

alias mysubclass if ($2 == SYSCOMMAND) && ($3 != CLOSE) noop $dll(cwnd.dll,callWindowProc,mysubclass $2 $5 $6) 
alias test_dialog_close noop $dll(cwnd.dll,callWindowProc,mysubclass WM_CLOSE 0 0 0) $dll(cwnd,sfree,mysubclass) | dialog -x test
Use /test_dialog to try this example, do not call /dialog -x to close the dialog, use the /test_dialog_close alias, which will clean up stuff before calling /dialog -x

Dll is available here, documentation (in french) available here

Last edited by Wims; 15/01/16 09:42 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2008
Posts: 1,483
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,483
I've founded an .dll that can disable the X button from the dialogs you can get this dll and use this code in order to work. (of course cwnd.dll is much better)

Code:
dialog test {
  size -1 -1 200 200
}
ON *:DIALOG:test:*:*: {
  if ($devent == init) { dll hstylus.dll x_desabilitar $dialog($dname).hwnd }
}

Joined: Jul 2006
Posts: 4,020
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,020
I wouldn't know if it's better, depends on what it can do; I know the author of cwnd.dll, so I trust it better.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard