Solved

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

Posted on 2001-07-17
6
135 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

15 Experts available now in Live!

Get 1:1 Help Now