Solved

Delaying a lot of time when shutdown the application, why?

Posted on 1998-09-30
14
170 Views
Last Modified: 2010-04-06
Hi all Gurus!!

I'm programming an application with Delphi 3.0. I have a lot of controls on it... one of them is a StringGrid control, which has initially only 1 row and 1 column. When I run the program and I don't add any lines to the grid, all is OK... when I close the application, it closes immediately, that is, delphi shows the properties window and I can continuing programming. The problem is when inside the application, I fill the grid with a lot of rows... more than 55000.... and only 1 column... then.. if I close the application... the window is closed... but the properties window is shown after several minutes, that is... a great delay before application really closes.. so I have to make a Program Reset using the menu option.

How can I fix it?
Thanks in advance,
Jaime
0
Comment
Question by:skel
14 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1341363
Why would you need so many cells???

//Vik
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1341364
I think this cannot be avoided because you have two many cells.

Why don't you free/destoy the StringGrid first before you end the application.

Another way may be writing a component from drawgrid without using stringlist to store your data in the memory. Shoud not be too difficult.

0
 

Author Comment

by:skel
ID: 1341365
Well.. I will explain what I need to do... I'm doing a debugger of an embedded system. In that string grid I'm storing machine instructions (Mnemonics) of a 64 K memory. As the instructions has operation codes of at least 3 bytes,  when I have read all the memory, it results that I have a little more than 55000 rows.
I have other 3 more string grids, one for displaying External Memory of the system, one for Internal Memory, and the last for displaying the Stack Memory. These others don't have many rows (4096, 16 and 32 rows, respectively).

Any suggestion of how can I do it?
Thanks a lot in advance
Jaime

0
 

Expert Comment

by:DPedrelli
ID: 1341366
In the OnCloseQuery you could hide the form so that the app would seem to close instantly.

David.
0
 

Expert Comment

by:huizhang
ID: 1341367
skel,

Please tell us what happens when you run this app outside delphi
IDE.
0
 
LVL 1

Expert Comment

by:Zonnald
ID: 1341368
Hi All,

I tried to reproduce this (in D4) so that I might debug the clean up code for TStringGrid.

Unfortunately the source for GRIDS in D4 seems to have some bug in it when trying to add values to the Cells.

Therefore I could not get to the end of my routine to check, what was going on - althought I suspect as KJTeng suggests that this code is as good as it is going to get.

Another point was that when I added a processmessages in the loop I wrote to populate 55000 cells I noted that this did speed up this loop?

Anyway I agree that this is unlikely to be improvable.

Zonnald
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1341369
what about the following:

you fix the height of the stringgrid-control so that there are let's say always 10 rows displayed.
you create a TStringLis to manage all your strings.
you create a function which controls a "window" over this TStringList, always displaying the actual row plus the next 9 rows (handling of begin/end of the list shouldn't be too hard) in your StringGrid.
when the user scrolls the window, the index into the TStringList must be set correspondingly and then the function to display the virtual window in the StringGrid must be invoked.
when closing the app, you free the TStringList.
i think, this should speed up the closing process.

try and tell me.

Black Death.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:skel
ID: 1341370
Yes, I understand the idea... now... how can I control the thumb position of the scroll bar? for example.. as I am displaying only 10 rows of the grid.. scrollbar will fit to this visible rows. If I am, for example, displaying the string number 28000, the thumb need to be almost in the middle of scroll bar, how can I do it?

Thanks
Jaime
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1341371
ya, that's a point...

you won't have a matching scrollbar, because the StringGrid is of height 10 and the StringList to be displayed has 10 entries. so you'll have to add two buttons by yourself. in addition to these you can place a vertical trackbar next to the stringgrid (between the buttons) and manage it manually. that's not so funny, i know...
can't think of any better method right now. when i've got a new idea, i'll let ya know, o.k.?

so far,

Black Death.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1341372
ugh. that was stupid.
of course you'll place a TScrollBar next to the Grid and switch off the ScrollBars of the Grid itself. sorry...
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1341373
so. skel.
meanwhile i've slammed together a little demo to show you what i've meant. it's not very nice, but it worx. post your email-address here and i'll mail it to you. if there are any questions, mail me:

andreas.naguschewski@vt.siemens.de

Black Death.
0
 

Author Comment

by:skel
ID: 1341374
Thanks a lot Black Death... I have placed a TScrollBar next to the TStringGrid (without displaying its own scrollbar of course).... that's works very well... thanks a lot for your help :)

Jaime
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1341375
no sweat ;-)=)

like i've said before; if you want the demo, mail me.

cheerio,

Black Death.


0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 1341376
Skel,

There is a much better, more elegant way.

Hold the information you would add to the stringgrid in, say, a TList (or however you cirrently do it). Set the stringgrid to have 55,000 rows. Write a handler for the OnDrawCell event in the list (which is called for each cell) and draw the text into the cell (see example below...).

procedure TMyForm.StringGrid1DrawCell(Sender: TObject; Col, Row: Longint;
                                                            Rect: TRect; State: TGridDrawState);
begin
    Stringgrid.Canvas.Textout(rect.left + 2, rect.top + 2, GetTheString(Row));
end

This means you don't need to mess around with a separate scroll bar and everything exits nice and quickly.

Cheers,

Raymond.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now