Sorry -not getting anywhere with setText()

June somewhere at so.com
Thu May 8 02:53:22 PDT 2008


Max Samukha Wrote:

> On Thu, 08 May 2008 04:35:18 -0400, June <somewhere at so.com> wrote:
> 
> >Max Samukha Wrote:
> >
> >> On Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam at nospam.com>
> >> wrote:
> >> 
> >> >On Thu, 08 May 2008 02:26:27 -0400, June <somewhere at so.com> wrote:
> >> >
> >> >>Attach what I am trying to make work -not winning here ,round and round in loops
> >> >>Any help appreciated
> >> >
> >> >You defined the setText(char[] name, char[] text) as nested function
> >> >in Box's constructor. Move it out to the class' scope.
> >> >
> >> >Btw, 'public:' is not needed as class members are public by default. 
> >> >
> >> > 
> >> 
> >> The following may have typos but should demonstrate the idea described
> >> in the previous thread:
> >> 
> >> class Box {
> >> 
> >>     private Control[char[]] controls; // Use associative array
> >> 
> >>     this (Composite parent ,int style ) {
> >> 
> >>     auto box = new Composite(parent,DWT.SINGLE);
> >>     box.setSize(700,40); 
> >> 
> >>     auto No = new Text(box,DWT.LEFT);
> >>     No.setBounds(1,15,10,15);
> >>     No.setText("");
> >>       
> >>     auto Date = new Text(box,DWT.LEFT);
> >>     Date.setBounds( 21, 15, 60, 15);
> >>     Date.setText("");
> >>       
> >>     auto Content   = new Text(box,DWT.LEFT); 
> >>     Content.setBounds( 90, 15,70, 15);
> >>     Content.setText("");
> >> 
> >>     box.setVisible = true;
> >> 
> >>     controls["No"]=No;
> >>     controls["Date"]=Date;
> >>     controls["Content"]=Content;
> >>     
> >>     box.setTabList(controls.values);
> >> 
> >>   }
> >> 
> >>   void setText(char[] name, char[] text)
> >>   {
> >>       controls[name].setText(text);
> >>    }
> >> }
> >> 
> >> void main () {
> >>   Display display = new Display ();
> >>   Shell shell = new Shell (display);
> >>   shell.setText("Boxes");
> >>   
> >>   Box mybox = new Box(shell,DWT.SINGLE);
> >>   mybox.setText("No","wire");
> >>   mybox.setText("Content","Fishingline");
> >>   shell.pack();
> >>   shell.open();	
> >>   while (!shell.isDisposed ()) {
> >>     if (!display.readAndDispatch ()) display.sleep ();
> >>   }
> >>   display.dispose ();
> >> }
> >Hi & Thanks .. I tried this and adjusted a couple of lines in Main that I had wrong . Still get a compile error related to controls?
> 
> The attached file is empty
This site seems slow ,I did not check Sorry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Box.d
Type: text/x-dsrc
Size: 1608 bytes
Desc: not available
Url : http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20080508/e8fb1da6/attachment.d 


More information about the Digitalmars-d-learn mailing list