Interested in learning Delphi ???

Here you can talk about C++ And C# And Other languages programming.

Postby BattleStar-Galactica » Mon Apr 17, 2006 6:16 pm


there is no more resource about ado i can find. im boring so i do a pt window killer :lol:
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[i];
// 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)
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby Departure » Tue Apr 18, 2006 8:04 am

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
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Postby BattleStar-Galactica » Tue Apr 18, 2006 8:42 am

i'm not sure my code will kill banner or popup :lol: , 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 :lol:

you see, delphi embed all api we dont need to do import like vb. it's very interesting.
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby Departure » Tue Apr 18, 2006 4:53 pm

your code uses "sendmessage" this wont kill the banners, you need to use "post message"
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Postby BattleStar-Galactica » Thu Apr 20, 2006 8:47 pm

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:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby Departure » Sat Apr 22, 2006 2:41 am

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)
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Postby BattleStar-Galactica » Sat Apr 22, 2006 8:07 pm

i play with some function when i found it maybe interesting the vb programmer who want learn delphi than i post here :lol:

/////////////////////////////// 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[i]);
end;
end;
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby BattleStar-Galactica » Sun Apr 30, 2006 2:20 am

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)
Attachments
ServerClientChatMulti.rar
(283.11 KiB) Downloaded 72 times
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Re: Interested in learning Delphi ???

Postby Departure » Sun Oct 28, 2007 2:35 am

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

Code: Select all
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 locohacker starts using delphi one day so im not alone in programming paltalk apps with delphi :idea:
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Re: Interested in learning Delphi ???

Postby Chike » Tue Nov 06, 2007 12:24 pm

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.
Image
Chike
imFiles Master
imFiles Master
 
Posts: 583
Joined: Sun May 13, 2007 6:20 pm

Previous

Return to C++, C# And Others Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests