Image Capture [message #438311] |
Mon, 21 June 2004 15:23 |
Mark Wallace Messages: 3 Registered: July 2009 |
Junior Member |
|
|
I'm using the code below to do image capture of SWT widgets. One problem I'm
seeing is when I capture the image of an Edit control on Windows XP, what
happens is that the XP skinned border is not captured, anyone know why?
// removed exports
public class Main01 {
static final int WM_PRINT = 0x0317;
static final int PRF_CLIENT = 0x00000004;
static final int PRF_ERASEBKGND = 0x00000008;
static final int PRF_NONCLIENT = 0x00000002;
static final int PRF_OWNED = 0x00000020;
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
GridLayout layout = new GridLayout(1, true);
layout.verticalSpacing = 8;
shell.setLayout(layout);
Text text = new Text(shell, SWT.BORDER);
text.setText("Hello World");
text.setSize(300, 24);
Label label = new Label(shell, SWT.NONE);
label.setSize(300, 24);
shell.pack();
shell.open();
Image image = captureImage(text);
label.setImage(image);
shell.pack();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}
static public Image captureImage(Control control) {
Point size = control.getSize();
Image image = new Image(control.getDisplay(), size.x, size.y);
GC gc = new GC(image);
int hWnd = control.handle;
int wParam = gc.handle;
int lParam = PRF_NONCLIENT | PRF_CLIENT | PRF_ERASEBKGND;
OS.SendMessage(hWnd, WM_PRINT, wParam, lParam);
gc.dispose();
return image;
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.01466 seconds