Registriert seit: 18. Mai 2003
634 Beiträge
|
Re: Eigener Desktop???
23. Aug 2004, 14:09
So! Hab jetzt mal en Beispiel geschrieben wie man das alles verwenden kann
Delphi-Quellcode:
program Desk;
uses
Windows,
Messages;
function MainWndProc(hWindow: HWND; Msg: UINT; wParam: wParam;
lParam: lParam): LRESULT; stdcall; export;
var
ps: TPaintStruct;
begin
Result := 0;
case Msg of
WM_PAINT:
begin
BeginPaint(hWindow, ps);
SetBkMode(ps.hdc, TRANSPARENT);
TextOut(ps.hdc, 10, 10, 'Hello World!', 12);
EndPaint(hWindow, ps);
end;
WM_DESTROY: PostQuitMessage(0);
else
begin
Result := DefWindowProc(hWindow, Msg, wParam, lParam);
Exit;
end;
end;
end;
var
wc: TWndClass;
hWindow: HWND;
Msg: TMsg;
OldDesktop, Desktop: HDESK;
begin
OldDesktop:=GetThreadDesktop(GetCurrentProcessId);
Desktop:= CreateDesktop('Oliver', nil, nil, DF_ALLOWOTHERACCOUNTHOOK, GENERIC_ALL, nil);
SetThreadDesktop(Desktop);
switchdesktop(Desktop);
wc.lpszClassName := 'YourAppClass';
wc.lpfnWndProc := @MainWndProc;
wc.Style := CS_VREDRAW or CS_HREDRAW;
wc.hInstance := hInstance;
wc.hIcon := LoadIcon(0, IDI_APPLICATION);
wc.hCursor := LoadCursor(0, IDC_ARROW);
wc.hbrBackground := (COLOR_WINDOW + 1);
wc.lpszMenuName := nil;
wc.cbClsExtra := 0;
wc.cbWndExtra := 0;
RegisterClass(wc);
hWindow := CreateWindowEx(WS_EX_CONTROLPARENT or WS_EX_WINDOWEDGE,
'YourAppClass',
'Desktop',
WS_VISIBLE or WS_CLIPSIBLINGS or
WS_CLIPCHILDREN or WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0,
400, 300,
0,
0,
hInstance,
nil);
ShowWindow(hWindow, CmdShow);
UpDateWindow(hWindow);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
Halt(Msg.wParam);
SetThreadDesktop(OldDesktop);
switchdesktop(OldDesktop);
CloseDesktop(Desktop);
end.
|
|
Zitat
|