std::vector resize downward

Calling resize() with a smaller size has no effect on the capacity of a vector. It will not free memory. The standard idiom for freeing memory from a vector is to swap() it with an empty temporary vector: std::vector<T>().swap(vec);. If you want to resize downwards you’d need to copy from your original vector into a … Read more

Resize WPF Window and contents depening on screen resolution

The syntax Height=”{Binding SystemParameters.PrimaryScreenHeight}” provides the clue but doesn’t work as such. SystemParameters.PrimaryScreenHeight is static, hence you shall use: <Window x:Class=”MyApp.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:tools=”clr-namespace:MyApp.Tools” Height=”{x:Static SystemParameters.PrimaryScreenHeight}” Width=”{x:Static SystemParameters.PrimaryScreenWidth}” Title=”{Binding Path=DisplayName}” WindowStartupLocation=”CenterScreen” Icon=”icon.ico” > And it would fit the whole screen. Yet, you may prefer to fit a percentage of the screen size, e.g. 90%, in … Read more

jquery resize listener on a div

As the thread poelinca provided suggests, there are some nice plugins available for this functionality. If you don’t like the plugin idea, another simple solution would be to simply trigger a “resize” event on the div whenever the content is modified. Then you could monitor it with resize() as expected, utilizing an elegant observer pattern. … Read more

Resize textField Based On Content

You have to use an UITextView instead of an UITextField. Then, you can use the sizeThatFits method. But first you have to know how high one line will be. You can get that information by using lineHeight: var amountOfLinesToBeShown: CGFloat = 6 var maxHeight: CGFloat = yourTextview.font.lineHeight * amountOfLinesToBeShown After that, just call the sizeThatFits … Read more

jQuery Animation – Smooth Size Transition

Try this jQuery plugin: // Animates the dimensional changes resulting from altering element contents // Usage examples: // $(“#myElement”).showHtml(“new HTML contents”); // $(“div”).showHtml(“new HTML contents”, 400); // $(“.className”).showHtml(“new HTML contents”, 400, // function() {/* on completion */}); (function($) { $.fn.showHtml = function(html, speed, callback) { return this.each(function() { // The element to be modified var … Read more