?
Solved

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

Posted on 1998-09-30
14
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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 300 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

762 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