Mercurial > projects > dwt-samples
annotate snippets/program/Snippet32.d @ 120:1f0a7a472680
fix rm snippets from module statements.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 19:17:23 +0200 |
parents | 4a04b6759f98 |
children |
rev | line source |
---|---|
78 | 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 *******************************************************************************/ | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
13 module program.Snippet32; |
78 | 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 |