Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > VCL

Lost Password?

Thread Tools Display Modes
Old 02-04-2012, 03:20 PM
mmx64 mmx64 is offline
Join Date: Aug 2009
Posts: 58
Default GUI programming

I have started a more complex program, and i would like some guidance.

I have a array of word, and i need to display its contents in a chart.

I had been dooing some testing and here is what i came up to:

on myform i create a scrollbar named sb
on myform i create a Timage named img
on img i create and load a bitmap named bm

and i browse the array up and down with the following code:
procedure TForm1.sbChange(Sender: TObject);
var increment,i,myData,addrIncrement:integer;
clearbm; //i clear bitmap to base color.


for i  := sb.Position to  sb.Position+700 do
    if oData[i] >= 32769 then
    myData:=oData[i] div 2

    myData:=327-(myData div 100);


The output looks like file in attach.

All this works but i have some problem:

1. After i minimize the form them i restore it back the bitmap is cleared.
2. somehow i need to able to make a selection on that chart from point A to point B, and to have a vertical cursor so i can move it around the chart.
3. I need to draw vertical and horizontal grids on that chart.

This is my first interactive GUI programing , so i need for someone to tell me the method in how this GUI's are programmed. Thanks!!!
Attached Images
File Type: jpg ss.jpg (16.5 KB, 16 views)
Reply With Quote
Old 02-04-2012, 09:05 PM
pengo pengo is offline
Junior Member
Join Date: Jan 2012
Location: New Zealand
Posts: 5
Default A couple of thoughts

Well done with this. I've usually stuck with charting components to do the hard yards; they're a lot easier, and there are some good free ones available. I'm impressed that you're doing this yourself.

I think you'll need to redraw the image every time it's invalidated. Minimising and restoring will require that, and also (completed or partial) hiding and showing. You could create your bitmap and save it to a temporary file, then load it into a TImage for display; that way you don't need to redraw it. Or you could just call your existing code from the OnPaint event. At least this is what I expect is going on here: try it and see.

Draw your grid lines (MoveTo, LineTo) before drawing your data. The data lines will be drawn over the grid lines.

The selection is more complex, and I'm not sure what kind of selection you want ... but you can set the cursor for the displaying TImage to the one you want (although I'm not sure what a vertical cursor is).
Zip and deliver project code with one click.
Reply With Quote
Old 02-04-2012, 09:51 PM
mmx64 mmx64 is offline
Join Date: Aug 2009
Posts: 58

Thanks for reply, well technically what i want to do is not a chart, its more like a file editor, but more advanced.
Let me be more explicit about what i want here:
i have an array of word.
I display it as shown above.
Maybe to you the lines on the screen doesn't tell you much, but for me (as i was trained to work with similar file editing software) tells me a lot.
When i see the part im interested in, i want to select it, so the selection should give me the begin-end address of the data from array.
The so called "vertical cursor", i want a line from top to bottom to act as a cursor, to be able to move it around the screen, where its position will be the position from array.

And about the grid lines you give me in idea:
Instead of clearing bp , i will clear it and draw the grid at the same time, then will draw my data on it. Hows that sounds?
Reply With Quote
Old 02-05-2012, 04:02 PM
BaraoZemo BaraoZemo is offline
Senior Member
Join Date: Nov 2001
Posts: 3,598

take a look in the component called "heartmachine", it will fit all your needs
and comes with full sources... so you can "learn" how to do some advanced features that will be very usefull to you.

you can modify it , learn the code, implement your code or modify and publish the original component with the modifications
Reply With Quote
Old 02-16-2012, 08:42 PM
mmx64 mmx64 is offline
Join Date: Aug 2009
Posts: 58

Hi, thanks that helps a lot.

I have created a component, where i draw my background, my grid lines..... Everything is ok.(i have a bitmap, where i draw my things and on paint event i draw it to canvas)
I am displaying data from an array of byte.
for i := offset to offset+width do

I still need:
1. to create a line from top to bottom of my bitmap, and to be able to drag (left - right) by mouse, where the location on the bitmap is the address from my array.
2. If i click on my "line" and drag it , i need to make a selection with it.

If anyone has any idea how should i implement it, please share. Thanks!!!
Attached Images
File Type: jpg ss1.jpg (20.1 KB, 8 views)

Last edited by mmx64; 02-16-2012 at 08:46 PM.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:56 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.