Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Case Is of (https://www.delphipraxis.net/160844-case.html)

EWeiss 3. Jun 2011 18:17

Case Is of
 
Delphi-Quellcode:
    case DisplayMin of
    9:
wie war es noch..

möchte prüfen ob DisplayMin größer als 9 ist.

gruss

Flips 3. Jun 2011 18:20

AW: Case Is of
 
Delphi-Quellcode:
if DisplayMin > 9 then ...
? oO
Sry aber ich glaub ich versteh die Frage nicht^^

BUG 3. Jun 2011 18:25

AW: Case Is of
 
Wenn du alle anderen < 9 auch abfängst, dann kannst du einfach else benutzen.

Delphi-Quellcode:
case x of
  case 1: ;
  case 2: ;
  case 3,4,5: ;
  case 6: ;
  case 7: ;
  case 8: ;
  case 9: ;
  else ;
end;

EWeiss 3. Jun 2011 18:31

AW: Case Is of
 
Zitat:

Zitat von Flips (Beitrag 1104494)
Delphi-Quellcode:
if DisplayMin > 9 then ...
? oO
Sry aber ich glaub ich versteh die Frage nicht^^

Ich möchte abhängig von den übergebenen Minuten zwei Nummern aus einem Bitmap blitten.

Delphi-Quellcode:
procedure TSkinMediaTimer.UpdateDis(WinHandle: HWND; DC: HDC; ViewTime: Integer);
var
  DisplayMin: Integer;
  DisplaySec: Integer;
  DisplayMs:  Integer;
  NumImg,
  NumImgW,
  NumImgH:    cardinal;
  Graphics:   Cardinal;
begin

  DisplayMs := ViewTime mod 1000 div 10;
  DisplaySec := ViewTime div 1000;
  DisplayMin := DisplaySec div 60;
  DisplaySec := DisplaySec mod 60;
  DisplayMin := DisplayMin mod 60;

  NumImg := SkinEngine.GetProperty(WinHandle, NUMBER_IMAGE);

  if GdipCreateFromHDC(DC, Graphics) = 0 then
  begin
    SkinEngine.GetImageSize(NumImg, NumImgW, NumImgH);

    case DisplayMin of
    9:
      begin
        NumberLed(Graphics, NumImgH, 1, StrToInt(Copy(IntToStr(DisplayMin), 1, 1)));
        NumberLed(Graphics, NumImgH, 2, StrToInt(Copy(IntToStr(DisplayMin), 2, 1)));
      end;
    0:
      begin
        NumberLed(Graphics, NumImgH, 1, 0);
        NumberLed(Graphics, NumImgH, 2, 0);
      end
    else
      begin
        NumberLed(Graphics, NumImgH, 1, 0);
        NumberLed(Graphics, NumImgH, 2, StrToInt(Copy(IntToStr(DisplayMin), 1, 1)));
      end;
    end;

    case DisplaySec of
    9:
      begin
        NumberLed(Graphics, NumImgH, 3, StrToInt(Copy(IntToStr(DisplaySec), 1, 1)));
        NumberLed(Graphics, NumImgH, 4, StrToInt(Copy(IntToStr(DisplaySec), 2, 1)));
      end;
    0:
      begin
        NumberLed(Graphics, NumImgH, 3, 0);
        NumberLed(Graphics, NumImgH, 4, 0);
      end;
    else
      begin
        NumberLed(Graphics, NumImgH, 3, 0);
        NumberLed(Graphics, NumImgH, 4, StrToInt(Copy(IntToStr(DisplaySec), 1, 1)));
      end;
    end;

    case DisplayMs of
    9:
      begin
        NumberLed(Graphics, NumImgH, 5, StrToInt(Copy(IntToStr(DisplayMs), 1, 1)));
        NumberLed(Graphics, NumImgH, 6, StrToInt(Copy(IntToStr(DisplayMs), 2, 1)));
      end;
    0:
      begin
        NumberLed(Graphics, NumImgH, 5, 0);
        NumberLed(Graphics, NumImgH, 6, 0);
      end
    else
      begin
        NumberLed(Graphics, NumImgH, 5, 0);
        NumberLed(Graphics, NumImgH, 6, StrToInt(Copy(IntToStr(DisplayMs), 1, 1)));
      end;
    end;
    GdipDeleteGraphics(Graphics);

  end;

end;
Meine Idee war es das in einer Case Anweisung zu verwirklichen.
Scheint aber nicht so zu funktionieren wie gedacht OHNE If abfrage.

bei 9: sollte eigentlich "> 9" stehen .. hmm scheint wohl nicht zu funktionieren.

gruss

schlecki 3. Jun 2011 18:36

AW: Case Is of
 
probier mal
Delphi-Quellcode:
 9..MaxInt: ...

EWeiss 3. Jun 2011 18:43

AW: Case Is of
 
Zitat:

Zitat von schlecki (Beitrag 1104497)
probier mal
Delphi-Quellcode:
 9..MaxInt: ...

Arghh ja das war's.

Danke. Sorry muss mich erst wieder nach meiner Krankheit erholen. (Fangen)

gruss


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:58 Uhr.

Powered by vBulletin® Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2021 by Daniel R. Wolf