Created
February 6, 2011 14:18
-
-
Save anonymous/813389 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// My SkypeReply event error: | |
// Get Skype from Skype.com. | |
// Import the Skype4COM library in Delphi. | |
// Make a new project, and drop the TSkype component on your form. | |
// Make a FormCreate event for your form | |
// Make a SkypeReply event in the TSkype component. (Events>OnReply) | |
// Paste the following code into your Unit1: | |
// Now, make a Skype Category, and rename it. When it gets renamed, the Stack Overflow occurs! | |
unit Unit1; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, OleCtrls, SKYPE4COMLib_TLB, StrUtils; | |
type | |
TForm1 = class(TForm) | |
Skype1: TSkype; | |
procedure FormCreate(Sender: TObject); | |
procedure Skype1Reply(ASender: TObject; const pCommand: ICommand); | |
private | |
function GetCategoryByID(ID: Integer): IGroup; | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
Form1: TForm1; | |
implementation | |
{$R *.dfm} | |
//////////////////////////////////////////////////////////////////////////////// | |
/// GetCategoryByID | |
//////////////////////////////////////////////////////////////////////////////// | |
Function TForm1.GetCategoryByID(ID : Integer):IGroup; | |
Var | |
I : Integer; | |
Category : IGroup; | |
Begin | |
// Make the default result nil | |
Result := nil; | |
// Loop thru the CUSTOM CATEGORIES of the ONLY SKYPE CONTROL used in this project | |
// (which 100% positive IS attached ;) ) | |
for I := 1 to Skype1.CustomGroups.Count do | |
Begin | |
// The Category Variable | |
Category := Skype1.CustomGroups.Item[I]; | |
// If the current category ID returned by the loop matches the passed ID | |
if Category.Id = ID then | |
begin | |
// Return the Category as Result (IGroup) | |
Result := Category; | |
// Exit the function. | |
Exit; | |
end; | |
End; | |
End; | |
//////////////////////////////////////////////////////////////////////////////// | |
/// FormCreate | |
//////////////////////////////////////////////////////////////////////////////// | |
procedure TForm1.FormCreate(Sender: TObject); | |
begin | |
// Attach to the Skype Client. | |
Skype1.Attach(10,False); | |
end; | |
//////////////////////////////////////////////////////////////////////////////// | |
/// SkypeReply | |
//////////////////////////////////////////////////////////////////////////////// | |
procedure TForm1.Skype1Reply(ASender: TObject; const pCommand: ICommand); | |
Procedure OnCategoryRename; | |
Var | |
CategoryID : Integer; | |
sCtgName : String; | |
Begin | |
if (AnsiContainsStr(pCommand.Reply,'GROUP')) and (AnsiContainsStr(pCommand.Reply,'DISPLAYNAME')) then | |
begin | |
sCtgName := pCommand.Reply; | |
Delete(sCtgName,1,Pos('GROUP',sCtgName)+5); | |
CategoryID := StrToInt(Trim(LeftStr(sCtgName,Pos(' ',sCtgName)))); | |
sCtgName := GetCategoryByID(CategoryID).DisplayName; | |
ShowMessage(sCtgName); | |
end; | |
End; | |
begin | |
if Trim(pCommand.Reply) = '' then Exit; | |
if LeftStr(pCommand.Reply,4) = 'CALL' then Exit; | |
if (AnsiContainsStr(pCommand.Reply,'GROUP')) and (AnsiContainsStr(pCommand.Reply,'DISPLAYNAME')) then | |
OnCategoryRename; | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment