mIRC Homepage
Posted By: greeny Closing channel window... - 06/01/05 06:32 PM
Hi there,

is there any way to detect that a channel window is being closed while NOT connected to a server? Since on part obviously only triggers while connected to a server...
Posted By: tidy_trax Re: Closing channel window... - 06/01/05 06:44 PM
I don't think so, I thought on close might work but this is at the bottom:

Quote:
Note: These events do not trigger for any other types of windows. Channel windows are handled by the on JOIN/PART events.
Posted By: greeny Re: Closing channel window... - 06/01/05 07:38 PM
On close didn't work, already tried that smirk
Posted By: SladeKraven Re: Closing channel window... - 06/01/05 07:59 PM
That's what tidy said, that it wouldn't work.
Posted By: greeny Re: Closing channel window... - 06/01/05 09:13 PM
Yeah.. I guess it's time for a feature suggestion then..
Posted By: SladeKraven Re: Closing channel window... - 06/01/05 09:29 PM
How would we benefit though? Not being connected to a server an all, IMO, it is pretty pointless.
Posted By: greeny Re: Closing channel window... - 06/01/05 10:02 PM
Well, I need it for a treeview switchbar I'm making. I often disconnect from servers and then close channels while disconnected, so I don't rejoin them.
Posted By: tidy_trax Re: Closing channel window... - 06/01/05 10:06 PM
Even if nobody benefits it makes sense that you should be able to detect a channel window closing when you're not connected, since you can with every other type of window.
Posted By: SladeKraven Re: Closing channel window... - 06/01/05 10:10 PM
Well, I guess so. smile
Posted By: FiberOPtics Re: Closing channel window... - 06/01/05 10:24 PM
Well, it's certainly possible, but to be honest, the code is far from pretty :tongue:

So I suppose the choice you have to make is: either find a dll that triggers on the closing of a channel window, and gives a signal so you can handle it. Though then you have one more dll in your script.

Or you could try out this script, it worked for me, but perhaps you're not too fond of using timers. Note that the interval right now for checking the windows is at 50 ms. Adjust it at will.

When a channel is closed, a signal will be sent to CHANCLOSE with two parameters: 1 = cid, 2 = window name.

Code:
on *:SIGNAL:chanclose:{
  ; your code here 
  ; example: echo -sa Closed channel $2 from server window with cid $1 
}
[color:red]  [/color] 
on *:DISCONNECT: owin.start
on *:CONNECT: owin.stop 
 [color:red]  [/color] 
alias owin.start {
  var %a = 1, %b = net $+ $cid
  while $window(#*,%a) { hadd -m %b $v1 1 | inc %a } 
  if $hget(%b) { .timerowin.chk -m 0 50 owin.chk $cid %b }
}
 [color:red]  [/color] 
alias owin.stop {
  if $hget(net $+ $cid) { .timerowin.chk off | hfree $v1 }
}
[color:red]  [/color] 
alias owin.chk {
  scid $1
  if $hget($2,0).item > $window(#*,0) { 
    var %a = $v1, %b = %a - $v2, %c
    while %b && $hget($2,%a).item {
      %c = $v1
      if !$window(%c) {
        hdel $2 %c
        signal chanclose $1 %c
        if !$hget($2,1).item { owin.stop | return }
        dec %b
      }
      dec %a 
    }
  }
}


Greets
Posted By: greeny Re: Closing channel window... - 07/01/05 01:35 AM
Well, I managed to find another way to achieve this...

I'm looking at the on active event, check $lactive and if it no longer exists, I trigger my aliases smile

Better than timers I think.
Posted By: FiberOPtics Re: Closing channel window... - 07/01/05 01:53 AM
Lol that doesn't really work, well it does but only in limited cases.

Because it requires for you to actually left click on the channel window before closing it.

Try it like this: go with your mouse over a channel button, and right click and press close. Active event won't have triggered for that window, and the $lactive identifier won't be filled with this window when you click another window, so nothing will happen.

Also if you programmatically close windows, it won't happen either. For example: connect to a server, join channels #one and #two. Then disconnect from the server, and then type /part #one. The channel window will close, but once again, active event didn't trigger, so nothing happens.

Anyway, that code was for you, so you should just use whatever you please, if you rather go with the active event, then thats your choice of course.

Greets
Posted By: greeny Re: Closing channel window... - 07/01/05 03:50 PM
Well FiberOptics, in my case it does work, because as I said I'm using a treeview switchbar, and I don't have no channel buttons, so the window always becomes active before I can close it.

And if I _am_ connected to a server, I can still use the on part event.
Posted By: FiberOPtics Re: Closing channel window... - 07/01/05 05:15 PM
Ah ok, Ic, if it's one of those treeview bars that hide the regular bar, then of course those aren't issues for you. I never customize my mIRC with stuff like docked dialogs, switchbars etc, just regular mIRC here.

Oh, the /part thing I noted that it doesn't work when you are offline. Seems the on part event doesn't trigger when you aren't connected, even though it closes the channel window.

Anyway, cya around!
© mIRC Discussion Forums