/ *DLL 主 体 代 码
* 定 义DLL 公 用 变 量
*g_CommonAVI 对Animate 控 件
动 画 类 型 索 引
*gi_Canceled Button_Cancel
按 钮 是 否 被 选 择 过
*gi_AVIType 要 显 示 的 动 画 类 型,
由DLL 输 出 函 数 做 为 参 数 输 入
*gi_RequestClose 请 求 动 画 线 程 关 闭 标 志
*gi_WindowActive 动 画 窗 口 所 处 的 状 态
*lpsWinTitle 动 画 窗 体 的 标 题,
由DLL 输 出 函 数 做 为 参 数 输 入
*/
TCommonAVI g_CommonAVI[]={
aviNone, aviFindFolder,
aviFindFile, aviFindComputer,
aviCopyFiles, aviCopyFile,
aviRecycleFile, aviEmptyRecycle,
aviDeleteFile
};
int gi_Canceled=0,gi_AVIType=0;
int gi_RequestClose=0,gi_WindowActive=0;
char lpsWinTitle[256];
HWND hWndParent=NULL;
/ * 定 义DLL 输 出 函 数 */
extern “C" __declspec(dllexport) int pascal Dll
EntryPoint(HINSTANCE hinst, unsigned
long reason, void *);
extern “C" __declspec(dllexport) int pascal
ShowStatus Window
(int AVIType,LPSTR WinTitle,long hWnd);
extern “C" __declspec(dllexport)
int pascal GetStatus(int ai_CloseWin);
extern “C" __declspec(dllexport)
int pascal CloseStatusWindow();
/ * 定 义 线 程TformThread: */
class TFormThread : public TThread{
public: // User declarations
__fastcall TFormThread(bool CreateSuspended);
void __fastcall Execute(void);
};
__fastcall TFormThread::
TFormThread(bool CreateSuspended):
TThread(CreateSuspended){
}
/ * 动 画 线 程 执 行 代 码,
动 画 窗 体 的 定 时 器 控 件 会 关 闭 它,
清 除 窗 体 存 在 标 志 后 结 束 线 程 的 运 行
*/
void __fastcall TFormThread::Execute(void){
gi_WindowActive=1;
StatusForm=new TStatusForm(NULL);
StatusForm ->Caption=lpsWinTitle;
StatusForm ->ShowModal();
gi_WindowActive=0;
delete StatusForm;
gi_RequestClose=0;
}
/ * 定 义 一 个 线 程 实 例 指 针 */
TFormThread *FormThread;
/ * 输 出 函 数 代 码 实 现 部 分
* DllEntryPoint 32 位DLL 入 口
* ShowStatusWindow 显 示 动 画 窗 口,
它 通 过 创 建 一 个 线 程 来 创 建 窗 口,
避 免 由 于 窗 口 的MODAL 属 性 而 使
控 制 权 不 能 及 时 的 返 还 给 调 用 者
* GetStatus 取 得“ 取 消” 状 态,
即 用 户 有 没 有 选 择“ 取 消” 按 钮
* CloseStatusWindow 关 闭 动 画 窗 口,
*/
__declspec(dllexport) int WINAPI DllEntryPoint
(HINSTANCE hinst, unsigned long reason, void *)
{
return 1;
}
__declspec(dllexport) int pascal ShowStatusWindow
(int AVIType,LPSTR WinTitle,long hWnd){
hWndParent=(HWND)hWnd;
memset(lpsWinTitle,0,sizeof(lpsWinTitle));
strncpy(lpsWinTitle,WinTitle,sizeof(lpsWin Title) -1);
if (AVIType>0 & & AVIType<=8) gi_AVIType="AVIType;"
FormThread="new" TFormThread(true);
FormThread ->Priority = tpNormal;
FormThread ->Resume();
}
__declspec(dllexport) int pascal GetStatus
(int ai_CloseWin){
if (gi_Canceled)
if (gi_WindowActive){
gi_RequestClose=1;
while(gi_RequestClose);
}
return gi_Canceled;
}
__declspec(dllexport) int pascal CloseStatusWindow(){
if (gi_WindowActive){
gi_RequestClose=1;
while(gi_RequestClose);
}
return gi_Canceled;
} |