mIRC Homepage
Posted By: Anonymous Prevent Dialog from Closing by ESC or x Button - 14/01/16 04:18 PM
Hi,

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

BR,
Balla.
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)
Posted By: Anonymous Re: Prevent Dialog from Closing by ESC or x Button - 14/01/16 11:04 PM
can you please show me an example? and from where i can get cwnd.dll ?
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
}
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
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 }
}
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.
© mIRC Discussion Forums