Farb Problem



  • Hallo irgendwie wird bei mir der Wert von der Variable farbe nicht ausgegeben.

    Da steht immer die Zahl: 4294967295

    Auf der Konsole da funktioniert alles aber bei der VCL nicht so ganz 😞

    void __fastcall TForm1::Timer1Timer(TObject *Sender)
    {
    
    COLORREF farbe;
    HDC desktop;
    POINT maus_pos;
    
    int maus_sp_x;
    int maus_sp_y;
    
         GetCursorPos(&maus_pos);
    
           label_x_wert -> Caption = maus_pos.x;
           label_y_wert -> Caption = maus_pos.y;
    
           maus_sp_x =   maus_pos.x;
           maus_sp_y =   maus_pos.y;
    
    farbe = GetPixel(desktop, maus_sp_x, maus_sp_y );
    
    Label1->Caption = farbe;
    
    }
    


  • Hallo,

    wo wird denn HDC desktop initialisiert? Ich sehe nur eine Deklaration...

    MfG



  • Hallo

    Ich kann an den Code kein Problem feststellen.
    Welche Ausgabe erzeugt den Wert, den du als fehlerhaft ansiehst? Wenn es die dritte Ausgabe der Farbe ist, dann hat das Programm aber Recht. Denn ein TColor-Wert ist eine int-Zahl, die einfach lexigrafisch in einen String umgewandelt wird. Was erwartest denn du für eine Ausgabe?

    /Edit : Und Kolumbus hat natürlich mit seiner Anmerkung auch recht.

    bis bald
    akari



  • Ah jetzt funktioniert es^^

    Die Deklaration hatte ich vergessen da war der Fehler.

    Ich hatte das Programm erst auf der Konsole gemacht und jetzt mach ich es auf der VCL da hab ich wohl was vergessen mit zu kopieren.

    ty @ all



  • BDS2006-Hilfe schrieb:

    The COLORREF value is used to specify an RGB color.

    typedef DWORD COLORREF;
    typedef DWORD *LPCOLORREF;
    Remarks
    When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
    0x00bbggrr

    The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.

    To create a COLORREF color value, use the RGB macro. To extract the individual values for the red, green, and blue components of a color value, use the GetRValue, GetGValue, and GetBValue macros, respectively.

    Den Wert kannst du natürlich nicht einfach in ein Label-Caption schreiben, wie akari schon schrieb. Nur mit dem Integer-Wert bin ich jetzt nicht so sicher... Ist 32bit-hexadezimal in 3 Gruppen aufgeteilt!? Wenn man das auf einem Label ausgeben will, wird das wohl als int interpretiert, weil 32bit-Wert.
    Wie soll denn die Ausgabe aussehen, um mich mal akari anzuschliessen?!

    Edit: Ok, dann sind wir wohl durch hier... 🙂


Anmelden zum Antworten