Solved

Desktop Subclass Problem

Posted on 2001-09-05
3
393 Views
Last Modified: 2010-08-05
I wrote this dll, and it isn't working. Can anybody help?

--------------------------------------------------------
library Desktop;

uses
  SysUtils, Classes,windows, Messages, Dialogs;

const
    WM_PAINTPRIVATE_MESSAGE = WM_USER + 322;

var oldWndProc: Integer;

function myDesktopWndProc(WindowHandle:hWnd; TheMessage:Longint; ParamW:Longint;ParamL:Longint):LongInt; stdcall;
begin
  case TheMessage of
  xxx : ShowMessage('Testing...');
  end;

   myDesktopWndProc := CallWindowProc(Pointer(OldWndProc),WindowHandle, TheMessage, ParamW, ParamL);
end;


procedure SetProc; stdcall;
var FhDesktopWnd : HWND;
    FDesktopWndInstance : TFarProc;
    Errol : Cardinal;
    DProc : LongInt;
begin

 oldWndProc:=GetWindowLong(GetDesktopWindow, GWL_WNDPROC);
 if SetWindowLong( GetDesktopWindow, GWL_WNDPROC, Longint(@myDesktopWndProc))=0 then
  begin
  Errol:= GetLastError;
  showmessage(inttostr(Errol));

  end
  else
   showmessage('Set')
end;

procedure KillProc; stdcall;
begin
  SetWindowLong( GetDesktopWindow, GWL_WNDPROC, LongInt(oldWndProc));
  showmessage('Kill')
end;


exports SetProc index 1,
        KillProc index 2;
begin

end.




--------------------------------------------------------

I get the ERROR_CALL_NOT_IMPLEMENTED error when I call then SetWindowLong function.


Regards,
guitfatio
0
Comment
Question by:guitfatio
3 Comments
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 25 total points
Comment Utility
Check out Madshi's comment (it's at the bottom of the page):

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20178822
0
 
LVL 20

Assisted Solution

by:Madshi
Madshi earned 25 total points
Comment Utility
:-)

The problem is that SetWindowLong is only supported for windows that belong to the current process. So your dll can call SetWindowLong only, if your dll is loaded in the context of the explorer process. See DragonSlayer's link for more information...

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

split points between DragonSlayer and Madshi

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now