Announcement

Collapse
No announcement yet.

Process Doesn't Stop on "X"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    guess I was guilty of a "Window-centric" attitude - when the last window is destroyed, the program is over ...
    Not true, even if you are thinking "window-centric."

    and the compiler was supposed to add code to shut down the process.
    Oh, but it does add such code.... when you reach the logical end of WinMain() it adds ExitProcess().

    MCM

    Leave a comment:


  • Gary Beene
    replied
    Thanks everyone,

    I guess I was guilty of a "Window-centric" attitude - when the last window is destroyed, the program is over and the compiler was supposed to add code to shut down the process.

    But that's not the case and not even desired since many apps don't even need/want a window.

    Leave a comment:


  • Manuel Valdes
    replied
    Gary:

    This subject was posted some weeks ago. I suggested to use the Device Context (DC) in every nested loop to enable the programm to detect whether the graphic window was closed. Even though was deemed ugly, it works.

    Regards,

    Code:
     
    GLOBAL hdcon AS LONG
     
    Function PBMain () As Long
      Local hWin as Dword
    Graphic Window "Box", 300, 300, 130, 130 To hWin
      While 1
        GRAPHIC GET DC TO hdcon
        IF hdcon = 0 THEN EXIT LOOP
      Wend
    End Function
    Last edited by Manuel Valdes; 17 Aug 2009, 10:42 AM.

    Leave a comment:


  • Michael Mattias
    replied
    >MCM, I guess I was expecting the loops to be exited when the "X" was pressed.

    Huh? Why would it do that?

    How then could you EVER create a program which gets input from a GRAPHIC Window, then dismisses the window and goes on to "do something" with that input?

    I mean, we've all written a loop like that at one time or another. And I will bet a lot money we've all had exactly the same reaction, too:

    MCM

    Leave a comment:


  • Dave Biggs
    replied
    Gary,

    Think of the Graphic Window as a Modeless Dialog that your program (Function PBMain) has created.
    Even if it is closed your program will continue to run until it's natural end - by reaching the End Function statement.

    Leave a comment:


  • Mike Doty
    replied
    Thanks for the info, though not using the feature right now.
    Code:
    FUNCTION PBMAIN () AS LONG
      LOCAL hWin AS DWORD
      GRAPHIC WINDOW "Box", 300, 300, 130, 130 TO hWin
      GRAPHIC ATTACH hWin, 0
      DO
        SLEEP 1000
        GRAPHIC GET CLIENT TO ncWidth!, ncHeight!
        IF ncWidth! = 0 THEN EXIT DO
        BEEP
      LOOP
    END FUNCTION

    Leave a comment:


  • Paul Dixon
    replied
    Gary,
    the code that looks after the window is written by you if you use SDK programming and you'd then trap the appropriate message in the message loop and flag that your program loop should quit.
    For DDT programming, as in this case, the compiler will generate the code to do the basic maintenance of the graphic window and you'd need to intercept messages by subclassing the window to see if the window has been closed.
    I'd think it's easier, in this case, to just check if the window still exists unless you need to intercept other messages as well.

    Paul

    Leave a comment:


  • Gary Beene
    replied
    Hmm... same thing here. "X" closes the window but not the process.

    Code:
    Function PBMain () As Long
      Local hWin As Dword, i As Long, j As Long
      Graphic Window "Box", 300, 300, 130, 130 To hWin
      For i = 1 To 1000000
         For j = 1 To 1000000
            '
         Next j
      Next i
    End Function
    MCM, I guess I was expecting the loops to be exited when the "X" was pressed.

    Any place you've seen at MSDN that might discuss this?

    Leave a comment:


  • Michael Mattias
    replied
    >Is is supposed to work that way?
    Well...
    Code:
     While 1
     Wend
    .. usually does not do a whole lot until one does not equal zero. And as a bonus, it is context-agnostic.

    Maybe something like
    Code:
     WHILE ISWIN (hWin) 
     WEND
    .. would exit the endless loop when 'hWin' is destroyed and no longer passes the 'smell test' as a valid window.



    MCM

    Leave a comment:


  • Gary Beene
    started a topic Process Doesn't Stop on "X"

    Process Doesn't Stop on "X"

    When I run this code and then "X" out of it, the process doesn't go away. I have to open Window Task Manager to stop it.

    Code:
    Function PBMain () As Long
      Local hWin As Dword
      Graphic Window "Box", 300, 300, 130, 130 To hWin
      While 1
      Wend
    End Function
    Is is supposed to work that way?
Working...
X