{"id":441,"date":"1997-09-09T01:36:29","date_gmt":"1997-09-09T09:36:29","guid":{"rendered":"http:\/\/www.birdhouse.org\/betips\/?p=441"},"modified":"1997-09-09T01:36:29","modified_gmt":"1997-09-09T09:36:29","slug":"control-window-look-feel-or-behavior-with-hey","status":"publish","type":"post","link":"https:\/\/www.betips.net\/?p=441","title":{"rendered":"Control window look, feel, or behavior with &quot;hey&quot;"},"content":{"rendered":"<p>A few tips on this site allude to ways in which you can control the window look, feel, or behavior of your BeOS applications by sending them BMessages with <a href=\"http:\/\/w3.datanet.hu\/~amezei\/\">hey<\/a> (see for example <a href=\"\/chunga.php?ID=467\">Keep focus when switching workspaces<\/a>). What&#8217;s not obvious from reading those tips is how one determines the magic numbers used in the hey commands.<br \/>\nThe secret lies in the file <code>\/boot\/develop\/headers\/be\/interface\/Window.h<\/code> &#8212; a header file which contains a pile of window properties. If you look through this file, you&#8217;ll notice that it&#8217;s broken up into several sections:<\/p>\n<pre>\nwindow_type\nwindow_look\nwindow_feel\n<\/pre>\n<p>and a separate section for defining behaviors. The three sections above have numerical identifiers as standard integers, while the behaviors section has identifiers expressed in hexadecimal. Each BeOS application determines its own properties internally, but these properties can be overridden by sending appropriate message to an application or to a window.<br \/>\nIt&#8217;s quite easy to change the type, look, or feel of any given application window. For example, say you want to change the look of an open NetPositive window to &#8222;bordered.&#8220; In Window.h, you find a line:<\/p>\n<pre> B_BORDERED_WINDOW_LOOK = 20,<\/pre>\n<p>So you can simply type:<\/p>\n<pre>hey NetPositive set Look of Window 0 to 20<\/pre>\n<p>And boom &#8212; that NetPositive window loses its title tab and most of its chrome. So much for look and feel.<br \/>\n Because window <i>behaviors<\/i> are expressed in hex, and because behaviors can be a combination of one or more properties, things get a little more complex when changing behaviors.<br \/>\nSpecifically, the behaviour of a window is based on the value [val] passed to its SetFlags() function, and [val] can be a combination of any flags specified in <code>Window.h<\/code>. There&#8217;s also a SetFeel() function which acts on additional behaviour fields.<br \/>\nThe usual &#8222;algorithm&#8220; is to run:<\/p>\n<pre>hey ApplicationName get Flags<\/pre>\n<p>although in most cases you&#8217;ll have to also name a specific window of the application, like:<\/p>\n<pre>hey ApplicationName get Flags of Window 0<\/pre>\n<p>hey will return two numbers &#8212; something like:<\/p>\n<pre>\nReply BMessage(B_REPLY):\n   \"result\" (B_INT32_TYPE) : 16450 (0x00004042)\n<\/pre>\n<p>The first number in the result is a decimal value (16450 in this case). To change the behavior of this window, you need to <i>add<\/i> this value to the converted value you wish to change it to (behaviors are additive). Sound tricky? Bear with me. Looking again in <code>Window.h<\/code>, you see:<\/p>\n<pre> B_AVOID_FRONT = 0x00000080,<\/pre>\n<p>so to make this window not take focus automatically when switching workspaces (as described in the <a href=\"\/chunga.php?ID=467\">Keep focus when switching workspaces<\/a> tip), you would convert 0x00000080 to its equivalent decimal values (try this handy web-based <a href=\"http:\/\/www.tw2.co.uk\/webresources\/hex.html\">converter<\/a>), sum them, and set the window to the new value. You get 128+ 16450, or 16578. Now, you can simply enter:<\/p>\n<pre>hey NetPositive set Flags of Window 1 to 16578<\/pre>\n<p>and your window will add the &#8222;Avoid front&#8220; property to its current properties (if you switch to another workspace and back, that window will refuse to be at the front when you return to the workspace).<br \/>\nThis technique isn&#8217;t 100% foolproof (for example if you set an already set flag you might end up adding another random one, etc.) so a little caution is advised. But you won&#8217;t blow up your computer with hey, and you&#8217;ll get the original values back by simply restarting the application in question).<br \/>\nFor more on using hey, see Chris Herborth&#8217;s <a href=\"http:\/\/www.beosbible.com\/bos\/ch_scripting1.html\">Scripting chapter<\/a> in the BeOS Bible, or Seth Flaxman&#8217;s hey <a href=\"http:\/\/www.benews.com\/story\/2188\/\">tutorial<\/a> at BeNews.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few tips on this site allude to ways in which you can control the window look, feel, or behavior of your BeOS applications by sending them BMessages with hey (see for example Keep focus when switching workspaces). What&#8217;s not obvious from reading those tips is how one determines the magic numbers used in the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[7],"class_list":["post-441","post","type-post","status-publish","format-standard","hentry","tag-interface"],"_links":{"self":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=441"}],"version-history":[{"count":0,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/441\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}