Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2001-07-17
6
Medium Priority
?
147 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Industry Leaders: 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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 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