![]() |
wiedermal VCC - > Delphi
hab einige Probleme folgenden cpp Code nach Delphi zu konvertieren
Code:
void CScanPassDlg::OnPaint()
{ if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } meine Versuche mit
Delphi-Quellcode:
scheitern an
procedure TForm1.FormPaint(Sender: TObject);
var cxIcon, cyIcon, X, Y: Integer; rect: TRECT; DC: HDC; begin if IsIconic(m_hWnd) then begin // CPaintDC dc(this); // device context for painting // SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle cxIcon := GetSystemMetrics(SM_CXICON); cyIcon := GetSystemMetrics(SM_CYICON); rect := GetClientRect; X := (rect.Width - cxIcon + 1) div 2; Y := (rect.Height - cyIcon + 1) div 2; DC.DrawIcon(X, Y, m_hIcon); end else exit; end; DC: HDC; erzeugt [DCC Fehler] main.pas(118): E2007 Konstante oder Typenbezeichner erwartet wo ist das Problem |
AW: wiedermal VCC - > Delphi
DC is vom Typ HDC
HDC ist ein Handle ... also quasi ein Pointer Und haben Pointer Methoden? Nein. Wo kommt denn das m_hWnd urplötzlich her? (das gibt's im Original aber nicht) Und von wo kommt m_hIcon? dc(this) ist quasi das HDC vo dem Fenster im Self diese SetDC(Self.Handle) Aber warum nicht Self.Canvas verwenden, welches dieses kapselt? Statt dem m_hIcon ein TIcon und dann einfach nur noch im OnPaint
Delphi-Quellcode:
.
Canvas.Draw((ClientHeight - Icon.Height) div 2, (ClientWidth - Icon.Width) div 2, Icon)
und für das WM_ICONERASEBKGND ... entweder das Icon nicht transparent zeichnen lassen oder z.B. über Canvas.FillRect den Hintergrund löschen. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:34 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz