This commit was manufactured by cvs2svn to create branch 'captive'.
[reactos.git] / subsys / system / explorer / winefile / plugins / ex_clock.c
1 //
2 // Explorer Clock Plugin
3 // 
4 // Alexander Ciobanu
5 // alex@prodidactica.md
6 //
7
8 #include <windows.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "ex_bar.h"
13
14 HWND Static;
15 HWND Wnd;
16 char locstr[20];
17
18 int ex_x1;
19 int ex_y1;
20 int ex_dx;
21 int ex_dy;
22
23 // Initialize the plugin
24 //
25 static int InitializePlugIn(HWND ExplorerHandle)
26 {
27  SYSTEMTIME systime;
28  TCHAR TimeStr[20];
29
30   fprintf(stderr,"EX_CLOCK : INITIALIZE PLUGIN call\n");
31
32  SetTimer(ExplorerHandle,500,1000,NULL);
33   GetLocalTime(&systime);
34   wsprintf(TimeStr,TEXT("%02d:%02d"),systime.wHour,systime.wMinute);
35
36  Static = CreateWindow(
37     TEXT("STATIC"),TimeStr,WS_VISIBLE | WS_CHILD | SS_CENTER | SS_SUNKEN,
38       ex_dx+ex_x1-100, 4, 50, ex_dy-14, ExplorerHandle, NULL, 
39      (HINSTANCE) GetWindowLong(ExplorerHandle, GWL_HINSTANCE),NULL);
40
41   return 1;
42 }
43
44 // Get Information about the plugin
45 //
46 char* PlugInInfo(int InfoNmbr)
47 {
48   static char Info[256];
49
50   fprintf(stderr,"EX_CLOCK : INFORMATION PLUGIN call\n");
51
52   switch(InfoNmbr)
53   {
54     case 0:                                   // PlugIn Name
55      strcpy(Info,"ReactOSClock");
56      break;
57
58     case 1:                                   // Version
59      strcpy(Info,"0.1");
60      break;
61
62     case 2:                                   // Vendor name
63      strcpy(Info,"ReactOS team");
64      break;
65
66     default:                                  // Default : Error
67      strcpy(Info,"-");
68      break;
69  
70   }
71
72   return Info;
73 }
74
75 // Reload plugin's configuration
76 //
77 static int ReloadPlugInConfiguration()
78 {
79   fprintf(stderr,"EX_CLOCK : RELOAD PLUGIN COFIGURATION call\n");
80   return 1;
81 }
82
83 // Quit plugin
84 //
85 static int QuitPlugIn()
86 {
87   fprintf(stderr,"EX_CLOCK : QUIT PLUGIN call\n");
88   return 1;
89 }
90
91 // Callback procedure for plugin
92 //
93 static int PlugInMessageProc(HWND PlgnHandle, UINT Msg, WPARAM wParam, LPARAM lParam)
94 {
95  static int blink = 0;
96
97  SYSTEMTIME systime;
98  TCHAR TimeStr[20];
99
100  // The plugin must decide whatever the handle passed is created by it !
101  // Sorry for bad english :-)
102  //
103  switch(Msg)
104   {
105    case WM_TIMER:
106                 GetLocalTime(&systime);
107                 wsprintf(TimeStr, TEXT("%02d%c%02d"), systime.wHour, blink?':':' ', systime.wMinute);
108                 blink ^= 1;
109                 SendMessage(Static,WM_SETTEXT,0,(LPARAM)TimeStr);
110     break;
111   }
112
113   return 1;
114 }
115
116 static int ExplorerInfo(EXBARINFO* info)
117 {
118   fprintf(stderr,"EX_CLOCK : EXPLORER INFO PLUGIN call\n");
119   ex_x1=info->x;
120   ex_y1=info->y;
121   ex_dx=info->dx;
122   ex_dy=info->dy;
123   return 1;
124 }
125
126 #ifdef _PLUGIN
127 BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
128 {
129   fprintf(stderr,"EX_CLOCK PlugIn loaded succesefully\n");
130   return TRUE;
131 }
132 #endif
133
134
135 struct PluginCalls plugincalls_Clock = {
136         InitializePlugIn,
137         QuitPlugIn,
138         ReloadPlugInConfiguration,
139         PlugInInfo,
140         ExplorerInfo,
141         PlugInMessageProc
142 };
143