(*

 This sourcecode is not commented all the way to explain how
 the minicommand 2.0 plugin system works.

 Look at source for "Sample.dpr" for full commentation.

 Feel free to modify this code as you wish.

*)





















library FunPack;

uses
  Forms,
  BleepInt,
  Bleeper,
  controls,
  windows,
  SysUtils,
  Classes,
  ImgFlip,
  mmSystem,
  pcUnit,
  Shared,
  Graphics;

{$R *.RES}
{$R cursors.res}
const

 my_name    = 'FunPack Plugin';      // <-- the name of your plugin
 my_version = '1.0';                 // <-- Version of your plugin
 my_author  = 'st0ner@charter.net';  // <-- only change value, not name!

 help_file  = 'FunPack.txt';         // <-- used for the edit server, when
                                     // loading a plugin to test or configure,
                                     // EditServerDir+\plugins\help_file is loaded
var
 TheBmp: TBitmap;
 dc: HDc;
 DeskHWnd: Hwnd;
 ScreenWidth: integer;
 ScreenHeight: integer;
 FlipBMP: TBitmap;
 h: thandle;
 OwnerHandle: THandle;

//== PLUGIN SHIT =============================================================//
procedure InitPlugin(Hndl: Integer); StdCall;
begin
 OwnerHandle := Hndl;
 { Create components and other stuff here }
end;

procedure KillPlugin; StdCall;
begin
 { Free components and other stuff here }
end;

function PluginInfo : PChar; StdCall;
var s: string;
begin
 s := my_name+'%'+my_version+'%'+my_author+'%'+help_file;
 Result := PChar(s);
end;

function DoPluginAction(Action: integer; Param1,Param2: pChar;
                        Param3,Param4: integer; BoolVar: Boolean): pChar; stdCall;
var
 Wnd,taskbarhandle,Buttonhandle:thandle; tmp:pchar; i:integer;
begin
 TMP:='FunPack Internal Error';
 case Action of
  0 :begin
      Wnd := FindWindow('Progman', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'ShellDll_DefView', nil);
      ShowWindow(Wnd, SW_HIDE);
      tmp:=pchar('Desktop Icons Hidden.');
     end;
  1 :begin
      Wnd := FindWindow('Progman', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'ShellDll_DefView', nil);
      ShowWindow(Wnd, SW_SHOW);
      tmp:=pchar('Desktop Icons shown.');
     end;
  2 :begin
      Wnd:=FindWindow('Shell_TrayWnd',nil);
      ShowWindow(Wnd,SW_HIDE);
      tmp:=pchar('Taskbar hidden.');
     end;
  3 :begin
      Wnd:=FindWindow('Shell_TrayWnd',nil);
      ShowWindow(Wnd,SW_Show);
      tmp:=pchar('Taskbar shown.');
     end;
  4 :begin
      taskbarhandle := FindWindow('Shell_TrayWnd', nil);
      buttonhandle := GetWindow(taskbarhandle, GW_CHILD);
      ShowWindow(buttonhandle, SW_HIDE);
      tmp:=pchar('Start button hidden.');
     end;
  5 :begin
      taskbarhandle := FindWindow('Shell_TrayWnd', nil);
      buttonhandle := GetWindow(taskbarhandle, GW_CHILD);
      ShowWindow(buttonhandle, SW_show);
      tmp:=pchar('Start button shown.');
     end;
  6 :begin
      Wnd := FindWindow('Shell_TrayWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayClockWClass', nil);
      ShowWindow(Wnd, SW_HIde);
      tmp:=pchar('System clock hidden.');
     end;
  7 :begin
      Wnd := FindWindow('Shell_TrayWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayClockWClass', nil);
      ShowWindow(Wnd, SW_show);
      tmp:=pchar('System clock shown.');
     end;

  8 :begin
      Wnd := FindWindow('Shell_TrayWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
      if BoolVar then
       begin
        ShowWindow(Wnd, SW_HIDE);
        tmp:=pchar('System tray hidden.');
       end else
       begin
        ShowWindow(Wnd, SW_SHOW);
        tmp:=pchar('System tray shown.');
       end;
     end;
  9 :begin
      Wnd := FindWindow('Progman',nil);
      if BoolVar then
       begin
        EnableWindow(wnd,false);
        tmp:=pchar('Desktop disabled.');
       end else
       begin
        EnableWindow(wnd,true);
        tmp:=pchar('Desktop enabled.');
       end;
     end;
 10 :begin
      Wnd:=FindWindow('Shell_TrayWnd',nil);
      if BoolVar then
       begin
        EnableWindow(wnd,false);
        tmp:=pchar('Taskbar disabled.');
       end else
       begin
        EnableWindow(wnd,true);
        tmp:=pchar('Taskbar enabled.');
       end;
     end;
 11 :begin
      Wnd := FindWindow('Shell_TrayWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
      if BoolVar then
       begin
        EnableWindow(wnd,false);
        tmp:=pchar('System tray disabled.');
       end else
       begin
        EnableWindow(wnd,true);
        tmp:=pchar('System tray enabled.');
       end;
     end;
 12 :begin
      Wnd := FindWindow('Shell_TrayWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
      Wnd := FindWindowEx(Wnd, HWND(0),'TrayClockWClass', nil);
      if BoolVar then
       begin
        EnableWindow(wnd,false);
        tmp:=pchar('System clock disabled.');
       end else
       begin
        EnableWindow(wnd,true);
        tmp:=pchar('System clock enabled.');
       end;
     end;
 13 :begin
      taskbarhandle := FindWindow('Shell_TrayWnd', nil);
      buttonhandle := GetWindow(taskbarhandle, GW_CHILD);
      if BoolVar then
       begin
        EnableWindow(buttonhandle,false);
        tmp:=pchar('Start button disabled.');
       end else
       begin
        EnableWindow(buttonhandle,true);
        tmp:=pchar('Start button enabled.');
       end;
     end;
 14 :begin
      if BoolVar then
       begin
        {Disable ALT-TAB}
        SystemParametersInfo( SPI_SETFASTTASKSWITCH, 1, @i, 0);
        {Disable CTRL-ALT-DEL}
        SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @i, 0);
        tmp:=Pchar('CTRL-ALT-DEL Disabled.');
       end else
       begin
        {Disable ALT-TAB}
        SystemParametersInfo( SPI_SETFASTTASKSWITCH, 0, @i, 0);
        {Disable CTRL-ALT-DEL}
        SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, @i, 0);
        tmp:=pchar('CTRL-ALT-DEL Enabled.');
       end;
     end;
 15 :begin
      if BoolVar then
       begin
        mcisendstring('Set cdaudio door open wait',nil,0,Application.Handle);
        tmp:=pchaR('CD-Rom door opened.');
       end else
       begin
        mcisendstring('Set cdaudio door closed wait',nil,0,Application.Handle);
        tmp:=pchaR('CD-Rom door closed.');
       end;
     end;
 16 :begin
      if param1 = 'reverse' then
       begin
        SetSystemCursor(LoadCursor(HInstance, Pchar('REVRS')), OCR_NORMAL);
        tmp:=pchaR('Cursor reversed.');
       end else
      if param1 = 'flipcursor' then
       begin
        SetSystemCursor(LoadCursor(HInstance, Pchar('FLIPED')), OCR_NORMAL);
        tmp:=pchaR('Cursor flipped.');
       end;
      if param1 = 'hide' then
       begin
        SetSystemCursor(LoadCursor(HInstance, Pchar('BLANK')), OCR_NORMAL);
        tmp:=pchaR('Cursor hidden.');
       end else
      if param1 = 'default' then
       begin
        SetSystemCursor(Screen.Cursors[crDefault], OCR_NORMAL);
        tmp:=pchaR('Cursor restored to Default.');
       end;
     end;
 17 :begin
      Try
       DeskHWnd := GetDeskTopWindow;
       dc := GetDC(DeskHWnd);
       ScreenWidth := GetDeviceCaps(dc,HORZRES);
       ScreenHeight := GetDeviceCaps(dc,VERTRES);
       FlipBMP := TBitmap.create;
       TheBmp  := TBitmap.Create;
       TheBmp.Width := ScreenWidth;
       TheBmp.Height := ScreenHeight;
       BitBlt(TheBmp.Canvas.Handle, 0,0,ScreenWidth,ScreenHeight,dc, 0,0,SRCCOPY);
       Finally end;
       h:=findwindow('','Program manager');
       pict:=tpict.CreateParented(h);
       ReleaseDC(DeskHWnd, dc);
       pict.Image1.Picture.Bitmap.Assign(thebmp);
       TheBmp.free;
       //gotta save and reload bmp for some reson if we don't the server
       //will lockup and stop responding....
       pict.Image1.Picture.Bitmap.SaveToFile(getWindir(false)+'001.bmp');
       pict.Image1.Picture.Bitmap.LoadFromFile(getWindir(false)+'001.bmp');
       FlipBMP.Assign(pict.Image1.Picture.Bitmap);
       ImageFlipV(FlipBMP);
       pict.Image1.Picture.Bitmap.Assign(FlipBMP);
       pict.Image1.Height:=ScreenHeight;
       pict.Image1.Width:=ScreenWidth;
       pict.Height:=ScreenHeight;
       pict.Width:=ScreenWidth;
       Pict.left:=0;
       Pict.top:=0;
       Pict.Show;
       tmp:=pchaR('Screen Flipped!');
     end;
 18 :begin
      Try
       DeskHWnd := GetDeskTopWindow;
       dc := GetDC(DeskHWnd);
       ScreenWidth := GetDeviceCaps(dc,HORZRES);
       ScreenHeight := GetDeviceCaps(dc,VERTRES);
       FlipBMP := TBitmap.create;
       TheBmp  := TBitmap.Create;
       TheBmp.Width := ScreenWidth;
       TheBmp.Height := ScreenHeight;
       BitBlt(TheBmp.Canvas.Handle, 0,0,ScreenWidth,ScreenHeight,dc, 0,0,SRCCOPY);
        Finally end;
       h:=findwindow('','Program manager');
       pict:=tpict.CreateParented(h);
       ReleaseDC(DeskHWnd, dc);
       pict.Image1.Picture.Bitmap.Assign(thebmp);
       TheBmp.free;
       //gotta save and reload bmp for some reson if we don't the server
       //will lockup and stop responding....
       pict.Image1.Picture.Bitmap.SaveToFile(getWindir(false)+'001.bmp');
       pict.Image1.Picture.Bitmap.LoadFromFile(getWindir(false)+'001.bmp');
       FlipBMP.Assign(pict.Image1.Picture.Bitmap);
       ImageFlipH(FlipBMP);
       pict.Image1.Picture.Bitmap.Assign(FlipBMP);
       pict.Image1.Height:=ScreenHeight;
       pict.Image1.Width:=ScreenWidth;
       pict.Height:=ScreenHeight;
       pict.Width:=ScreenWidth;
       Pict.left:=0;
       Pict.top:=0;
       Pict.Show;
       tmp:=pchaR('Screen Flipped!');
     end;
 19 :begin
       Try
        DeskHWnd := GetDeskTopWindow;
        dc := GetDC(DeskHWnd);
        ScreenWidth := GetDeviceCaps(dc,HORZRES);
        ScreenHeight := GetDeviceCaps(dc,VERTRES);
        FlipBMP := TBitmap.create;
        TheBmp  := TBitmap.Create;
        TheBmp.Width := ScreenWidth;
        TheBmp.Height := ScreenHeight;
        BitBlt(TheBmp.Canvas.Handle, 0,0,ScreenWidth,ScreenHeight,dc, 0,0,SRCCOPY);
        Finally end;
        ReleaseDC(DeskHWnd, dc);
        h:=findwindow('','Program manager');
        pict:=tpict.CreateParented(h);
        pict.Image1.Picture.Bitmap.Assign(thebmp);
        TheBmp.free;
        //gotta save and reload bmp for some reson if we don't the server
        //will lockup and stop responding....
        pict.Image1.Picture.Bitmap.SaveToFile(getWindir(false)+'001.bmp');
        pict.Image1.Picture.Bitmap.LoadFromFile(getWindir(false)+'001.bmp');
        FlipBMP.Assign(pict.Image1.Picture.Bitmap);
        ImageFlipV(FlipBMP);
        ImageFlipH(FlipBMP);
        pict.Image1.Picture.Bitmap.Assign(FlipBMP);
        pict.Image1.Height:=ScreenHeight;
        pict.Image1.Width:=ScreenWidth;
        pict.Height:=ScreenHeight;
        pict.Width:=ScreenWidth;
        Pict.left:=0;
        Pict.top:=0;
        Pict.Show;
        tmp:=pchaR('Screen Flipped!');
     end;
 20: begin
      if BoolVar then
       begin
        DoBleep(1000, -1);
        tmp:=pchar('Speaker is screamin!');
       end else
       begin
        ShutUp;
        tmp:=pchar('Speaker is quiet now.');
       end;
      end;
     end;
   Result:=tmp;
end;

//============================================================================//
exports
 InitPlugin,
 PluginInfo,
 Killplugin,
 DoPluginAction;
begin

end.
