» »

Pomoč... Začetnik v programiranju

Pomoč... Začetnik v programiranju

Tito ::

Imam Programsko kodo...
library BLA;

uses
Sharemem,
lcdcifhelper in 'lcdcifhelper.pas',
Graphics,
Classes,
SysUtils,
Dialogs,
Windows;

Type
tEventType = (tetRandom1,tetRandom2);
tmyEvents = Record
LinkedEventID : Integer;
EventType : tEventType;
EventParam : Integer;
End;

Var
MainWindowHandle : HWND; {---save so the you can send event notification back to LCDC---}
Monitoring : Boolean;
DoPopupMessage:Procedure(Text,URL,URLText:String);StdCall;
myEvents : Array of tmyEvents;

{
All the current exports from LCDC as follows :-

Function GetNetConnection:Boolean; StdCall;
Function GetVariable(aString:String;InParam:Array of char):String; StdCall;
Function GetVersionBuild:Integer; StdCall;
Procedure DoPopupMessage(Text,URL,URLText:String);StdCall;
Procedure ShowIconMessage(Title,Text:String);StdCall;
Function IsRunning:Boolean;StdCall;
Function GetGroupName:String;StdCall;
Function GetScreenName(CurOrLast:Boolean):String;StdCall;
Function GetHTTP(URL:String):String;StdCall;
Function SelectVariable(InString:String):String;StdCall;
Function ICM(InString:String):String;StdCall;

Declare as follows :-

GetVariable:Function(aString:String;InParam:Array of char):String; StdCall;
etc.

}

{$R blank.res}

{------------------------------------------------------------------------------}
{- Initialise - allows DLL to setup or call any needed params -----------------}
{- returning false to this will stop LCDC from using the plugin ---------------}
{- you would do this if the plugins purpose is not valid etc. -----------------}
{------------------------------------------------------------------------------}
Function Initialise(Handle:hWnd):Boolean;Export ; stdcall
Begin
MainWindowHandle := Handle;
Monitoring := False;
Result := True;
{ the InterfaceHelper shows all callbacks availble, you would get them like so }
DoPopupMessage := GetProcAddress(getmodulehandle(Nil),'DoPopupMessage');
End;

{------------------------------------------------------------------------------}
{- Finalise - allows DLL to free any memory etc. ------------------------------}
{------------------------------------------------------------------------------}
Procedure Finalise;Export ; stdcall
Begin
{ don't forget to free memory etc.! }
End;

{------------------------------------------------------------------------------}
{- reports back if active or not this enables/diables the LCDC plugin icon ----}
{- this function gets called about 1 per second, so you can use it to check ---}
{- events etc. however make your routine as quick as possible or it will eat --}
{- cpu time and cause user grief! ---------------------------------------------}
{------------------------------------------------------------------------------}
Function GetActive:Boolean;Export ; stdcall
Procedure TriggerEvent(WhichOne:Integer);
Begin
With myEvents[WhichOne] Do Begin
{- SendMessage(MainWindowHandle,UM_PluginEvent,LinkedEvent,EventResult); ------}
SendMessage(MainWindowHandle,UM_PluginEvent,LinkedEventID,0); {no event result needed}
End;
End;
Var
Loop,aRandom : Integer;
Begin
Result := True;
{--- you can do event monitoring here or in it's own timer thread - up to you :)---}
If Monitoring Then Begin
For Loop := 0 To Length(myEvents)-1 Do Begin
Case myEvents[Loop].EventType Of
tetRandom1 : Begin
aRandom := Random(40)+10;
If aRandom=myEvents[Loop].EventParam Then TriggerEvent(Loop);
End;
tetRandom2 : Begin
aRandom := Random(8)+1;
If aRandom=myEvents[Loop].EventParam Then TriggerEvent(Loop);
End;
End;

End;
End;
End;

{------------------------------------------------------------------------------}
{- reports back variables availble in this DLL --------------------------------}
{------------------------------------------------------------------------------}
Procedure GetVariables(Var myList:tLCDCStringList);Export ; stdcall
Const PlugInItems:Array[0..5] of String=(
'LV1 - Top Level 1',
#9'IT1 - Item 1 in top level',
#9'IT2 - Item 2 in top level',
'LV2 - Top Level 2',
#9'IT1 - Item 1 in top level',
#9'IT2 - Item 2 in top level');
Var Loop : Integer;
Begin
SetLength(myList,Length(PlugInItems));
For Loop := 0 To Length(PlugInItems)-1 Do
myList[Loop] := PluginItems[Loop];
End;

{------------------------------------------------------------------------------}
{- reports back variables availble in this DLL --------------------------------}
{- function will be sent first 3 chars of each level - e.g. LV2IT2 ------------}
{- you may split this as you want ---------------------------------------------}
{- breaking it down in a tree format is the most efficient way to do this -----}
{- tough shit if you don't like my coding style !! ----------------------------}
{------------------------------------------------------------------------------}
Function GetItemValue(AnItem:String):String ;Export ; stdcall
Begin
If Copy(AnItem,1,3)='LV1' Then Begin
If Copy(AnItem,4,3)='IT1' Then Begin
Result := 'Level1Item1value';
Exit;
End;
If Copy(AnItem,4,3)='IT2' Then Begin
Result := 'Level1Item2value';
Exit;
End;
Exit;
End;
If Copy(AnItem,1,3)='LV2' THen Begin
If Copy(AnItem,4,3)='IT1' Then Begin
Result := 'Level2Item1value';
Exit;
End;
If Copy(AnItem,4,3)='IT2' Then Begin
Result := 'Level2Item2value';
Exit;
End;
Exit;
End;
Result := '???';
End;

{------------------------------------------------------------------------------}
{- GetIcon16x16x16 returns the bitmap 16 x 16 in 16 colours to name -----------}
{- and resource location for LCDC to load in ----------------------------------}
{------------------------------------------------------------------------------}
Procedure GetBitmap16x16x16(Var LoadFromResource:tBitmapResInfo);stdcall;
Begin
With LoadFromResource Do Begin
hInst := hInstance;
ResName := 'TEST';
End;
End;

{------------------------------------------------------------------------------}
{- GetAuthor returns any contact details etc. on the plugin author ------------}
{------------------------------------------------------------------------------}
Function GetAuthor:String;Export ; stdcall
Begin
Result := 'Author details';
End;

{------------------------------------------------------------------------------}
{- GetLongName ----------------------------------------------------------------}
{------------------------------------------------------------------------------}
Function GetLongName:String;Export ; stdcall
Begin
Result := 'Blank example plugin';
End;

{------------------------------------------------------------------------------}
{- reports back actions DLL can do --------------------------------------------}
{- actions are a flat list not treed as in the variables ----------------------}
{- each action MUST be followed by an equals sign and a parameter ----- e.g. --}
{- nothing=0 0=no action -}
{- screen=1 1=screen name selection -}
{- text command select=2 2=text entry with command selection -}
{- gpo selection=3 3=select gpo number 1-10 -}
{- file=4,exe 4=file selection,file extension -}
{- group=5 5=group name selection -}
{- Combobox=6,A,B,C 6=ComboBox selection -}
{- RawText=7 7=Raw plain text entry -}
{------------------------------------------------------------------------------}
Procedure GetActions(Var myList:tLCDCStringList);Export ; stdcall
Begin
SetLength(myList,2);
myList[0] := 'DO DING SOUND=0';
myList[1] := 'LCDC FORUMS MESSAGE=0';
End;

{------------------------------------------------------------------------------}
{- execute action -------------------------------------------------------------}
{- action will be set to the whole word, and paramter based on user entry
{------------------------------------------------------------------------------}
Procedure ExecuteAction(Action,Parameter:String);Export ; stdcall
Begin
If Action='DO DING SOUND' Then Begin
MessageBeep(65535);
Exit;
End;
If Action='LCDC FORUMS MESSAGE' Then Begin
DoPopupMessage('Click here for LCDC Forums','http://forums.planetdps.com','::forums:...
Exit;
End;
End;

{------------------------------------------------------------------------------}
{- reports back if DLL is configurable ----------------------------------------}
{- obviously true=yes, and false=no -------------------------------------------}
{------------------------------------------------------------------------------}
Function GetConfigurable:Boolean;Export ; stdcall
Begin
Result := False
End;

{------------------------------------------------------------------------------}
{- configure plugin -----------------------------------------------------------}
{- you can open your own form or whatever here --------------------------------}
{------------------------------------------------------------------------------}
Procedure ExecuteConfiguration;Export ; stdcall
Begin
End;

{------------------------------------------------------------------------------}
{- reports back events plugin can do ------------------------------------------}
{- events are flat list not tree'd as in the variables ------------------------}
{- each event MUST be followed by an equals sign and --------------------------}
{- upto two parameters in square brackets - e.g. myEvent=[0][2] or anEvent=[1] }
{- nothing=[0] 0=no action -}
{- text=[1] 1=plain text entry -}
{- combo=[2,a,b,c] 2=dropdown combobox + options -}
{- number=[3,low,high] 3=number selection + lowest and highest allowed -}
{- Hotkey=[4] 4=Hotkey input -}
{- GroupSelection=[5] 5=Select from group list -}
{- ScreenSelection=[6] 6=Select from screens -}
{- FloatValue=[7,1.1,9.9] 7=Floating number selection + lowest/highest -}
{------------------------------------------------------------------------------}
Procedure GetEvents(Var myList:tLCDCStringList);Export ; stdcall
Begin
SetLength(myList,2);
myList[0] := 'ON RANDOM NUMBER=[3,10,50]';
myList[1] := 'ON ANOTHER RANDOM NUMBER=[2,1,2,3,4,5,6,7,8,9]';
End;

{------------------------------------------------------------------------------}
{- enable the monitoring of events to send back -------------------------------}
{- LCDC will send a list of events for you to monitor -------------------------}
{- this means you only have to watch a couple of things rather than everything }
{------------------------------------------------------------------------------}
Procedure StartEventMonitoring(SomeEvents:tLCDCArrayOfEvents);Export ; stdcall
Var
Loop : Integer;
Begin
{- you are sent an array of your events only, go though each one ans setup -}
{- you own internal monitoring to trigger these events, events should only -}
{- be triggered once e.g. if x>y should only be triggered once, not every -}
{- time the event is checked, this saved a LOT of processing time elsewhere-}
Monitoring := False;
SetLength(myEvents,Length(SomeEvents));
If Length(SomeEvents)>0 Then Begin
Randomize;
For Loop := 0 To Length(SomeEvents)-1 do Begin
myEvents[Loop].LinkedEventID := SomeEvents[Loop].IDNumber;
If SomeEvents[Loop].OfType='ON RANDOM NUMBER' Then Begin
myEvents[Loop].EventType := tetRandom1;
Try
myEvents[Loop].EventParam := StrToInt(SomeEvents[Loop].Param1);
except
myEvents[Loop].EventParam := 10;
End;
End;
If SomeEvents[Loop].OfType='ON ANOTHER RANDOM NUMBER' Then Begin
myEvents[Loop].EventType := tetRandom2;
Try
myEvents[Loop].EventParam := StrToInt(SomeEvents[Loop].Param1);
except
myEvents[Loop].EventParam := 1;
End;
End;
End;
Monitoring := True;
End;
End;

{------------------------------------------------------------------------------}
{- stop the monitoring of events to send back ---------------------------------}
{------------------------------------------------------------------------------}
Procedure StopEventMonitoring;Export ; stdcall
Begin
{- flag your montioring to not bother cheecking anymore! }
Monitoring := False;
SetLength(myEvents,0);
End;

{------------------------------------------------------------------------------}
{- EXPORT all inforamtion needed back out -------------------------------------}
{------------------------------------------------------------------------------}
Exports
Initialise,Finalise,
GetActive,GetVariables,GetItemValue,GetBitmap16x16x16,GetAuthor,GetActions,GetConfigurable,GetLongName,GetEvents,
ExecuteAction,ExecuteConfiguration,
StartEventMonitoring,StopEventMonitoring;

end.

************************************************

Sedaj pa takole: to naj bi bila spremenljivka Result := 'Level2Item2value'; kako bi naredil, da bi ta spremenljivka kazala fremrate od BSplayerja?


Aja to se gre za en plug izdelan v Delphi-ju, je pa dodatek za en program, ki kaže različne stvari, ki se dogajajo v kišti na lcd zaslončku... Obstajajo plugini za Winamp, WINDVD, seti... Za bsplayer ga še ni a ga potrebujem, saj želim narediti Divx player z takim LCD-jem...

HVALA
  • spremenil: Tito ()

Gandalfar ::

pomojem da mors pogledat ane v SDK dokumentacijo kera funkcija ti vrne ta podatek in potem pac to podas v resultu...


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Slo-Tech userscripts

Oddelek: Izdelava spletišč
175173 (2625) jype
»

Delphi - izdelava igre

Oddelek: Programiranje
81165 (938) Nextor
»

[Delphi] Simpl vprašanja ko pasulj :)

Oddelek: Programiranje
91488 (1337) oldguy
»

[.NET ASP] Napaka : Specified cast is not valid

Oddelek: Programiranje
61118 (1071) pinc
»

Odpiranje dat.exe v VB

Oddelek: Programiranje
122990 (2783) webblod

Več podobnih tem