preventing paint of DbctrlGrid panel or deleting after fill

Posted on 2009-07-16
Last Modified: 2013-11-23
I am developing an application which queries a db for a file/exe path, among other things.  If the application exists, the grid should be populated.  If the application does not, I need to skip the resultset row or delete/hide the filled panel.  (ex. if quickbooks exist on a client machine, paint else move to the next rs row or delete the painted panel.

For the life of me, I can't work this out.  

I'm hoping someone here may have some suggestions.

*btw, I tried an alternative in iterating through the result set for the apppath; if the exe exists, proceed; else delete/filter the resultset row -no luck here either.....

Thanks in advance,

R Davis
Question by:brparrish
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
  • 3
  • 3
  • 2

Expert Comment

ID: 24877198
You could this :

1) Add a flag field into the table that stores the exe's path. Let's say APP_EXISTS type integer
    App Exists value = 1, App does not exist value = 0.
2) Write a procedure that updates the flag according to the existance of the file

3)Select from the database only the records that the application exists using the flag in the query
Select * from TABLENAME where APP_EXISTS = 1
and you will get only the records you want to display without trying to override the paint procedure of the grid.

Author Comment

ID: 24877397
Yep, I thought about that, trouble is 100 people will use this daily, so modifying the DB isn't really an option.  I thought about an ADOtable on the form also, drop the dataset there, then read the results to appropriate fields.....that doesn't really seem viable either, but may be my only option.  -Thanks for your input

Expert Comment

ID: 24878577
Well in my opinion you can implement this making a thread that will run to update the DB.
If you have to mofidy this table daily you could make a separate exe to run as a service
and make a scheduler to run on a spesific interval.

AdoTable is good but pretty slow try to do it using SQL and AdoTables this will speed up 100% the proccess specially if the DB Engine is MS SQL,MySQL generally a good DB engine.

If you could explain more the logic you want to implement maybe more ideas will appear.

Independent Software Vendors: 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!


Author Comment

ID: 24878718
Well, in a nutshell....we write a lot of software which is pushed out to our users.  Historically, we publish the shortcuts for these apps via GPO.  I'm trying to overcome that.  A db will host the name, appGroup, description and path of the exe.  Additionally, this app will also include apps like, IE, Outlook, Word, Excel etc....(in effort to clean the desktop).

So changing the DB isn't really a good option for me as up to 100 users will hit this app between 8:30 -9:00a.

What happens now (and this all works, w/exception of hiding local apps that aren't installed ex; Quickbooks).

query: select * from desktop_ui >> open dataset >> while not eof, fill panel fields w/the app name, description and group membership >> In an onpaintpanel event, take the exe path from the dataset; extract the icon or associated icon (if the object is a file, .pdf etc) and fill image1 w/it.

This all works great w/exception of the panels I'd like omitted/not-painted or skipped.

For example:  I've set an erroneous path for IE7  -however, db fields are populated -only image1 is skipped (because the icon can't be found)

I've tried checks such as fileexists()   -no dice.

For kicks, I've set silly behavior like changing the back color if the app is not found  -this works, so I know the if statement is good.  I just can't seem to find a way to remove or omit cells that don't apply to the respective user.

It is that dead end that got me focusing on a table to filter the rows prior to filling.

Hope this helps,

R Davis
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24884945
you have a form which is prepolutated with panels for all your apps ?

why not just change the visibilty of the panel ?

this is a little obscure as to what your form looks like
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24890751
the first time you load this thing, i agree it would take some time to find all the apps installed
why not save a TClientDataSet to a local file once processed
and then load from this local file the next time

you would use a thread to load all the possible apps from the db
and process which ones are available in this thread
within this thread you can then recreate the local file

opening the app the first time would be slow possibly
the second time, instant, and in the background it would be running the thread to check for new versions

Accepted Solution

brparrish earned 0 total points
ID: 24897459
I actually received some help w/this via the delphi forums.....silly how simple is was:

procedure TForm1.rsFilterRecord(DataSet: TDataSet; var Accept: Boolean);
  Accept := FileExists(rs.FieldByName('AppExePath').AsString);

in the form create:

rs.Filtered := True;  -crazy!

Thanks to all for your input.

R Davis
LVL 38

Expert Comment

by:Geert Gruwez
ID: 24897489
it will still take a while to load your dataset
and will take a time to show your form as you do this in the formcreate
you may have to add a waiting cursor or even a form displaying it's busy

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

635 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