Loading ...
Sorry, an error occurred while loading the content.
 

XPs: modeless dialog

Expand Messages
  • Christopher Golden
    I m wondering how one can go about adding a modeless dialog to CC2 via an XP. The XP command I m working on can take a long time (a few seconds) to do some
    Message 1 of 6 , Jul 16, 2000
      I'm wondering how one can go about adding a modeless dialog
      to CC2 via an XP. The XP command I'm working on can take a
      long time (a few seconds) to do some calculations, and I'd
      like to put up a simple dialog with a progress bar that can
      give the user visual feedback (i.e. let the user know that
      CC2 is working on the problem, and has not locked up) while
      doing the number-crunching.

      Obviously I can do all the Windows API stuff without a pro-
      blem, but what I foresee as an issue is the need to tie the
      new dialog into the CC2 message loop. That is, if I can't
      let CC2 know that I'm creating a modeless dialog, it won't
      know to forward Windows messages intended for that dialog
      along to it.

      The other alternative, I suppose, would be to spawn off a
      separate thread that runs the progress bar dialog itself,
      but that seems wasteful in this case. What would the
      canonical way of putting up a modeless dialog be when
      adding one to an XP?

      Thanks!
      Christopher Golden
      golden@...
    • Peter Olsson
      I don t think there is any support for modeless dialogs in CC2, so you will have to do with Windows API functions. As an alternative you can use the message
      Message 2 of 6 , Jul 17, 2000
        I don't think there is any support for modeless dialogs in CC2, so you will have to do with Windows API functions. As an alternative you can use the message area on the status bar. There are two ways to write to the message area:

        1. FormSt(Pointer to packet, FD_Status)
        2. StatusMsg("Text");

        To clear the area after you call StatusMsg(NULL);

        This is how CC2 normally displays working progress.

        Peter
      • Simon Rogers
        A percentage in the status indicator would be the usual approach. See Peter s PNG export. Simon
        Message 3 of 6 , Jul 17, 2000
          A percentage in the status indicator would be the usual approach. See
          Peter's PNG export.
          Simon

          > -----Original Message-----
          > From: Christopher Golden [mailto:golden@...]
          > Sent: 16 July 2000 18:35
          > To: cc2-dev-l@egroups.com
          > Subject: [cc2-dev-l] XPs: modeless dialog
          >
          >
          > I'm wondering how one can go about adding a modeless dialog
          > to CC2 via an XP. The XP command I'm working on can take a
          > long time (a few seconds) to do some calculations, and I'd
          > like to put up a simple dialog with a progress bar that can
          > give the user visual feedback (i.e. let the user know that
          > CC2 is working on the problem, and has not locked up) while
          > doing the number-crunching.
          >
          > Obviously I can do all the Windows API stuff without a pro-
          > blem, but what I foresee as an issue is the need to tie the
          > new dialog into the CC2 message loop. That is, if I can't
          > let CC2 know that I'm creating a modeless dialog, it won't
          > know to forward Windows messages intended for that dialog
          > along to it.
          >
          > The other alternative, I suppose, would be to spawn off a
          > separate thread that runs the progress bar dialog itself,
          > but that seems wasteful in this case. What would the
          > canonical way of putting up a modeless dialog be when
          > adding one to an XP?
          >
          > Thanks!
          > Christopher Golden
          > golden@...
          >
          > ------------------------------------------------------------------------
          > BTW: Did you buy that new car yet?
          > If not, check this site out.
          > They're called CarsDirect.com and it's a pretty sweet way to buy a car.
          > http://click.egroups.com/1/6847/0/_/373793/_/963768919/
          > ------------------------------------------------------------------------
          >
          > To Post a message, send it to: cc2-dev-l@...
          > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...
          >
          >
        • Bronikowski, Joe
          ... Actually, until your XP function returns, CC2 s message loop isn t running anyway. You could just SendMessage to the modeless dialog when you want it to
          Message 4 of 6 , Jul 17, 2000
            Christopher Golden wrote:

            > new dialog into the CC2 message loop. That is, if I can't
            > let CC2 know that I'm creating a modeless dialog, it won't
            > know to forward Windows messages intended for that dialog
            > along to it.

            Actually, until your XP function returns, CC2's message loop isn't
            running anyway. You could just SendMessage to the modeless dialog
            when you want it to repaint, etc. Or, if you want CC2 to be
            repainting etc while your code is running, occasionally run a
            PeekMessage loop to flush all messages:

            while (PeekMessage (&msg, hCC2, 0, 0, PM_REMOVE)
            DispatchMessage (&msg);

            If you're paranoid, limit the number of messages processed:

            for (i=0; (i < 20) && PeekMessage (&msg, hCC2, 0, 0, PM_REMOVE); i++)
            DispatchMessage (&msg);

            (these are from memory, actual usage may differ slightly.) You could
            include doing this for your modeless dialog too if you want it to process
            repaints etc. on the fly.

            Now, if you really mean you want a modeless dialog to remain
            AFTER your XP function returns, then you're in a whole different
            ball game :-)

            BTW So far I've found this to accurately provide CC2's hwnd:

            HWND hCC2 = GetFocus ();

            (before you do anything to change focus, of course!)

            Joe B
          • Christopher Golden
            ... Good point; I hadn t thought of this. I think I had forgotten that CC2 s main Windows message loop is running in the same thread as the one executing the
            Message 5 of 6 , Jul 17, 2000
              Joe Bronikowski wrote:

              > Actually, until your XP function returns, CC2's message loop isn't
              > running anyway. You could just SendMessage to the modeless dialog
              > when you want it to repaint, etc.

              Good point; I hadn't thought of this. I think I had forgotten
              that CC2's main Windows message loop is running in the same
              thread as the one executing the XP code. Which, now that I
              think about it, was pretty silly of me to forget... since if
              it were otherwise, all sorts of other complications would crop
              up.

              I'll certainly keep around the code snippets you sent for po-
              tential future use. I've decided for now to go with the
              simple status bar progress messages suggested by Simon and
              Peter, and forego the dialog box.

              > Now, if you really mean you want a modeless dialog to remain
              > AFTER your XP function returns, then you're in a whole different
              > ball game :-)

              Luckily, I haven't yet dreamt up an XP command for which such
              a persistent dialog would be useful. :-)

              Thanks!
              Christopher Golden
              golden@...
            • Peter Olsson
              ... You can also get this from the XP structure (MyXP) that gets initialized when the DLL is loaded. -- //Peter
              Message 6 of 6 , Jul 17, 2000
                On Mon, 17 Jul 2000, Bronikowski, Joe wrote:

                > BTW So far I've found this to accurately provide CC2's hwnd:
                >
                > HWND hCC2 = GetFocus ();

                You can also get this from the XP structure (MyXP) that gets initialized
                when the DLL is loaded.

                --
                //Peter
              Your message has been successfully submitted and would be delivered to recipients shortly.