dwt learning question,please help

Sam Hu samhu.samhu at gmail.com
Sun Aug 31 19:33:17 PDT 2008


This time I use another gif image file located in dwt-samples\res and then I can pass the compile also.When I run the program,it crashed also with the same message.Below is the resoure and the attached please found the compile information and the exception message when I run the program.
//**********************************************
module resizeapp;

import dwt.DWT;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import dwt.widgets.Label;
import dwt.graphics.Image;
import dwt.graphics.ImageData;
import dwt.graphics.Rectangle;
import dwt.layout.GridLayout;
import dwt.layout.GridData;
import dwt.events.ControlAdapter;
import dwt.events.ControlEvent;

import dwt.widgets.MessageBox;
import tango.core.Exception;

class MainForm
{
	private:
	Display display;
	Shell shell;
	Label label;
	Image image;

	void InitializeComponents()
	{
		display=new Display;
		shell =new Shell(display);
		image=new Image(display,r"c:\bigd\dwt-samples\res\region_shell.gif");

		shell.setLayout(new GridLayout);
		label=new Label(shell,DWT.NONE);
		label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
		label.setImage(image);
		shell.setData(label);

		shell.addControlListener(new class ControlAdapter{
			public void controlResized(ControlEvent e)
			{
				Shell shell=cast(Shell)e.getSource;

				Label label=cast(Label)shell.getData;
				Rectangle rect=shell.getClientArea;
				ImageData data=label.getImage.getImageData;

				if(rect.width<data.width || rect.height<data.height)
				{
					shell.setText("Too small");
					label.setText("I'm melting");
					
				}
				else
				{
					shell.setText("Happy Guy Fits");
					label.setImage(label.getImage);
				}
				
			}
		});
		shell.pack;
		shell.open;

		while(! shell.isDisposed)
		{
			if(! display.readAndDispatch)
			display.sleep;
		}
		if(!(image is null))
		image.dispose;
		display.dispose;
			
	}
	public:
	this()
	{
		InitializeComponents;
	}
}
int main(char[][] args)
{
	try
	{
		MainForm mainForm=new MainForm;
	}
	catch(Exception e)
	{
		MessageBox.showError(e.toString,"Fatal Error");
		return -1;
	}

	return 0;
}
//**********************************************

Thanks,
Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: console1.gif
Type: image/gif
Size: 11000 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-dwt/attachments/20080831/6baa3b62/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: console2.gif
Type: image/gif
Size: 18963 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-dwt/attachments/20080831/6baa3b62/attachment-0003.gif>


More information about the Digitalmars-d-dwt mailing list