Thema: Delphi Looking 4 help

Einzelnen Beitrag anzeigen

Mr.Sade

Registriert seit: 25. Feb 2003
17 Beiträge
 
Delphi 6 Enterprise
 
#8
  Alt 27. Feb 2003, 19:48
Hello people

I think all is working now.
I haven't try it with delphi, because I am at school right now,
but I will do it later, when I get home.
I have ported my delphi code to assembly language, MASM32
and I have change some parts and it works good

the parts that I changed are:
Delphi-Quellcode:
procedure NotepadCreated(Handle: HWND);
var
  OldPtr: Integer;
begin
  { invoke  SetWindowLong, Handle, GWL_WNDPROC, ADDR NotepadProc
    invoke  SetWindowLong, Handle, GWL_USERDATA, eax  }


  { lets subclass it and assign pointer }
  OldPtr := SetWindowLong(Handle, GWL_WNDPROC, Integer(@NotepadProc));
  SetWindowLong(Handle, GWL_USERDATA, OldPtr);
end;
and when cleaning everything:
Delphi-Quellcode:
{ EnumWins proc Handle:DWORD, lParam:LPARAM
    invoke  RtlZeroMemory, ADDR Buffer, 256
    invoke  GetClassName, Handle, ADDR Buffer, 256
    invoke  lstrcmpi, ADDR Buffer, ADDR Notepad
    .IF eax == 0
        invoke  SendMessage, Handle, WM_STOPSUBCLASSING, 0, 0
    .ENDIF
    mov    eax, TRUE
    ret
EnumWins endp }

function EnumWins(Handle: HWND; lParam: LPARAM): Boolean;
    stdcall;
var
  szClass: array [0..256] of Char;
begin
  ZeroMemory(@szClass, 256);
  GetClassName(Handle, szClass, 256);
  if szClass = 'Notepadthen
    SendMessage(Handle, WM_STOPSUBCLASSING, 0, 0);
  Result := True;
end;

Inside NotepadWndProc:
Delphi-Quellcode:
  { Msg == WM_STOPSUBCLASSING
      invoke  GetWindowLong, Handle, GWL_USERDATA
      invoke  SetWindowLong, Handle, GWL_WNDPROC, eax  }

  WM_STOPSUBCLASSING:
  begin
    OldPtr := GetWindowLong(Handle, GWL_USERDATA);
    SetWindowLong(Handle, GWL_WNDPROC, OldPtr);
  end;

so if it works with MASM, it should work with Delphi6
Thank You for your time
Mr.Sade
  Mit Zitat antworten Zitat