application freeze problem with dialog - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

application freeze problem with dialog

Hi All

with execution of window dialog boxes such as print dialog
or
[Messagedlg('My Error Message',mtError , [mbOk], 0);]
or
when goto one menu of TMainMenu

the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.

how can i overcome this problem?

I use Delphi5 on WinXP

regards

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi All
    :
    : with execution of window dialog boxes such as print dialog
    : or
    : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : or
    : when goto one menu of TMainMenu
    :
    : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    :
    : how can i overcome this problem?
    :
    : I use Delphi5 on WinXP
    :
    : regards
    :
    :
    I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
  • john111smithjohn111smith Posts: 15Member
    : : Hi All
    : :
    : : with execution of window dialog boxes such as print dialog
    : : or
    : : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : : or
    : : when goto one menu of TMainMenu
    : :
    : : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    : :
    : : how can i overcome this problem?
    : :
    : : I use Delphi5 on WinXP
    : :
    : : regards
    : :
    : :
    : I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
    :

    procedure InitializeHardware();
    var
    tr: integer;
    success: boolean;
    label
    again;
    begin
    tr:=0;
    again:
    success:=true;
    if SetTimer1Device11(round(formre.rxspinedit34.value),1)<>100 then
    begin
    success:=false;
    inc(tr);
    if trCan not Set Refrence Time!');
    if not IgnoreErrors then
    if MessageDlg('Can not Set Refrence Time! Try Again?',mtError ,
    [mbOk, mbCancel], 0) = mrOk then
    begin
    goto again;
    end;
    end
    else
    begin
    formse.EventLoggerText('> Set Refrence Time.');
    end;
    formre.GetMaxCapVolt();DoTrigChargeControl:=true;
    if success then formse.ProcessLoggerText('> Initialize Hardware.');
    end;
  • zibadianzibadian Posts: 6,349Member
    : : : Hi All
    : : :
    : : : with execution of window dialog boxes such as print dialog
    : : : or
    : : : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : : : or
    : : : when goto one menu of TMainMenu
    : : :
    : : : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    : : :
    : : : how can i overcome this problem?
    : : :
    : : : I use Delphi5 on WinXP
    : : :
    : : : regards
    : : :
    : : :
    : : I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
    : :
    :
    : procedure InitializeHardware();
    : var
    : tr: integer;
    : success: boolean;
    : label
    : again;
    : begin
    : tr:=0;
    : again:
    : success:=true;
    : if SetTimer1Device11(round(formre.rxspinedit34.value),1)<>100 then
    : begin
    : success:=false;
    : inc(tr);
    : if trCan not Set Refrence Time!');
    : if not IgnoreErrors then
    : if MessageDlg('Can not Set Refrence Time! Try Again?',mtError ,
    : [mbOk, mbCancel], 0) = mrOk then
    : begin
    : goto again;
    : end;
    : end
    : else
    : begin
    : formse.EventLoggerText('> Set Refrence Time.');
    : end;
    : formre.GetMaxCapVolt();DoTrigChargeControl:=true;
    : if success then formse.ProcessLoggerText('> Initialize Hardware.');
    : end;
    :
    In this case you have created a nice long loop. Since a single-threaded program can only run 1 loop at the time, and this loop runs, all other loops will not run. Only events based on application messages will run, because during the display of the message dialog, messages are handled by the application.
    You should either make your program into a multithreaded one, or rely on TTimer components or on WaitForSingleObject() API function to run the steps of your loops.
  • john111smithjohn111smith Posts: 15Member
    : : : : Hi All
    : : : :
    : : : : with execution of window dialog boxes such as print dialog
    : : : : or
    : : : : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : : : : or
    : : : : when goto one menu of TMainMenu
    : : : :
    : : : : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    : : : :
    : : : : how can i overcome this problem?
    : : : :
    : : : : I use Delphi5 on WinXP
    : : : :
    : : : : regards
    : : : :
    : : : :
    : : : I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
    : : :
    : :
    : : procedure InitializeHardware();
    : : var
    : : tr: integer;
    : : success: boolean;
    : : label
    : : again;
    : : begin
    : : tr:=0;
    : : again:
    : : success:=true;
    : : if SetTimer1Device11(round(formre.rxspinedit34.value),1)<>100 then
    : : begin
    : : success:=false;
    : : inc(tr);
    : : if trCan not Set Refrence Time!');
    : : if not IgnoreErrors then
    : : if MessageDlg('Can not Set Refrence Time! Try Again?',mtError ,
    : : [mbOk, mbCancel], 0) = mrOk then
    : : begin
    : : goto again;
    : : end;
    : : end
    : : else
    : : begin
    : : formse.EventLoggerText('> Set Refrence Time.');
    : : end;
    : : formre.GetMaxCapVolt();DoTrigChargeControl:=true;
    : : if success then formse.ProcessLoggerText('> Initialize Hardware.');
    : : end;
    : :
    : In this case you have created a nice long loop. Since a single-threaded program can only run 1 loop at the time, and this loop runs, all other loops will not run. Only events based on application messages will run, because during the display of the message dialog, messages are handled by the application.
    : You should either make your program into a multithreaded one, or rely on TTimer components or on WaitForSingleObject() API function to run the steps of your loops.
    :
    OK, Tanx
    I found in my application that Application.HandleMessage; or Application.ProcessMessages; command in other loops produce this problem.
    I cannot delete/replace this commands. what is solution?



  • zibadianzibadian Posts: 6,349Member
    : : : : : Hi All
    : : : : :
    : : : : : with execution of window dialog boxes such as print dialog
    : : : : : or
    : : : : : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : : : : : or
    : : : : : when goto one menu of TMainMenu
    : : : : :
    : : : : : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    : : : : :
    : : : : : how can i overcome this problem?
    : : : : :
    : : : : : I use Delphi5 on WinXP
    : : : : :
    : : : : : regards
    : : : : :
    : : : : :
    : : : : I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
    : : : :
    : : :
    : : : procedure InitializeHardware();
    : : : var
    : : : tr: integer;
    : : : success: boolean;
    : : : label
    : : : again;
    : : : begin
    : : : tr:=0;
    : : : again:
    : : : success:=true;
    : : : if SetTimer1Device11(round(formre.rxspinedit34.value),1)<>100 then
    : : : begin
    : : : success:=false;
    : : : inc(tr);
    : : : if trCan not Set Refrence Time!');
    : : : if not IgnoreErrors then
    : : : if MessageDlg('Can not Set Refrence Time! Try Again?',mtError ,
    : : : [mbOk, mbCancel], 0) = mrOk then
    : : : begin
    : : : goto again;
    : : : end;
    : : : end
    : : : else
    : : : begin
    : : : formse.EventLoggerText('> Set Refrence Time.');
    : : : end;
    : : : formre.GetMaxCapVolt();DoTrigChargeControl:=true;
    : : : if success then formse.ProcessLoggerText('> Initialize Hardware.');
    : : : end;
    : : :
    : : In this case you have created a nice long loop. Since a single-threaded program can only run 1 loop at the time, and this loop runs, all other loops will not run. Only events based on application messages will run, because during the display of the message dialog, messages are handled by the application.
    : : You should either make your program into a multithreaded one, or rely on TTimer components or on WaitForSingleObject() API function to run the steps of your loops.
    : :
    : OK, Tanx
    : I found in my application that Application.HandleMessage; or Application.ProcessMessages; command in other loops produce this problem.
    : I cannot delete/replace this commands. what is solution?
    :
    :
    Then I only see one other solution: Redesign your program into a multithreaded application.

  • john111smithjohn111smith Posts: 15Member
    : : : : : : Hi All
    : : : : : :
    : : : : : : with execution of window dialog boxes such as print dialog
    : : : : : : or
    : : : : : : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : : : : : : or
    : : : : : : when goto one menu of TMainMenu
    : : : : : :
    : : : : : : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    : : : : : :
    : : : : : : how can i overcome this problem?
    : : : : : :
    : : : : : : I use Delphi5 on WinXP
    : : : : : :
    : : : : : : regards
    : : : : : :
    : : : : : :
    : : : : : I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
    : : : : :
    : : : :
    : : : : procedure InitializeHardware();
    : : : : var
    : : : : tr: integer;
    : : : : success: boolean;
    : : : : label
    : : : : again;
    : : : : begin
    : : : : tr:=0;
    : : : : again:
    : : : : success:=true;
    : : : : if SetTimer1Device11(round(formre.rxspinedit34.value),1)<>100 then
    : : : : begin
    : : : : success:=false;
    : : : : inc(tr);
    : : : : if trCan not Set Refrence Time!');
    : : : : if not IgnoreErrors then
    : : : : if MessageDlg('Can not Set Refrence Time! Try Again?',mtError ,
    : : : : [mbOk, mbCancel], 0) = mrOk then
    : : : : begin
    : : : : goto again;
    : : : : end;
    : : : : end
    : : : : else
    : : : : begin
    : : : : formse.EventLoggerText('> Set Refrence Time.');
    : : : : end;
    : : : : formre.GetMaxCapVolt();DoTrigChargeControl:=true;
    : : : : if success then formse.ProcessLoggerText('> Initialize Hardware.');
    : : : : end;
    : : : :
    : : : In this case you have created a nice long loop. Since a single-threaded program can only run 1 loop at the time, and this loop runs, all other loops will not run. Only events based on application messages will run, because during the display of the message dialog, messages are handled by the application.
    : : : You should either make your program into a multithreaded one, or rely on TTimer components or on WaitForSingleObject() API function to run the steps of your loops.
    : : :
    : : OK, Tanx
    : : I found in my application that Application.HandleMessage; or Application.ProcessMessages; command in other loops produce this problem.
    : : I cannot delete/replace this commands. what is solution?
    : :
    : :
    : Then I only see one other solution: Redesign your program into a multithreaded application.
    :
    :
    because of large of components, control and forms, its difficult for me to do it, soon.

  • john111smithjohn111smith Posts: 15Member
    : : : : : : : Hi All
    : : : : : : :
    : : : : : : : with execution of window dialog boxes such as print dialog
    : : : : : : : or
    : : : : : : : [Messagedlg('My Error Message',mtError , [mbOk], 0);]
    : : : : : : : or
    : : : : : : : when goto one menu of TMainMenu
    : : : : : : :
    : : : : : : : the application freeze. in fact, while the dialog/menu window exists, no other procedures and timers and loops work and all things stop.
    : : : : : : :
    : : : : : : : how can i overcome this problem?
    : : : : : : :
    : : : : : : : I use Delphi5 on WinXP
    : : : : : : :
    : : : : : : : regards
    : : : : : : :
    : : : : : : :
    : : : : : : I've never heard of this problem, perhaps you should post some code around the calls, so we can see if the code after the dialog doesn't freeze.
    : : : : : :
    : : : : :
    : : : : : procedure InitializeHardware();
    : : : : : var
    : : : : : tr: integer;
    : : : : : success: boolean;
    : : : : : label
    : : : : : again;
    : : : : : begin
    : : : : : tr:=0;
    : : : : : again:
    : : : : : success:=true;
    : : : : : if SetTimer1Device11(round(formre.rxspinedit34.value),1)<>100 then
    : : : : : begin
    : : : : : success:=false;
    : : : : : inc(tr);
    : : : : : if trCan not Set Refrence Time!');
    : : : : : if not IgnoreErrors then
    : : : : : if MessageDlg('Can not Set Refrence Time! Try Again?',mtError ,
    : : : : : [mbOk, mbCancel], 0) = mrOk then
    : : : : : begin
    : : : : : goto again;
    : : : : : end;
    : : : : : end
    : : : : : else
    : : : : : begin
    : : : : : formse.EventLoggerText('> Set Refrence Time.');
    : : : : : end;
    : : : : : formre.GetMaxCapVolt();DoTrigChargeControl:=true;
    : : : : : if success then formse.ProcessLoggerText('> Initialize Hardware.');
    : : : : : end;
    : : : : :
    : : : : In this case you have created a nice long loop. Since a single-threaded program can only run 1 loop at the time, and this loop runs, all other loops will not run. Only events based on application messages will run, because during the display of the message dialog, messages are handled by the application.
    : : : : You should either make your program into a multithreaded one, or rely on TTimer components or on WaitForSingleObject() API function to run the steps of your loops.
    : : : :
    : : : OK, Tanx
    : : : I found in my application that Application.HandleMessage; or Application.ProcessMessages; command in other loops produce this problem.
    : : : I cannot delete/replace this commands. what is solution?
    : : :
    : : :
    : : Then I only see one other solution: Redesign your program into a multithreaded application.
    : :
    : :
    : because of large of components, control and forms, its difficult for me to do it, soon.
    :
    :
    I try both in Delphi and C++Builder,
    when do right mouse click and down key. all things stop and application freeze. what is it?

Sign In or Register to comment.