{"id":342,"date":"2019-09-29T13:33:13","date_gmt":"2019-09-29T19:33:13","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=342"},"modified":"2019-09-28T13:39:52","modified_gmt":"2019-09-28T19:39:52","slug":"switch-the-window-type-at-runtime","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2019\/09\/29\/switch-the-window-type-at-runtime\/","title":{"rendered":"Switch the window type at runtime"},"content":{"rendered":"\n<p>I&#8217;ve seen this question come up a couple times recently. And while it would be nice to do you cant. <\/p>\n\n\n\n<p>The frame type is required to be set when the window is constructed. And there&#8217;s no constructor on a window that allows you to do something like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dim w as new Window(frametype)<\/code><\/pre>\n\n\n\n<p>So how can you have something like a document window on macOS and a movable modal on Windows ?<\/p>\n\n\n\n<p>With a little inventiveness and some work.<\/p>\n\n\n\n<p>First &#8211; make a container control that will be the windows content. All your common ui elements go in here. This is the common UI.<\/p>\n\n\n\n<p>Then create a new window for macOS and set its frame type to whatever you need on macOS.<\/p>\n\n\n\n<p>And one for Windows and Linux if needed.<\/p>\n\n\n\n<p>One each embed, at design time, an instance of the container control you just created. Any non-common ui can be added directly to the windows themselves.<\/p>\n\n\n\n<p>Now at runtime when you need an instance of this window you can use conditional compilation to make sure you get the right kind of window.<\/p>\n\n\n\n<p><a href=\"http:\/\/great-white-software.com\/miscellaneous\/making%20a%20platform%20specific%20window%20frame.zip\">I&#8217;ve put together a small sample<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve seen this question come up a couple times recently. And while it would be nice to do you cant. The frame type is required to be set when the window is constructed. And there&#8217;s no constructor on a window that allows you to do something like So how can you have something like a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2019\/09\/29\/switch-the-window-type-at-runtime\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Switch the window type at runtime&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[6,3],"class_list":["post-342","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-tips","tag-xojo"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=342"}],"version-history":[{"count":1,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/342\/revisions"}],"predecessor-version":[{"id":343,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/342\/revisions\/343"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}