1. "Memo1" component that hides value such as 100,200,300 or 450 ounce etc.
2. "Memo2" component that hides value such as 50,100,150 or 225 ounce so the component will store the decreasing values from 100,200,300 or 450 pounds. Thus the bar image's height will be 50% of the barimage old height.
3. "barimage1" Image Component. its width is 10,its height is 47;
and then we will load a picture that is just a simple color bar inside that image component.
I m giving my picture file formatted .bmp extension that we will upload inside image component.
Until here, everything is simple and ok. Now I will write the code block inside parent press event of Memo1 and Memo2 that is called as "by clicking both of them inside the form pushing "shift" key.
note: Also I will sent you the bar color image that we will upload to image component

var
Anaform: TAnaform;
Key:Char;
cnt0:integer;
oldmemo29,oldmemo28:string;
implementation
uses Unit2;

{$R *.dfm}
...
procedure TAnaform.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
firstbarheight1,topresult, topset1,heightresult:integer;
barheight1:real;
begin
if Key in [VK_RETURN] then
begin
if Memo1.Lines[0]<>'0' then
begin
oldmemo1:=Memo1.Lines[0];
oldmemo2:=Memo2.Lines[0];
firstbarheight1:= barimage1.Height;
barimage1.Height := barimage1.height*strtoint(memo2.Lines[0]);
barheight1 := barimage1.Height/strtoint(memo1.Lines[0]);
heightresult := ceil(barheight1);
topresult := firstbarheight1 - heightresult;
topset1 := barimage1.Top+topresult;
barimage1.SetBounds(36,topset1,10,heightresult);
end
else
ShowMessage('Please edit a value different than zero');
{ if (Memo1.Lines[0]<> Oldmemo1) or (Memo2.Lines[0] <> Oldmemo2) then
begin
barimage1.SetBounds(36,34,10,47);
firstbarheight1 := barimage1.Height;
barimage1.Height := barimage1.height*strtoint(memo1.Lines[0]);
barheight1 := barimage1.Height/strtoint(memo1.Lines[0]);
heightresult := ceil(barheight1);
topresult := firstbarheight1 - heightresult;
topset1 := barimage1.Top+topresult;
barimage1.SetBounds(36,topset1,10,heightresult);
end;
end;}
end;

After changing memos whose starting value is "0" , there exists problem. now I want to tell this problem clearly. For the entered values such as memo1.Lines[0] := 200, memo2.Lines[0]:=100. When I press "enter" or "return" key, Bar image height is changing successfully. namely Barimage's height is decreasing half (100/200 := 1/2 ). namely barimage's height is being 23.5 changing old value of bar image height (47). but when I change the values of memo1 and memo2 components second times or more. the bar image height is not protecting old value that is 47. For example: After the Barimage height was 23.5. and When I entered new values such as 70 and 35 for memo1 and memo2 consequently. (35/70 := 1/2). The bar image height is being 23.5/2 = 11.75 (rounding 12) uncorrecly. But I want the barimage height should be first height value again and should start to calculate the decrement again using the old "47" value of barimage height . Namely in my last example. Bar image shouldn't be 11.75. bar image height should be again 47. So I tried to add some extra code in my procedure that triggers keypress events of memo components like the codes between my comment brackets ({}) to solve this problem. but this condition block doesn't imply its task. how will I solve this logic mistake problem? Can you give me any solution like writing extra code commands to my code block

Recommended Answers

All 2 Replies

yes but I didnt like "oops sorry" message and I want to change some format of that question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.