comparison snippets/program/Snippet32.d @ 78:4a04b6759f98

Clean up directory names
author John Reimer <terminal.node@gmail.com>
date Sat, 10 May 2008 13:32:45 -0700
parents
children 1f0a7a472680
comparison
equal deleted inserted replaced
76:04f122e90b0a 78:4a04b6759f98
1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module snippets.program.Snippet32;
14
15 /*
16 * Program example snippet: find the icon of the program that edits .bmp files
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import dwt.DWT;
22 import dwt.graphics.ImageData;
23 import dwt.graphics.Image;
24 import dwt.widgets.Shell;
25 import dwt.widgets.Display;
26 import dwt.widgets.Label;
27 import dwt.program.Program;
28
29 void main () {
30 Display display = new Display ();
31 Shell shell = new Shell (display);
32 Label label = new Label (shell, DWT.NONE);
33 label.setText ("Can't find icon for .bmp");
34 Image image = null;
35 Program p = Program.findProgram (".bmp");
36 if (p !is null) {
37 ImageData data = p.getImageData ();
38 if (data !is null) {
39 image = new Image (display, data);
40 label.setImage (image);
41 }
42 }
43 label.pack ();
44 shell.pack ();
45 shell.open ();
46 while (!shell.isDisposed()) {
47 if (!display.readAndDispatch ()) display.sleep ();
48 }
49 if (image !is null) image.dispose ();
50 display.dispose ();
51 }
52