Windows close to floor

Closing the Window

When the user closes a window, that action triggers a sequence of window messages.

The user can close an application window by clicking the Close button, or by using a keyboard shortcut such as ALT+F4. Any of these actions causes the window to receive a WM_CLOSE message. The WM_CLOSE message gives you an opportunity to prompt the user before closing the window. If you really do want to close the window, call the DestroyWindow function. Otherwise, simply return zero from the WM_CLOSE message, and the operating system will ignore the message and not destroy the window.

Here is an example of how a program might handle WM_CLOSE.

In this example, the MessageBox function shows a modal dialog that contains OK and Cancel buttons. If the user clicks OK, the program calls DestroyWindow. Otherwise, if the user clicks Cancel, the call to DestroyWindow is skipped, and the window remains open. In either case, return zero to indicate that you handled the message.

If you want to close the window without prompting the user, you could simply call DestroyWindow without the call to MessageBox. However, there is a shortcut in this case. Recall that DefWindowProc executes the default action for any window message. In the case of WM_CLOSE, DefWindowProc automatically calls DestroyWindow. That means if you ignore the WM_CLOSE message in your switch statement, the window is destroyed by default.

When a window is about to be destroyed, it receives a WM_DESTROY message. This message is sent after the window is removed from the screen, but before the destruction occurs (in particular, before any child windows are destroyed).

In your main application window, you will typically respond to WM_DESTROY by calling PostQuitMessage.

We saw in the Window Messages section that PostQuitMessage puts a WM_QUIT message on the message queue, causing the message loop to end.

Here is a flow chart showing the typical way to process WM_CLOSE and WM_DESTROY messages:

Gideon’s desk…

Graphisoft Registered Consultant, helping the ArchiCAD community

Window-to-floor area ratio calculation in 4 easy steps (SANS 10400-XA 4.4.4.1 & 2)

First some background: New legislation in South Africa dictates that it is necessary to determine the window-to-floor area. This ‘regulation’ is applicable to many other countries, not just South Africa. (LEED in USA, Green Building – various countries, Energy Star etc…)

Читайте также:  Windows 10 latest service pack что это

“SANS 10400- XA 4.4.4 Fenestration

4.4.4.1 Buildings with up to 15 % fenestration area to nett floor area per storey comply with the minimum energy performance requirements.

4.4.4.2 Buildings with a fenestration area to nett floor area per storey that exceeds 15 % shall comply with the requirements for fenestration in accordance with SANS 204.”

This window-to-floor area ratio balances energy, first cost, and indoor environmental quality. This will prevent solar gain from overheating the living space. Having too little glazing misses out on free solar energy – but too much glazing can result in excessive heat gain in the summer and unnecessary heat loss in the winter.

From a purely economic viewpoint, lower window area ratios lower the first cost to purchase. Window-to-floor area ratios above 15% for standard construction require increased envelope performance ratings and mechanical equipment efficiencies.

While energy use increases with window area, the penalty is not significant when high performance windows (double or triple glazed) are used. But of course the first cost to purchase for these are much, much more higher.

How to:

I am aware that there are “fenestration calculators” available (there is even one for purchase?) But these still require the user to manually count the windows (Yes, 1, 2, 3, 4….etc) together with their relevant height x width. In-fact this method is daft and pales in comparison to the speed and ease that this is possible to achieve using ArchiCAD.

In this example I used the standard “ArchiCAD 15 Template” (INT English). The example building is a 2 story office building. Ground Floor = 260m2 and First Floor = 260m2. Therefore 260 x 15% = 39m2

Place a zone stamp on the floor plan to establish the total floor area per story (this can be done with one click)

How to do this in 4 easy steps:

In the Navigator – Project Map > Schedules > Element double click on “Window list” to open it.

Click on “Scheme Settings…”

Under Criteria / Window List – click on “Add” and change criteria to “Story” (this will filter the window schedule by story) Just remember to change this to “1”. Later on you can also duplicate the Scheme – Window List and “Rename” it to Window List Ratio Ground Floor and Window List Ratio First Floor for example.

Under Fields / Window List Copy – find the field “W/D opening surface on the reveal side”. Related to each selected schedule field, 3 buttons are available at the right to fine-tune sorting criteria. Choose display a “sum” to add a schedule cell that will contain the sum total for all items of this field.

Читайте также:  Что такое rsync linux

Click on “OK” to close the Scheme Settings window. You will then see the total square meter displayed for all the windows for the story selected.

Summary: As per the result (which only takes a minute to set up) one can clearly see that in this example both the Ground & First floor fenestration do not exceed the 15% per floor area ratio. Of course the windows can be modified and optimized, individually or globally, and the resultant ratio established by a simple click on Window List to recalculate the result in seconds.

window.close and self.close do not close the window in Chrome

The issue is that when I invoke window.close() or self.close() it doesn’t close the window. Now there seems to be a belief that in Chrome you can’t close by script any window that is not script created. That is patently false but regardless it is supposed to still do it, even if it requires to pop up an alert to confirm. These are not happening.

So does anyone have real, functional and proven method of closing a window using something like javascript:window.close() or javascript:self.close() that actually does what is expected and something that happens just fine in every browser that is NOT Chrome based? Any suggestions would be greatly appreciated and I am looking for Javascript specific solution, nothing JQuery or third party implementation.

Update: While much of what has been suggested has serious limitations and usability issues, the latest suggestion (specific to TamperMonkey) using // @grant window.close in the script header will often do the trick even on those tabs that normally can’t handle the close method. While not entirely ideal and doesn’t generalized to every case, it is a good solution in my case.

16 Answers 16

Ordinary javascript cannot close windows willy-nilly. This is a security feature, introduced a while ago, to stop various malicious exploits and annoyances.

The close() method on Window objects should, if all the following conditions are met, close the browsing context A:

  • The corresponding browsing context A is script-closable.
  • The browsing context of the incumbent script is familiar with the browsing context A.
  • The browsing context of the incumbent script is allowed to navigate the browsing context A.

A browsing context is script-closable if it is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), or if it is a browsing context whose session history contains only one Document.

Читайте также:  Microsoft planner для windows 10

This means, with one small exception, javascript must not be allowed to close a window that was not opened by that same javascript.

Chrome allows that exception — which it doesn’t apply to userscripts — however Firefox does not. The Firefox implementation flat out states:

This method is only allowed to be called for windows that were opened by a script using the window.open method.

If you try to use window.close from a Greasemonkey / Tampermonkey / userscript you will get:
Firefox: The error message, » Scripts may not close windows that were not opened by script. »
Chrome: just silently fails.

The long-term solution:

The best way to deal with this is to make a Chrome extension and/or Firefox add-on instead. These can reliably close the current window.

However, since the security risks, posed by window.close , are much less for a Greasemonkey/Tampermonkey script; Greasemonkey and Tampermonkey could reasonably provide this functionality in their API (essentially packaging the extension work for you).
Consider making a feature request.

The hacky workarounds:

Chrome is currently was vulnerable to the «self redirection» exploit. So code like this used to work in general:

This is buggy behavior, IMO, and is now (as of roughly April 2015) mostly blocked. It will still work from injected code only if the tab is freshly opened and has no pages in the browsing history. So it’s only useful in a very small set of circumstances.

However, a variation still works on Chrome (v43 & v44) plus Tampermonkey (v3.11 or later). Use an explicit @grant and plain window.close() . EG:

Thanks to zanetu for the update. Note that this will not work if there is only one tab open. It only closes additional tabs.

Firefox is secure against that exploit. So, the only javascript way is to cripple the security settings, one browser at a time.

You can open up about:config and set
allow_scripts_to_close_windows to true .

If your script is for personal use, go ahead and do that. If you ask anyone else to turn that setting on, they would be smart, and justified, to decline with prejudice.

There currently is no equivalent setting for Chrome.

Оцените статью