Announcement

Collapse
No announcement yet.

A window that outlives the .exe that created it

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

  • A window that outlives the .exe that created it

    I want to create a window with some information in it that is on a timer. When the timer expires the window is destroyed. However, the .exe that created it will close long befor the window times out.

    I think I need to initiate a thread in the .exe. Would this do it?

    Then when I try to send a string to the thread I get compile errors:
    Code:
    FUNCTION ConfirmAction(dStr AS STRING) AS LONG
    LOCAL Ht AS LONG, hDlg AS LONG
        Ht = (TALLY(dStr, $CRLF)+1)*9 + 24
        DIALOG NEW 0 ,"Compile Information", , , 110, Ht, %WS_POPUP OR %WS_DLGFRAME TO hDlg
        CONTROL ADD LABEL,   hDlg, 110, dStr,   4,     4, 105,  Ht-5,
        CONTROL ADD BUTTON,  hDlg, 102, "OK",        35, Ht-18,  40,    16, 1
        DIALOG SHOW MODELESS hDlg 
    
    END FUNCTION   
    '--------------------------------------------------------------
    PBMAIN
    '
    '
    '
    THREAD CREATE ConfirmAction(DisplayStr) TO i
    '
    '
    End Function
    ------------------
    Kind Regards
    Mike
    Last edited by Gary Beene; 12 Jul 2014, 07:56 PM. Reason: Code: tags

  • #2
    You have a few problems with this implementation...

    1. An EXE can't stop before it's window do... that is, any remaining windows will be automatically destroyed by Windows when PBMAIN/WINMAIN exits. The disk image of the EXE is also locked while the EXE is still running.

    2. A thread can only take a single BYVAL 32-bit LONG or DWORD. To pass a string, you'll need to pass a pointer to the string data (or handle); and assign DWORD/LONG value to a local pointer of the appropriate data type.

    3. Message pumps are thread-specific, so if you create a MODELESS dialog in a thread, that thread must contain it's own DIALOG DOEVENTS loop. A MODAL dialog is much easer in this respect, since it contains it's own message pump.

    In summary, I think you may need to have a rethink of the application design. Can you describe what it is you wish to achieve, and maybe we can suggest alternative methods to achieve the results you require.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      OK sure Lance,

      I am working with Semens Excellent Wrapper and now the very cool Jellyfish Editor.

      With the wrapper I can add CRCs, INCLUDE resources etc etc but I want to see a confirmation window of the additional processes the wrapper executed.

      When I hit the compile button on Jellyfish, it calls MyWrapper.exe (disguised as PBCC.exe) which processes a few things and then calls PBDll.exe which compiles the .bas file. The Shell is Syncronous so the wrapper waits for the compiler to finish. Once the compiler is finished the wrapper makes the CRC, compresses the file etc and then returns control to Jellyfish.

      In Jellyfish I want to continue working, BUT I want a small window to remain for about 5 secs that tells me what just happened in the wrapper. I do NOT want to have to click OK everytime I do a compile. If the window times out I can ignore it when I dont need to see what happened and just carry on working.

      SO I guess the last thing the wrapper could do is shell to a little app asynchonously that reads a .txt file (like the .log file) with the pertinent info in it and quits when done, KILLing the .log file in the process ?

      Seems like a klunky way to go tho ...



      ------------------
      Kind Regards
      Mike

      Comment


      • #4
        Hey, if it works, where is the problem?

        Unless you can add a modeless window to Jellyfish that does what you want, I can't see an easier way to handle the job.

        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          Write a program to launch the "confirmation Window" in a separate process (either CreatePRocess or SHELL). Those spawned processes literally have a "life of their own."

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            That is exactly what Mike anticipated...

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              How about if i SHELL to the little display app with a command line that contains the text to display?

              ------------------
              Kind Regards
              Mike

              Comment


              • #8
                Sounds reasonable, but there is maximum limit to the command-line length (off hand I don't recall the exact limit, but there certainly is one!)

                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment

                Working...
                X