Solved

Why my program causes the computer hang up when the display color is 16 colors?

Posted on 2001-07-17
6
141 Views
Last Modified: 2010-04-06
Hi all,
Why my program causes the computer hang up when the display color is 16 colors?

When I run the Delphi 3.0 cs (have all the patches), then load my project, the computer also will hang up.

Not have problem in 256 colors, 16 bit colors and more colors.

Thanks, supwang
0
Comment
Question by:SupWang
[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
  • 4
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 6291339
Hi SupWang...   :-)

Please make sure that you have the latest official driver version of your graphics card installed (no beta drivers). This could be a graphics driver problem. Or does the problem also occur on other people's PCs in 16 colors? In that case it has to be the guilt of your program. Then it will be more difficult to solve the problem...

Regards, Madshi.
0
 
LVL 2

Author Comment

by:SupWang
ID: 6292059
Hi Madshi,
How are you? How about you and your girl friend?

Yes, other people's PCs also have the same problem.
when use the stand vga driver(16 colors), also have the same problem. Why the Delphi open this project will cause the computer hang up??

Regards, supwang
0
 
LVL 2

Author Comment

by:SupWang
ID: 6292280
Hi Madshi,
I find that is the delphi bug. the dbgrid will cause this problem. In 16 colors, I create a new project, then drop down a dbgrid to the form, the computer hang up immediately.  :-(

and I try to do the same test in Delphi4, but In 16 colors the D4 can't run and hang up the computer, like my program.

Regards, supwang
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!

 
LVL 2

Author Comment

by:SupWang
ID: 6292379
Hi Madshi,
I want to add the following codes to the DPR file. Could you please check it? and I will give the points to you.


var
  tHDC: hdc;
  NumberColors: Integer;

begin
  tHDC := GetDC(0);
  try
    NumberColors := GetDeviceCaps(tHDC, 12) * GetDeviceCaps(tHDC, 14);
  finally
    ReleaseDC(0, tHDC);
  end;
  if NumberColors < 8 then
  begin
    showmessage('This program must run at 256 or more colors.')
  end
  else
  begin
    //do something...
    //do something...
  end;
end;
0
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 6293047
Hi SupWang!

>> How are you? How about you and your girl friend?

Oh well, still the same as every year. Am still working on the "girl friend" project...  :-)

>> I find that is the delphi bug. the dbgrid will cause this problem.

:-(  That's quite sad, really.

>> I want to add the following codes to the DPR file. Could you please check it?

Yep, that's a solution. I'm using such a color depth check in some of my projects, too. My code looks quite the same as your code, but I like named constants more than those "12" and "14", because there nobody knows what they mean:

function GetColorDepth : integer;
var dc : dword;
begin
  dc := CreateCompatibleDC(0);
  try
    result := GetDeviceCaps(dc, BitsPixel) * GetDeviceCaps(dc, Planes);
  finally DeleteDC(dc) end;
end;

Regards, Madshi.
0
 
LVL 2

Author Comment

by:SupWang
ID: 6294021
Hi Madshi,
Your project always very well.  :-)

Thanks, supwang
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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