- This topic has 24 replies, 4 voices, and was last updated 17 years ago by Admin.
-
AuthorPosts
-
April 17, 2006 at 11:16 pm #191518BattleStar-GalacticaMember
there is no more resource about ado i can find. im boring so i do a pt window killer 😆
here it’s a snippetcode////////////enumwindow function EnumWindowsOut(Handle: THandle; List: TStringList) : boolean ; stdcall; var className: array[0..255] of Char; caption: array[0..255] of Char; begin GetClassName(Handle, className, SizeOf(className)-1) ; GetWindowText(Handle, caption, SizeOf(caption)-1) ; if className = 'My Window Class' then List.Add(IntToStr(Handle)) ; Result :=True; end; ////////////end enumwindow /////////////////////////killwindow procedure Killwindow; var Handle : THandle; Handles : TStringList; sHandle : string; lines, i : Integer; begin Handles := TStringList.Create; try EnumWindows(@EnumWindowsOut, LParam(Handles)) ; lines := Handles.Count; for i := 0 to lines-1 do begin sHandle := Handles; // showmessage(sHandle); Handle := StrToInt(sHandle); SendMessage(Handle, WM_Quit, 0, 0) ; end; finally Handles.Free; end; end; ///////////////////////const WM_Quit = 16////// ////to use this function call procedure TForm1.Button1Click(Sender: TObject); begin Killwindow; end; ///that's will close all pt window :lol:
i think loco must joins us to learn delphi, it’s easy like learn vb 8)
April 18, 2006 at 1:04 pm #191517DepartureMembernice code… i could use this to tranfer BnP
Killer over to delphi, nobody seems to know how its done… it simple, instead of “sendmessage” i use “postmessage” and thats it you can kill and banner …popups ect… with postmessageI tryed for years to work out why sendmessage did’nt work, then one day i thought i would try postmessage … and bingo it worked…
the moral of the story is… when you know something should work in your program but does’nt … try a similar API
April 18, 2006 at 1:42 pm #191516BattleStar-GalacticaMemberi’m not sure my code will kill banner or popup 😆 , i just tryed kill pt room(voice room). but the constant of WM_Quit maybe 16 or 18.
i think 16 for quit and 18 for kill. i’m not sure or what i said has non sense 😆you see, delphi embed all api we dont need to do import like vb. it’s very interesting.
April 18, 2006 at 9:53 pm #191515DepartureMemberyour code uses “sendmessage” this wont kill the banners, you need to use “post message”
April 21, 2006 at 1:47 am #191514BattleStar-GalacticaMemberget text from window handle with delphi
function GetText(WindowHandle: hwnd):string; var txtLength : integer; buffer: string; begin TxtLength := SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0); txtlength := txtlength + 1; setlength (buffer, txtlength); sendmessage (WindowHandle,wm_gettext, txtlength, longint(@buffer[1])); result := buffer; end; //hope it can be useful for you :lol:
April 22, 2006 at 7:41 am #191513DepartureMembervery usful, but i have’nt played with delphi for awhile now, i jusy have’nt had the time, but ill start making some new programs again soon :O)
April 23, 2006 at 1:07 am #191512BattleStar-GalacticaMemberi play with some function when i found it maybe interesting the vb programmer who want learn delphi than i post here 😆
/////////////////////////////// the split function exist in vb but not in delphi procedure Split(const aString, Delimiter: string; Results: tStrings); begin Results.CommaText:='"' + StringReplace(aString, Delimiter, '","', [rfReplaceAll]) + '"'; end; //////////////////////////////////////use this function like bellow code procedure TForm1.Button1Click(Sender: TObject); var Handles : TStringList; lines, i : Integer; begin Handles := TStringList.Create; split('hello the world',' ',handles); lines := Handles.Count; for i := 0 to lines-1 do begin showmessage(handles); end; end;
April 30, 2006 at 7:20 am #191511BattleStar-GalacticaMemberok this it’s my last post about delphi cuz i think i know enoug good about delphi. I will continue to learn MFC.
here it’s the code for chat server multi connection and client chat project to do the test. check it, it’s very easy to do client server with delphi.
if one day you have a special procedure or function, i’ll happy if you share with me.
BTW Now I learn MFC, it’s too hard if anyone who interested about learning MFC pm me and we can learn together 8)
October 28, 2007 at 7:35 am #191510DepartureMemberhere is some delphi source code for paltalk.
The first function finds the window handel by partial captions of the window, for example – Voice Room
Then the next code (button click) sends a Virtual Windows message being a command to that handel. very simple very effective, the commad send was the “Notify me on people joining” but ofcause you could use any of paltalks commads using this method
function FindWindowFromPartialTitle(PartialTitle : String) : HWnd; var Buffer : array [0..255] of char; begin { do for each child of desktop window } Result := GetDeskTopWindow; Result := GetWindow(Result, GW_CHILD); while (Result 0) do begin { if window includes partial title, we're done } GetWindowText(Result, Buffer, 255); if (Pos(PartialTitle, StrPas(Buffer)) > 0) then exit; { otherwise, get the next window } Result := GetWindow(Result, GW_HWNDNEXT); end; end; procedure TForm1.Button1Click(Sender: TObject); var PalRoomHandle: integer; begin { Call our function to find a window with partial caption - Voice Room } PalRoomHandle := FindWindowFromPartialTitle('- Voice Room'); { if then statments just like vb } if PalRoomHandle 0 then begin showmessage ('Paltalk voice room Found'); { send a message, once again just like Vb } PostMessage(PalRoomHandle,WM_COMMAND,33112,0); end else showmessage('Paltalk voice room was NOT found.'); end;
Maybe of use to someone, I hope Admin starts using delphi one day so im not alone in programming paltalk apps with delphi 💡
November 6, 2007 at 5:24 pm #191509ChikeMember@Departure wrote:
here is some delphi source code for paltalk.
As a general note, not Delphi specific, according to teh documentation, this is better done with EnumWindows. For the reasons look at the remarks here.
The code is a bit more rough, but quickly it becomes a second nature to write it this way. -
AuthorPosts
Related
- You must be logged in to reply to this topic.