windebug.pas 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 2000 by Pierre Muller
  5. Win32 specific debugger routines for the IDE
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. Unit windebug;
  13. interface
  14. type
  15. DebuggeeState = (Running_State,Stopped_State);
  16. procedure ChangeDebuggeeWindowTitleTo(State : DebuggeeState);
  17. implementation
  18. uses
  19. gdbint,
  20. strings,
  21. windows;
  22. function GetWindowHandle(H : HWND; state : LPARAM) : WINBOOL;stdcall;
  23. var pTitle, pEnd, pNewTitle : pchar;
  24. len : longint;
  25. begin
  26. GetWindowHandle:=true;
  27. GetMem(pTitle,256);
  28. { we want all windows !! }
  29. if GetWindowThreadProcessId(H,nil)=inferior_pid then
  30. begin
  31. len:=GetWindowText(H,pTitle,256);
  32. if DebuggeeState(State) = Stopped_State then
  33. begin
  34. GetMem(pNewTitle,len+50);
  35. pEnd:=strpos(pTitle,'... running under FP debugger');
  36. if assigned(pEnd) then
  37. pEnd^:=#0;
  38. strcopy(pNewTitle,pTitle);
  39. strcat(pNewTitle,'... stopped by FP debugger');
  40. SetWindowText(H,pNewTitle);
  41. FreeMem(pNewTitle,len+50);
  42. end
  43. else if DebuggeeState(State) = Running_State then
  44. begin
  45. GetMem(pNewTitle,len+50);
  46. pEnd:=strpos(pTitle,'... stopped by FP debugger');
  47. if assigned(pEnd) then
  48. pEnd^:=#0;
  49. strcopy(pNewTitle,pTitle);
  50. strcat(pNewTitle,'... running under FP debugger');
  51. SetWindowText(H,pNewTitle);
  52. FreeMem(pNewTitle,len+50);
  53. end;
  54. end;
  55. FreeMem(pTitle,256);
  56. end;
  57. procedure ChangeDebuggeeWindowTitleTo(State : DebuggeeState);
  58. begin
  59. EnumWindows(EnumWindowsProc(@GetWindowHandle),longint(State));
  60. end;
  61. end.