No to mam coś takiego:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PS : TPaintStruct;
DC : HDC; // uchwyt
implementation
{$R *.dfm}
{$R BITMAP.RES}
function WndProc(Wnd: HWND; uMsg: UINT; wPar: WPARAM; lPar: LPARAM): LRESULT; stdcall;
var
Bitmap : HBITMAP;
_Bitmap : HDC;
begin
{ na początek zwracamy wartość 0 - meldunek jest przetwarzany }
Result := 0;
case uMsg of
{ tutaj, w tym miejscu należy obsłużyć należne komunikaty }
{ w funkcji DefWindowProc przekazujemy takie same parametry jak w funkcji okienkowej }
WM_PAINT:
begin
DC := BeginPaint(Wnd, PS);
Bitmap := LoadBitmap(hInstance, 'ID_BITMAP');
_Bitmap := CreateCompatibleDC(DC);
SelectObject(_Bitmap, Bitmap);
BitBlt(dc, 10, 10, 14, 14, _Bitmap, 0, 0, SRCCOPY);
DeleteDC(_Bitmap);
EndPaint(Wnd, PS);
end;
WM_DESTROY: PostQuitMessage(0);
else Result := DefWindowProc(Wnd, uMsg, wPar, lPar);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hW : HWND;
begin
hW := FindWindow(nil,'Form1'); // określ uchwyt
DC:=GetDC(hW);
WndProc(hW,DC,10,10);
end;
end.
i w debuggerze pisze że
[Error] Unit1.pas(69): Types of actual and formal var parameters must be identical
nie może skompilować bo parametr musi być taki sam i nie wiem o co chodzi...