Saturday, 15 September 2012

delphi - Getting shape to show up on a form during runtime -



delphi - Getting shape to show up on a form during runtime -

i have button , when clicked, tmachine (aka tshape) show on form. currenty no errors, never shows on form.

code button click

procedure tfdeptlayout.baddmachineclick(sender: tobject); var machine: tmachine; shapeasset, shapeshape, shapenumber, shapename: string; begin if not oktoadd() begin showmessage('please fill out form correctly!'); exit; end; shapeasset := edit2.text; shapeshape := combobox1.text; shapenumber := edit3.text; shapename := edit1.text; if sub = false begin machine := tmachine.create(self); machine.parent := self; machine.placeshape(0, fdb.getww(shapeshape), fdb.gethw(shapeshape), '20', '20', shapename, shapenumber, shapeasset) //show save button //lockout add together machine button //let user place machine top / left. //save locations //save top , left each tmachine database //lockout save button //show add together machine button end; if sub showmessage('auto save form'); showmessage('congrats added machine'); end;

if needed can show tmachine unit?..

type tmachine = class(tshape) private fonmouseenter: tnotifyevent; procedure cmmouseenter(var message: tmessage); message cm_mouseenter; protected procedure domouseenter; virtual; published property onmouseenter: tnotifyevent read fonmouseenter write fonmouseenter; public mnname: string; mnasset: string; mnnumber: string; mnispanel: string; mnbasicname: string; mnlshape: string; procedure placeshape(am, sizew, sizeh: integer; ptop, pleft, name, order, asset: string); end; implementation uses deptlayout; procedure tmachine.cmmouseenter(var message: tmessage); begin domouseenter; inherited; end; procedure tmachine.domouseenter; begin if assigned(fonmouseenter) fonmouseenter(self); end; procedure tmachine.placeshape(am, sizew, sizeh: integer; ptop, pleft, name, order, asset: string); var mylabel: tlabel; begin if ptop = '0' top := 136 else top := strtoint(ptop); width := sizew; height := sizeh; if pleft = '0' left := mydatamodule.fdb.lastx + 2 //set left else left := strtoint(pleft); mydatamodule.fdb.lastx := left + sizew; if = 1 //if in edit mode.. begin //create label set within shape. mylabel := tlabel.create(fdeptlayout); mylabel.parent := fdeptlayout; mylabel.left := left; mylabel.top := top + 8; mylabel.caption := '#' + mnnumber; end; end; end.

of course of study doesn't work!

the code adds machine within if not oktoadd() then, run if not oktoadd. but! if case, exit before run code! hence, code never run!

probably mean this:

if not oktoadd begin showmessage('please fill out form correctly!'); exit; end; //end!!!!!!

delphi delphi-xe2

No comments:

Post a Comment