{"id":408,"date":"2010-09-29T20:25:45","date_gmt":"2010-09-30T01:25:45","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=408"},"modified":"2011-10-07T11:37:02","modified_gmt":"2011-10-07T16:37:02","slug":"powerbuilder-resize-service-extension-max-height-width","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-resize-service-extension-max-height-width\/","title":{"rendered":"Powerbuilder \u2013 PFC Resize Service Extension \/ Max Height &#038; Width"},"content":{"rendered":"<p>The PFC window resize service is one of my favorite things in the entire class library as it can easily be implemented and adds a great bit of functionality to an application.  One drawback, however, is there is no built in capability to limit the resizing of the objects on a window; either they resize and\/or move or they don&#8217;t.  This simple extension adds the capability to set maximum width and height values to the controls being resized so you don&#8217;t end up with an ugly display of a large blank space after the end of the columns inside a datawindow control.<\/p>\n<p>To implement this extension you need to change the code in the n_cst_resizeattrib and n_cst_resize objects.  Whether you do this at the PFC layer or some corporate layer is up to you.<\/p>\n<p>In the n_cst_resizeattrib object add the following instance variables:<\/p>\n<pre name=\"code\" class=\"VB\">real\t\tr_maxwidth = 0\r\nreal\t\tr_maxheight = 0<\/pre>\n<p>In the n_cst_resize object do the following:<\/p>\n<p>Alter the of_register function to return the array position &#8216;li_slot_available&#8217;.<\/p>\n<p>Add the following functions:<\/p>\n<pre name=\"code\" class=\"VB\">public function integer of_setmaxcontrolwidth (integer ai_arraypos, real ar_width);\r\n\/\/ 11.5.1 set maximum control width\r\n\/\/ parms ai_arraypos - array position in the inv_registered control array\r\n\/\/ \t\t\tar_width - maximum witdth control can be resized to\r\n\/\/set r_maxwidth in n_cst_resizeattrib for specified array position\r\nIF Upperbound(inv_registered) >= ai_arraypos THEN\r\n\tinv_registered[ai_arraypos].r_maxwidth = ar_width\r\n\tRETURN Success\r\nELSE\r\n\tRETURN Failure\r\nEND IF\r\nend function\r\n\r\npublic function integer of_setmaxcontrolheight (integer ai_arraypos, real ar_height);\r\n\/\/ 11.5.1 set maximum control width\r\n\/\/ parms ai_arraypos - array position in the inv_registered control array\r\n\/\/ \t\t\tar_width - maximum height control can be resized to\r\n\/\/set r_maxheight in n_cst_resizeattrib for specified array position\r\nIF Upperbound(inv_registered) >= ai_arraypos THEN\r\n\tinv_registered[ai_arraypos].r_maxheight = ar_height\r\n\tRETURN Success\r\nELSE\r\n\tRETURN Failure\r\nEND IF\r\nend function<\/pre>\n<p>Then in the of_resize method modify as follows:<\/p>\n<pre name=\"code\" class=\"VB\">BEFORE:\r\n\/\/Save the 'exact' Width and Height attributes.\r\ninv_registered[li_cnt].r_width = inv_registered[li_cnt].r_width + lr_resize_deltawidth\t\r\ninv_registered[li_cnt].r_height = inv_registered[li_cnt].r_height + lr_resize_deltaheight\r\n\r\nAFTER:\r\n\/\/ look at maximum values\r\nIF (inv_registered[li_cnt].r_maxwidth > 0) AND (inv_registered[li_cnt].r_width + lr_resize_deltawidth > inv_registered[li_cnt].r_maxwidth) THEN\r\n\t\/\/ exceeds max width so set to max\r\n\tinv_registered[li_cnt].r_width = inv_registered[li_cnt].r_maxwidth\r\nELSEIF  (inv_registered[li_cnt].r_width =  inv_registered[li_cnt].r_maxwidth) AND  (inv_registered[li_cnt].r_maxwidth > 0) THEN\r\n\tIF inv_registered[li_cnt].b_scalewidth  AND (inv_registered[li_cnt].r_width > ai_newwidth) THEN\r\n\t\t\/\/ resize down from max width to fit on window (115 is width of vertical scroll bar)\r\n\t\tinv_registered[li_cnt].r_width = inv_registered[li_cnt].r_maxwidth +  (ai_newwidth - inv_registered[li_cnt].r_width ) - 115\r\n\tEND IF\r\nELSE\r\n\t\/\/Save the 'exact' Width and Height attributes.\r\n\tinv_registered[li_cnt].r_width = inv_registered[li_cnt].r_width + lr_resize_deltawidth\t\r\nEND IF\r\n\t\t\t\r\nIF (inv_registered[li_cnt].r_maxheight > 0) AND (inv_registered[li_cnt].r_height + lr_resize_deltaheight > inv_registered[li_cnt].r_maxheight) THEN\r\n\t\/\/ exceeds max so set to max\r\n\tinv_registered[li_cnt].r_height = inv_registered[li_cnt].r_maxheight\r\nELSEIF  (inv_registered[li_cnt].r_height =  inv_registered[li_cnt].r_maxheight) AND (inv_registered[li_cnt].r_maxheight > 0) THEN\r\n\t\t\/\/ resize down from max\r\n\tIF inv_registered[li_cnt].b_scaleheight  AND (inv_registered[li_cnt].r_height > ai_newheight) THEN\r\n\t\t\/\/ resize down from max height to fit on window (115 is width of horizontal scroll bar)\r\n\t\tinv_registered[li_cnt].r_height = inv_registered[li_cnt].r_maxheight +  (ai_newheight - inv_registered[li_cnt].r_height ) - 115\r\n\tEND IF\r\nELSE\r\n\tinv_registered[li_cnt].r_height = inv_registered[li_cnt].r_height + lr_resize_deltaheight\t\r\nEND IF<\/pre>\n<p>Now in the event you register the controls on the window do the following:<\/p>\n<pre name=\"code\" class=\"VB\">li_arraypos = this.inv_resize.of_Register(dw_1, this.inv_resize.SCALERIGHTBOTTOM)\r\nIF li_arraypos > 0 THEN\r\n\t\/\/ set max width and height for dw_1\r\n\tthis.inv_resize.of_setmaxcontrolwidth(li_arraypos, 6400)\r\n\tthis.inv_resize.of_setmaxcontrolheight(li_arraypos, 3000)\r\nEND IF<\/pre>\n<p><strong>NOTE: as of 10\/1\/2010 I am unable to get the height maximum piece to properly resize down from a maximum setting.  This seems to be a bug but I will work on it some more as time permits.  At this time I recommend not setting a maximum height for datawindows.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PFC window resize service is one of my favorite things in the entire class library as it can easily be implemented and adds a great bit of functionality to an application. One drawback, however, is there is no built in capability to limit the resizing of the objects on a window; either they resize&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[33,12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/408"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":9,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":957,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/408\/revisions\/957"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}