mIRC Homepage

Custom-Window centered to mIRC-Window

Posted By: daniel61

Custom-Window centered to mIRC-Window - 31/01/21 12:14 PM

Hello smile

I am looking for a way to create custom-windows centered relative to mirc-window.
Option -C refers to screen, not mirc. so I used size of mirc-window ($window(-2).w / .h ) to calculate position, but this does not work when mirc-windows is placed on right side of screen.

is there any option/parameter/way to create new custom windows centered to mirc-window?

thanks guys
Posted By: maroon

Re: Custom-Window centered to mIRC-Window - 03/02/21 02:52 PM

Does using -1 -1 as the x and y positions do what you wish?
Posted By: Talon

Re: Custom-Window centered to mIRC-Window - 05/02/21 05:44 AM

If I'm following you correctly you're attempting to center a "desktop" window relative to mIRC's position? where -C centers it to the desktop?

I broke this down into a few sections, mIRC's position on the desktop (-2 both .dx and .dy) and mIRC's dimensions on the desktop (-2 .w and .w)
so knowing this, mIRC's position + half of it's dimension = center pixel relative to mIRC's overall size and position on the desktop.

If you know your custom @window's size, then simply taking that position and subtracting half it's dimensions would be the screen coordinates you need to be centered within the mIRC window. Here's a quick example alias demonstrating the effect.

Code
cwt {
  var %mx = $window(-2).dx , %my = $window(-2).dy
  var %mw = $window(-2).w , %mh = $window(-2).h
  var %cw = 320 , %ch = 240 
  var %px = $calc(%mx + %mw / 2 - %cw / 2) , %py = $calc(%my + %mh / 2 - %ch / 2)
  window -dpf @CenterWindowTest %px %py %cw %ch
}
Posted By: daniel61

Re: Custom-Window centered to mIRC-Window - 07/02/21 11:54 AM

@Talon

yes, thats it! thanks a lot!
© 2022 mIRC Discussion Forums