Screenshot from form - winforms

I want to get screenshot of screen under my form, so I hide it first and show after capturing. But on my Windows 7 form is not completely minimize, so I get form on screenshot. How can I be sure that my form is competely minimize?
WindowState = FormWindowState.Minimized;
Bitmap screenshot = ScreenUtils.ScreenShot();
background = screenshot;
WindowState = FormWindowState.Normal;
P.S. Hide() and Show() have the same problem.

you could set your forms opacity to 0, call refresh to make sure the painting is done, capture, reset opacity to 1 and call refresh again

Did you try to build in a sleep before making a screenshot?

Related

How to cover two overlapping components with a mask in Sencha ExtJS?

In Sencha, I'm able to mask a background component and bring up a dialog component nicely by calling this.view.mask() on the background component.
Then when I press "Submit" on the top dialog, I want to have a mask cover the dialog and background component all together instead of just masking the smaller dialog box. I don't want to just mask the dialog box, because even though the background is masked too, the dialog box's border is still obviously bright.
How can I mask both components all together?
On the dialog box I tried this.view.mask("Loading..."), but only the small dialog box is masked. Its border is still clearly bright so it's clear we're just putting a mask on the small dialog box rather than on the whole page.
I tried querying the background component via view=Ext.ComponentQuery.query('MyComponent')[0] and then using view.mask("Loading"), but this only adds the mask to that background component.
This is an ugly solution, but it worked for me. Tested on 7.0.0
var wnd = Ext.getCmp('window'), // just an example - Ext.getCmp() use is frowned upon :)
wndSize = wnd.getSize(),
myMask;
myMask = new Ext.LoadMask({
msg : 'Please wait...',
target : wnd,
height: wndSize.height,
width: wndSize.width
});
myMask.show().setXY(wnd.getXY());

programmatically animate window form in WPF

I have to increase height of windows form after I clicked one button.
I need to do this programmatically cause I try to do this with xml code and did it well ,but it work every time I click button, I need to animate just once with clicking just one button
you can use double animation to change the height property.In your button_click event write the code for double animation.
DoubleAnimation dblanim = new DoubleAnimation();
dblanim.To =200;
dblanim.Duration = TimeSpan.FromSeconds(3);
this.BeginAnimation(HeightProperty, dblanim);
use dblanim.To property to set the height of your window.

Unable to set button icon with ImageDownloadService (EncodedImage)

I have an issue with ImageDownloadService. Below is my code. If I use a label, I can display the image downloaded from a server. But if I use a button, nothing is displayed. I have set the placeholder as the initial icon of the button. Please what am i doing wrong?
EncodedImage eImg = EncodedImage.findButton(f).getIcon();
Image i = URLImage.createToStorage(eImg, "MyStoredImage.jpg", "http://ImgURL.png", URLImage.RESIZE_SCALE);
//now set the ad image to downloaded image
findButton(f).setIcon(i);
If I used findLabel(f).getIcon() instead and findLabel(f).setIcon(i), the code would work but for Button it does not. Why is this?
Thanks in advance.
See the discussion in the Codename One forum here https://groups.google.com/d/msg/codenameone-discussions/05dLV771OV8/x-pEYngCrsEJ

WebView is always the topmost component

I'm developing a reporting dashboard application using W8 Metro UI style application. The application has a dark theme, so most of the screen is black. I'm using the WebView control to display SSRS .rdl reports from our report server (which all have black backgrounds). The problem I'm seeing is that when I navigate to a new report, the WebView control flashes white for a split second and then loads the new report. To get around this, I tried putting an Easing opacity animation on the WebView control to make it fade out, load the report, and then fade back in. However, no matter what I try, I can't get the flickering to go away.
I then tried putting a black rectangle on top of the WebView and fading that one in and out... still no luck. The WebView is always on top at runtime, meaning I can't put any control on top of it. Does anyone know of a way around this?
I breifly looked into the WebView.Transitions, but couldn't find many resources on this. Could this be my answer?
EDIT:
Event to load the new report:
void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Create a WebViewBrush of the content currently loaded in the WebView
WebViewBrush b = new WebViewBrush();
b.SourceName = "WebView1";
b.Redraw();
Rectangle1.Fill = b;
// Hide the WebView
WebView1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
// Navigate to the new report
var selectedItem = ItemListView.SelectedItem;
WebView1.Navigate(((Report)selectedItem).ReportUri);
}
void WebView1_LoadCompleted(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
// Show the new report
WebView1.Visibility = Windows.UI.Xaml.Visibility.Visible;
Rectangle1.Fill = new SolidColorBrush(Colors.Transparent);
}
This is just the way WebView works because internally its loading the trident COM control into a separate hwnd. The workaround is to set Visibility to Hidden on the webview and instead show a webviewbrush which isn't interactive but does integrate with the rest of your UI so it can be animated, etc

How to use a modal window in titanium?

i have a serious problem here. i'm trying to use a modal window in my application. till now i used just a window over the parent window. but this caused a problem of not disabling the background.
here is my window:
the problem in the above pic is the background is not being disabled. if i use the modal window it occupies the whole view, which i dont want.
What i'm need of:
i need a view something like this alert view, which wen shown the background goes to disable mode.
any help is highly appreciated..
thank you...
Unfortunately You can not use the modal window as dialog box, but you can do a small trick and make your window look like a modal window.
Create a view and disable the click event on it. Add your dialog window to this view and show this view on screen.
var disableView = Titanium.UI.createView({
height:480,
width:320,
top:0,
backgroundColor:'#000',
opacity:0.7,
touchEnabled:true
});
disableView.add( yourWindow);

Resources