AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Dummy-Konstanten

Ein Thema von nailor · begonnen am 11. Mai 2003 · letzter Beitrag vom 11. Mai 2003
Antwort Antwort
Benutzerbild von nailor
nailor

Registriert seit: 12. Dez 2002
Ort: Karlsruhe
1.989 Beiträge
 
#1

Dummy-Konstanten

  Alt 11. Mai 2003, 13:45
Ich will sowas machen:

Delphi-Quellcode:
procedure TuWas(Was: cardinal);
begin
case was of
1: ...
2: ...
3: ...
....
else
end;
end;
und jetzt will ich für 1,2,3... "Dummys" vergeben, also zb WAS_BEENDEN, WAS_DATEILADEN, WAS_NEUZEICHNEN... (so ähnlich wie bei den Windows WM_XXX - Messages). Wenn ich jetzt aber die Konstanten global deklariere, dann meckert delphi im case-Block immer noch, dass ihm das nicht konstant genug wäre....
Michael N.
http://nailor.devzero.de/code/sharpmath/testing/ --- Tests, Feedback, Anregungen, ... aller Art sehr willkommen!
::: don't try so hard - it'll happen for a reason :::
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#2
  Alt 11. Mai 2003, 13:55
Häh? Wie hast Du die denn deklariert. Ich habe damit keine Probleme.

......
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Benutzerbild von nailor
nailor

Registriert seit: 12. Dez 2002
Ort: Karlsruhe
1.989 Beiträge
 
#3
  Alt 11. Mai 2003, 13:59
Code:
program bla;

uses
  Windows,
  Messages;

const
  MC_case1: cardinal = 0;
  MC_case2: cardinal = 1;
  MC_case3: cardinal = 2;

function MessageLoop(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam):
  lresult; stdcall;
begin
  Result := 0;
  case uMsg of
    WM_DESTROY:
      PostQuitMessage(0);
    WM_CREATE:
      begin
        //nix bis jetzt
      end;
  else
    Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
  end;
end;

procedure mc(CodeNR: cardinal);
begin
case CodeNR of
  MC_case1: begin {irgendwas} end;
  MC_case2: begin {irgendwas} end;
  MC_case3: begin {irgendwas} end;
end;
end;

var
  WindowClass: TWndClassEx = (
    cbSize         : SizeOf(TWndClassEx);
    Style          : CS_HREDRAW or CS_VREDRAW;
    lpfnWndProc    : @MessageLoop;
    cbClsExtra     : 0;
    cbWndExtra     : 0;
    hbrBackground  : COLOR_APPWORKSPACE;
    lpszMenuName   : nil;
    lpszClassName  : 'myClass';
    hIconSm        : 0;    );
  msg: TMsg;
begin
WindowClass.hInstance := hInstance;
WindowClass.hCursor   := LoadCursor(0, IDC_ARROW);
WindowClass.hIcon     := LoadIcon(0, IDI_APPLICATION);

RegisterClassEx(WindowClass);

CreateWindowEX(0, 'myClass', 'capt', WS_CAPTION or WS_VISIBLE,
                100, 100, 200, 125, 0, 0, hInstance, nil);

while GetMessage(msg,0,0,0) do
  begin
    TranslateMessage(msg);
    DispatchMessage(msg);
  end;
ExitCode := msg.wParam;
end.
Michael N.
http://nailor.devzero.de/code/sharpmath/testing/ --- Tests, Feedback, Anregungen, ... aller Art sehr willkommen!
::: don't try so hard - it'll happen for a reason :::
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#4
  Alt 11. Mai 2003, 14:08
Das kommt noch aus der Zeit, als man über
Delphi-Quellcode:
const
  MC_case1: cardinal = 0;
  MC_case2: cardinal = 1;
  MC_case3: cardinal = 2;
Vordefinierte Variablen definiert hat. Obwohl da const steht, galt es früher als initialisierte Variable. Das ist Vergangenheit, dürfte sich aber als "heutiger Bug" manifestiert haben. Einfach die Defninitionen abändern in
Delphi-Quellcode:
const
  MC_case1 = 0;
  MC_case2 = 1;
  MC_case3 = 2;
, um das Cardinal künmmert sich Delphi, wenn nötig.

......
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Benutzerbild von nailor
nailor

Registriert seit: 12. Dez 2002
Ort: Karlsruhe
1.989 Beiträge
 
#5
  Alt 11. Mai 2003, 15:40
Tatsächlich. Klappt.
Michael N.
http://nailor.devzero.de/code/sharpmath/testing/ --- Tests, Feedback, Anregungen, ... aller Art sehr willkommen!
::: don't try so hard - it'll happen for a reason :::
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz