user-0 提问: C，文件简单加密时，自制伪进度条不能实时显示的问题。

回复:
user: user-0
content: 引用 13 楼 zhao4zhong1 的回复:查MSDN是Windows程序员必须掌握的技能之一。  英语也是一门计算机语言的说。  恩，消息机制一直有点迷，我会好好看的。

user: user-1
content: 循环未退出前，WM_SETTEXT消息都缓存在the application queue中。

user: user-1
content: 查MSDN是Windows程序员必须掌握的技能之一。  英语也是一门计算机语言的说。

user: user-0
content: 引用 11 楼 zhao4zhong1 的回复:SetDlgItemText The SetDlgItemText function sets the title or text of a control in a dialog box.   BOOL SetDlgItemText(   HWND hDlg,         // handle of dialog box   int nIDDlgItem,    // identifier of control   LPCTSTR lpString   // text to set );   Parameters hDlg  Identifies the dialog box that contains the control.  nIDDlgItem  Identifies the control with a title or text that is to be set.  lpString  Pointer to the null-terminated string that contains the text to be copied to the control.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero. To get extended error information, call GetLastError.   Remarks The SetDlgItemText function sends a WM_SETTEXT message to the specified control.   QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winuser.h.   Import Library: Use user32.lib.   Unicode: Implemented as Unicode and ANSI versions on Windows NT.  See Also Dialog Boxes Overview, Dialog Box Functions, GetDlgItemInt, GetDlgItemText, SetDlgItemInt, WM_SETTEXT     UpdateWindow The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty. The function sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue. If the update region is empty, no message is sent.   BOOL UpdateWindow(   HWND hWnd   // handle of window );   Parameters hWnd  Handle to the window to be updated.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero.   Windows NT: To get extended error information, callGetLastError.  QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winuser.h.   Import Library: Use user32.lib.  See Also Painting and Drawing Overview, Painting and Drawing Functions, ExcludeUpdateRgn, GetUpdateRect, GetUpdateRgn, InvalidateRect, InvalidateRgn, WM_PAINT  我猜一下，是不是当前按钮事件未结束，输出的进度都在队列里，并没有提取出来？

user: user-0
content: 引用 8 楼 zhao4zhong1 的回复:深究的话，建议结合Spy++软件的使用，看看《深入浅出MFC》中分析Windows消息流向的相关章节。  嗯嗯，谢谢赵老师

user: user-1
content: SetDlgItemText The SetDlgItemText function sets the title or text of a control in a dialog box.   BOOL SetDlgItemText(   HWND hDlg,         // handle of dialog box   int nIDDlgItem,    // identifier of control   LPCTSTR lpString   // text to set );   Parameters hDlg  Identifies the dialog box that contains the control.  nIDDlgItem  Identifies the control with a title or text that is to be set.  lpString  Pointer to the null-terminated string that contains the text to be copied to the control.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero. To get extended error information, call GetLastError.   Remarks The SetDlgItemText function sends a WM_SETTEXT message to the specified control.   QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winuser.h.   Import Library: Use user32.lib.   Unicode: Implemented as Unicode and ANSI versions on Windows NT.  See Also Dialog Boxes Overview, Dialog Box Functions, GetDlgItemInt, GetDlgItemText, SetDlgItemInt, WM_SETTEXT     UpdateWindow The UpdateWindow function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty. The function sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue. If the update region is empty, no message is sent.   BOOL UpdateWindow(   HWND hWnd   // handle of window );   Parameters hWnd  Handle to the window to be updated.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero.   Windows NT: To get extended error information, callGetLastError.  QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Requires version 1.0 or later.   Header: Declared in winuser.h.   Import Library: Use user32.lib.  See Also Painting and Drawing Overview, Painting and Drawing Functions, ExcludeUpdateRgn, GetUpdateRect, GetUpdateRgn, InvalidateRect, InvalidateRgn, WM_PAINT

user: user-1
content: Multiple Threads in the User Interface http://msdn.microsoft.com/zh-cn/library/ms810439.aspx

user: user-1
content: 深究的话，建议结合Spy++软件的使用，看看《深入浅出MFC》中分析Windows消息流向的相关章节。

user: user-0
content: 引用 4 楼 user-2 的回复:没看代码  但是猜你没用多线程  恩，新手，才学API，还没看到多线程，学了一些东西，所以只是想写个东西贯通一下。

user: user-0
content: 引用 5 楼 zhao4zhong1 的回复:SetDlgItemText(hwnd, 1006, jdt); UpdateWindow(hwnd);//试试看 不行的话： SetDlgItemText(hwnd, 1006, jdt); UpdateWindow(hwnd); MSG msg; if (GetMessage(&msg,NULL,0,0)) {     TranslateMessage(&msg);     DispatchMessage(&msg); } //再试试看     谢谢谢谢，用了第一个果然好了，就是缺少窗口重绘吗，但是为什么有的可以不用重绘也能显示正常。有的又会卡死。重绘作用除了改变窗口大小时还有什么用啊。。

user: user-1
content: SetDlgItemText(hwnd, 1006, jdt); UpdateWindow(hwnd);//试试看 不行的话： SetDlgItemText(hwnd, 1006, jdt); UpdateWindow(hwnd); MSG msg; if (GetMessage(&msg,NULL,0,0)) {     TranslateMessage(&msg);     DispatchMessage(&msg); } //再试试看

user: user-2
content: 没看代码  但是猜你没用多线程

user: user-0
content: 我是想通过一个只读的文本框填充=号来实现。但是稍微大一点点的文件就没用，界面还是卡主，进度条无填充，直到加密结束，就一次填充完了。

user: user-0
content: 这是fen()的主要代码  struct stat stbuff;                 //以下是fen()的主要部分，前面省去各种初始化。 		stat(sinpdir,&stbuff); 		flen = stbuff.st_size; 		bl = flen / 26;     //26长度 		int i=0; 		while ((enreadcount = fread(enbuffer, 1, enkeylen, pi))>0){     			for (ensc = 0; ensc<enreadcount; ensc++){  				enbuffer[ensc] ^= enkey[ensc];  			} 			fwrite(enbuffer, enreadcount, 1, po); 		 			tj = tj + enreadcount;      //统计实际读取数 			if (tj>bl){             //进度输出部分，超过1/26，添加填充物，输出，清零。 				jdt[i] = '=';    //以‘=’作为进度填充物 				i++; 				tj = 0; 				SetDlgItemText(hwnd, 1006, jdt); 			}	 		}

user: user-0
content: 这是按钮调动的主要代码  case IDC_OK:{ 					    					   int rbc; 					   TCHAR dir[256]; 					   TCHAR jdt1[256]; 					    					   memset(jdt1, '\0', sizeof(jdt1)); 					   HWND hwnd1; 					   int i; 					   int i1; 					   hwnd1 = GetDlgItem(hwnd, IDC_LIEBIAO); 					    					   int ic; 					   ic = ListBox_GetCount(hwnd1); 					   i = 27 / ic;    //27进度长度，具体见fen() 					   i1 = 0; 					   int n = 1; 					    					   for (ic--; ic >= 0; ic--){ 						   memset(dir, '\0', sizeof(dir)); 						   ListBox_GetText(hwnd1, ic, dir); 						   if (0 != fen(hwnd, dir, rbc)){    //fen()，句柄，路径字符串，rbc无关紧要 							   MessageBox(hwnd, TEXT("失败，请检查"), TEXT("错误"), MB_OK | MB_ICONWARNING); 							   break; 						   } 						   info(hwnd, dir, 3); 						    						    						   i = i*n;               //以下文件个数的进度 						   while (i1 < i){ 							   jdt1[i1] = '='; 							   i1++; 						   } 						   n++; 						   SetDlgItemText(hwnd, IDC_ZONG, jdt1); 					   } 					   break; 					 }