Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi nonVCL vorlage will nicht... (https://www.delphipraxis.net/105899-nonvcl-vorlage-will-nicht.html)

hedie 1. Jan 2008 21:23


nonVCL vorlage will nicht...
 
Hallo

Ich habe mir ein kleines Programm geschrieben... welches jetzt jedoch 700 KB ist
obwohl es nur etwas kleiner erledigt (patchen einer EXE :D )

Nun wollte ich die Grösse trimmen...

Die einzige Möglichkeit ist ja, die über nonVCL

Gut, dachte ich und hab mal n bisschen ge googlet und das gefunden dsdt Link nonVCL
Dann wollte ich mir das erste Beispiel runterladen, doch was dan? Avast meldet einen Virus um zip
genauso beim zweiten beispiel. Das dritte hat dan geklappt... (LINK) Doch nun mekert Delphi beim Compilieren folgendes...

Delphi-Quellcode:
HLcursor := LoadCursor(hInstance, 'HandCursor');
Code:
[DCC Fehler] Hyperlink.pas(74): E2064 Der linken Seite kann nichts zugewiesen werden
weshalb den das?

mkinzler 1. Jan 2008 21:26

Re: nonVCL vorlage will nicht...
 
Ist HLcursor eine Konstante?
Was für ein Typ hat HLcursor?
Gibt es vielleicht eine Prozedur/Methode mit dem selben Namen?

hedie 1. Jan 2008 21:29

Re: nonVCL vorlage will nicht...
 
HLCursor ist nirgends definiert... also gehe ich mal davon aus das es ne konstante ist...

Wenn ich den Code Posten soll (den ganzen) einfach sagen... wollte nicht von begin an
das Forum zu "müllen" :)

mkinzler 1. Jan 2008 21:30

Re: nonVCL vorlage will nicht...
 
Einer Konstante kann man auch nichts zuweisen.

hedie 1. Jan 2008 21:32

Re: nonVCL vorlage will nicht...
 
aber weshalb konnte dan dieser assbard sein Projekt compilieren?

Im geposteten Zip (link) sind ja alle Projekt Dateien enthalten so wie er sie benutzt hat...

Da kann doch was nicht stimmen....

Kennst du sonst noch ein gutes Tutorial für nonVCL oder ein nonVCL hello world :D natürlich mit Formularen aus der WinAPI

p.s. danke für die schnellen Antworten

mkinzler 1. Jan 2008 21:34

Re: nonVCL vorlage will nicht...
 
Poste mal deinen Code
BTW. assarbad ist hier im Forum Als Olli aktiv

hedie 1. Jan 2008 21:41

Re: nonVCL vorlage will nicht...
 
Opps sorry hab mich vertan... er heisst assarbad :D

Delphi-Quellcode:
(****************************************************************
 ****************************************************************
 ***                                                          ***
 ***        Copyright (c) 2001 by -=Assarbad [GoP]=-          ***
 ***       ____________                 ___________           ***
 ***      /\   ________\               /\   _____  \          ***
 ***     /  \  \       /    __________/  \  \    \  \         ***
 ***     \   \  \   __/___ /\   _____  \  \  \____\  \        ***
 ***      \   \  \ /\___  \  \  \    \  \  \   _______\       ***
 ***       \   \  \ /   \  \  \  \    \  \  \  \      /       ***
 ***        \   \  \_____\  \  \  \____\  \  \  \____/        ***
 ***         \   \___________\  \__________\  \__\            ***
 ***          \  /           /  /          /  /  /            ***
 ***           \/___________/ \/__________/ \/__/             ***
 ***                                                          ***
 ***  May the source be with you, stranger ... :-)           ***
 ***                                                          ***
 ***  Greets from -=Assarbad [GoP]=- ...                     ***
 ***  Special greets go 2 Nico, Casper, SA, Pizza, Navarion...***
 ***[for questions/proposals drop a mail to [email]Assarbad@ePost.de[/email]]***
 *****************************************ASCII by Assa [GoP]****
 ****************************************************************)

{$R handcursor.res}
const
  AHyperlink = 'AHyperlinkWndClassEx';
  HLcursor: Cardinal = 0;
var
  inactivefont,
    activefont,
    inactivecolor,
    activecolor: Cardinal;

function HyperlinkWndProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
  prop, DC: DWORD;
  point: TPoint;
  rect: TRect;
  ps: TPaintStruct;
  pc: array[0..$400] of char;

  procedure paint(txtcolor: Cardinal);
  var size: TSize;
  begin
    GetClientRect(hWnd, rect);
    if txtcolor = inactivecolor then selectobject(dc, inactivefont)
    else selectobject(dc, activefont);
    Fillrect(DC, rect, GetSysColorBrush(COLOR_3DFACE));
    SetBkMode(DC, TRANSPARENT);
    Settextcolor(DC, txtcolor);
    SendMessage(hWnd, WM_GETTEXT, $400, LongInt(@pc[0]));
    GetWindowRect(hWnd, rect);
    GetTextExtentPoint32(DC, @pc[0], lstrlen(@pc[0]), size);
//center text in control window
    ExtTextOut(DC, ((rect.right - rect.left) div 2) - (size.cx div 2), 0, 2, @rect, @pc[0], lstrlen(@pc[0]), nil);
  end;

  function varfont(DC: DWORD; size, weight: integer; underline: BOOL): DWORD;
  begin
    result := CreateFont(-MulDiv(size, GetDeviceCaps(DC, LOGPIXELSY), 72), 0, 0, 0, weight, 0, Cardinal(underline), 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH or FF_ROMAN, 'MS Sans Serif');
  end;

  function fixfont(DC: DWORD; size, weight: integer; underline: BOOL): DWORD;
  begin
    result := CreateFont(-MulDiv(size, GetDeviceCaps(DC, LOGPIXELSY), 72), 0, 0, 0, weight, 0, Cardinal(underline), 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH or FF_MODERN, 'Courier New');
  end;

begin
  Result := 0;
  case uMsg of
    WM_CREATE:
      begin
        result := DefWindowProc(hWnd, uMsg, wParam, lParam);
        //HLcursor := LoadCursor(hInstance, 'HandCursor');
        DC := GetWindowDC(hWnd);
        inactivefont := fixfont(DC, 8, FW_NORMAL, FALSE);
        activefont := fixfont(DC, 8, FW_BOLD, TRUE);
        ReleaseDC(hWnd, DC);
        inactivecolor := rgb($0, $0, $0);
        activecolor := rgb($0, $0, $FF);
        SendMessage(hWnd, WM_CAPTURECHANGED, 0, 0);
      end;
    WM_RBUTTONUP,
      WM_LBUTTONUP:
      begin
        prop := getprop(hwnd, 'Link');
        if prop <> 0 then shellexecute(0, 'open', pchar(prop), '', '', SW_SHOWNORMAL);
      end;
    WM_CAPTURECHANGED,
      WM_MOUSEMOVE:
      begin
        GetCursorPos(point);
        GetWindowRect(hwnd, rect);
        if PtInRect(rect, point) then begin
          if GetCapture <> hWnd then begin
            SetCapture(hWnd);
            SetCursor(HLcursor);
            SendMessage(hWnd, WM_PAINT, activecolor, -1);
          end;
        end else begin
          ReleaseCapture;
          SendMessage(hWnd, WM_PAINT, inactivecolor, -1);
        end;
      end;
    WM_PAINT:
      begin
        case lParam of
          -1: begin
              DC := GetWindowDC(hWnd);
              paint(wParam);
              ReleaseDC(hWnd, DC);
            end;
        else begin
            DC := BeginPaint(hWnd, ps);
            paint(wParam);
            EndPaint(hWnd, ps);
          end;
        end;
      end;
  else result := DefWindowProc(hWnd, uMsg, wParam, lParam);
  end;
end;

procedure initacomctl;
var
  wc: TWndClassEx;
begin
  wc.style := CS_HREDRAW or CS_VREDRAW or CS_GLOBALCLASS;
  wc.cbSize := sizeof(TWNDCLASSEX);
  wc.lpfnWndProc := @HyperlinkWndProc;
  wc.cbClsExtra := 0;
  wc.cbWndExtra := 0;
  wc.hInstance := hInstance;
  wc.hbrBackground := COLOR_WINDOW;
  wc.lpszMenuName := nil;
  wc.lpszClassName := AHyperlink;
  wc.hIcon := 0;
  wc.hIconSm := 0;
  wc.hCursor := 0;
  RegisterClassEx(wc);
end;

Luckie 1. Jan 2008 21:46

Re: nonVCL vorlage will nicht...
 
Man kann bei den Compiler-Optionen angeben, dass man auch Konstanten ändern kann zur Laufzeit. Aber warum hast du dir gearde das komplizierteste Beispiel rausgesucht?

Und eigentlich hättest du auch meine NonVCL-Tutorials finden sollen: http://win32api.michael-puff.de

Dialog- und Fenster-Vorlagen findest du auch bei mir: http://www.michael-puff.de/Developer/Delphi/Demos/ -> Template.zip

hedie 1. Jan 2008 21:47

Re: nonVCL vorlage will nicht...
 
Cool Danke...

Weshalb ich mir gerade das dritte ausgesucht habe anstelle der beiden anderen...

Weil die ersten zwei ZIP's nen Virus enthalten :D meldet zumindest mein Avast

//////Edit

Mit dem einschalten der Option hats geklappt, Danke

Ich werd mir deine Page gleich mal ansehen

Luckie 1. Jan 2008 21:52

Re: nonVCL vorlage will nicht...
 
Halte ich für recht unwahrscheinlich. Weder Assarbad noch das DSDT werden Viren verbreiten.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:58 Uhr.
Seite 1 von 2  1 2      

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