如圖,關閉VC程序時就彈出(而且得點擊運行窗口的關閉按鈕兩次才彈出),選擇其中的關閉程序,程序才能正常關閉。程序中有一個按鈕的響應函數是個死循環,我把循環條件startstop在關閉函數DestroyWindow和Onclose函數中設置為否,也還是如常不能一下就關閉掉。
程序如下:
void CTestDlg::Onoriginalimage()
{
// TODO: Add your control notification handler code here
while (startstop)
{
grab_image_start(AcqHandle, -1);
grab_image_async(&Image, AcqHandle, -1);
if (HDevWindowStack::IsOpen())
set_color(HDevWindowStack::GetActive(),"green");
if (HDevWindowStack::IsOpen())
set_draw(HDevWindowStack::GetActive(),"margin");
if (HDevWindowStack::IsOpen())
set_line_width(HDevWindowStack::GetActive(),3);
find_bar_code(Image, &SymbolRegions, BarCodeHandle, "auto", &DecodedDataStrings);
count_obj(SymbolRegions, &Number);
str2="";
for (k=0 ;k<=Number-1 ;k++)
str2=str2+DecodedDataStrings[k]+" ";
GetDlgItem(IDC_str)->SetWindowText(str2);
str.Format(_T("%d"),Number[0]);
GetDlgItem(IDC_string)->SetWindowText(str);
disp_obj(Image, WindowHandle);
disp_obj(SymbolRegions, WindowHandle);
}
}
在循環體內添加如下代碼即可:
if ( ::PeekMessage( &message, NULL, NULL,NULL, PM_REMOVE ) )
{
::TranslateMessage( &message );
::DispatchMessage( &message );