一般用在从资源文件建立的窗体上<br>下面的例子需要WINXP才能完全体现<br>先定义个RC文件<br>100 DIALOG 0, 0, 160, 50<br>STYLE DS_SETFONT | WS_CAPTION | WS_POPUP | WS_DLGFRAME | NOT WS_SYSMENU<br>CAPTION "载入索引"<br>LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED<br>FONT 9, "宋体"<br>{<br> CONTROL "Animate1",1001,"SysAnimate32",0x00000006,15,10,0,0<br> CTEXT "请稍候...", -1, 12, 12, 110, 8<br> CONTROL "ProgressBar1",1002,"msctls_progress32",WS_BORDER | 0x00000001,5,32,150,10<br>}<br><br><br>然后在程序需要时<br>const<br> PBS_MARQUEE = $08;<br> PBM_SETMARQUEE = WM_USER + 10;<br>var<br>hwndDlg : HWND;<br>Modulehandle : HMODULE;<br>begin<br>//载入资源窗体<br>//DialogProc是回掉函数,可以参考SDK的写法<br>hwndDlg:=CreateDialog(HInstance,MAKEINTRESOURCE(100),self.Handle,@DialogProc);<br>Modulehandle:=LoadLibrary('shell32.dll');<br>FreeLibrary(Modulehandle);<br>//SendDlgItemMessage就是getDlgITem和sendmessage结合<br>//对这个窗体1001的控件设置,这里是装载一个动画<br>SendDlgItemMessage(hwndDlg,1001,ACM_OPENA,Modulehandle,151);<br>//对窗体上1002的控件进行设置,设置为winxp支持的滚动条<br>SetWindowLong(GetDlgItem(hwndDlg,1002),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,1002),GWL_STYLE) or PBS_MARQUEE);<br>SendDlgItemMessage(hwndDlg,1002,PBM_SETMARQUEE,1,70);<br>//显示这个窗体<br>ShowWindow(hwndDlg,SW_SHOW);