Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Image Capture
Image Capture [message #438311] Mon, 21 June 2004 15:23
Mark Wallace is currently offline Mark WallaceFriend
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;

}

}
Previous Topic:Help System Error
Next Topic:Delete Key keyCode on Mac not SWT.DEL?
Goto Forum:
  


Current Time: Thu Apr 18 15:00:08 GMT 2024

Powered by FUDForum. Page generated in 0.01466 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top