Skip to content

Interested in learning Delphi ???

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #191518

    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)

    #191517
    Departure
    Member

    nice 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 postmessage

    I 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

    #191516

    i’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.

    #191515
    Departure
    Member

    your code uses “sendmessage” this wont kill the banners, you need to use “post message”

    #191514

    get 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:
    #191513
    Departure
    Member

    very 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)

    #191512

    i 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;
    #191511

    ok 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)

    #191510
    Departure
    Member

    here 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 💡

    #191509
    Chike
    Member

    @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.

Viewing 10 posts - 16 through 25 (of 25 total)
  • You must be logged in to reply to this topic.