Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Bypass Windows Message other than Open & Close

Bypass Windows Message other than Open & Close

Scheduled Pinned Locked Moved C#
helptutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varunpandeyengg
    wrote on last edited by
    #1

    Hey everybody, I need to show a static Dialog having only a label "Please Wait" before a long process starts. Since both dialog & process are in the main thread, the dialog is frozen. Due to this, till the task is completed, if I click or drag the "Please Wait" Dialog, "End Process" pops in. Thus, I just need to bypass all the WINDOWS MESSAGES other than those needed for dlg.show() & dlg.close(). Please help me. To start with I know how to bypass the messages.

    protected override void WndProc(ref Message m)
    {
    if (m.Msg == WM_CLOSE) // All the messages I need to handle
    base.WndProc(ref m);
    }

    I just want to know what all messages I'll have to bypass. Also, is there any thing easier way to do this. Thanx in Advance. :-)

    M L 2 Replies Last reply
    0
    • V varunpandeyengg

      Hey everybody, I need to show a static Dialog having only a label "Please Wait" before a long process starts. Since both dialog & process are in the main thread, the dialog is frozen. Due to this, till the task is completed, if I click or drag the "Please Wait" Dialog, "End Process" pops in. Thus, I just need to bypass all the WINDOWS MESSAGES other than those needed for dlg.show() & dlg.close(). Please help me. To start with I know how to bypass the messages.

      protected override void WndProc(ref Message m)
      {
      if (m.Msg == WM_CLOSE) // All the messages I need to handle
      base.WndProc(ref m);
      }

      I just want to know what all messages I'll have to bypass. Also, is there any thing easier way to do this. Thanx in Advance. :-)

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      varunpandeyengg wrote:

      Thus, I just need to bypass all the WINDOWS MESSAGES

      No you need to redesign your process. Move your long running process off the main thread and do the job properly. Mucking around with message handling b/c you are too lazy to use another thread is just dumb.

      Never underestimate the power of human stupidity RAH

      V 1 Reply Last reply
      0
      • M Mycroft Holmes

        varunpandeyengg wrote:

        Thus, I just need to bypass all the WINDOWS MESSAGES

        No you need to redesign your process. Move your long running process off the main thread and do the job properly. Mucking around with message handling b/c you are too lazy to use another thread is just dumb.

        Never underestimate the power of human stupidity RAH

        V Offline
        V Offline
        varunpandeyengg
        wrote on last edited by
        #3

        Due to some limitation of the process, I need to call some functions of main thread plus BeginInvoke isn't performing well. So, I have no choice other than working with Windows Message.

        N 1 Reply Last reply
        0
        • V varunpandeyengg

          Due to some limitation of the process, I need to call some functions of main thread plus BeginInvoke isn't performing well. So, I have no choice other than working with Windows Message.

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          There is no other way. Running the long running job on new thread is the way to go. Because both the message handling code and long running code are getting executed on the main thread. Which means either one can execute at a time. Since the long running job is blocking the thread, main thread will be in waiting state and your message processing code won't get executed. Why do you think BeginInvoke is not performing well? Do you have benchmarks which shows BeginInvoke is slow?

          Best wishes, Navaneeth

          1 Reply Last reply
          0
          • V varunpandeyengg

            Hey everybody, I need to show a static Dialog having only a label "Please Wait" before a long process starts. Since both dialog & process are in the main thread, the dialog is frozen. Due to this, till the task is completed, if I click or drag the "Please Wait" Dialog, "End Process" pops in. Thus, I just need to bypass all the WINDOWS MESSAGES other than those needed for dlg.show() & dlg.close(). Please help me. To start with I know how to bypass the messages.

            protected override void WndProc(ref Message m)
            {
            if (m.Msg == WM_CLOSE) // All the messages I need to handle
            base.WndProc(ref m);
            }

            I just want to know what all messages I'll have to bypass. Also, is there any thing easier way to do this. Thanx in Advance. :-)

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            That is a bad idea. As others have said, your long operation needs to move to another thread. There are a couple of ways to do that, the best choice depends on the operations. What is it you are doing? How long does it take, and how often does your code need to access the GUI in that time? BTW1: I don't use Control.BeginInvoke(); when I need invoking, I use Control.Invoke(). BTW2: IMO a long operation needs a way to get cancelled (the user sits there waiting and has the time to change his mind); and a progress bar is also nice to have. These are additional reasons to do things properly, i.e. with an extra thread. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups