Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  gdi.rs

  Sprache: Rust
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


//! GDI helpers.

use windows_sys::Win32::{
    Foundation::HWND,
    Graphics::Gdi::{self, GDI_ERROR, HDC, HGDIOBJ},
};

/// A GDI drawing context.
pub struct DC {
    hwnd: HWND,
    hdc: HDC,
}

impl DC {
    /// Create a new DC.
    pub fn new(hwnd: HWND) -> Option<Self> {
        let hdc = unsafe { Gdi::GetDC(hwnd) };
        (!hdc.is_null()).then_some(DC { hwnd, hdc })
    }

    /// Call the given function with a gdi object selected.
    pub fn with_object_selected<R>(&self, object: HGDIOBJ, f: impl FnOnce(HDC) -> R) -> Option<R> {
        let old_object = unsafe { Gdi::SelectObject(self.hdc, object) };
        if old_object.is_null() || old_object == GDI_ERROR as HGDIOBJ {
            return None;
        }
        let ret = f(self.hdc);
        // The prior object must be selected before releasing the DC. Ignore errors; this is
        // best-effort.
        unsafe { Gdi::SelectObject(self.hdc, old_object) };
        Some(ret)
    }
}

impl Drop for DC {
    fn drop(&mut self) {
        unsafe { Gdi::ReleaseDC(self.hwnd, self.hdc) };
    }
}

Messung V0.5 in Prozent
C=85 H=75 G=80

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-08-26) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002