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 / C++ / MFC
  4. postmessage in a callback function

postmessage in a callback function

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 2 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.
  • M Offline
    M Offline
    Marcus Spitzmiller
    wrote on last edited by
    #1

    Anyone have any idea why when I call PostMessage in a callback function, it works just fine on W2K and WinXP, but doesn't work on Win98SE? On all of the above O/S's, it makes it to the callback just fine, and the PostMessage() succeeds, but on Win98, it never makes it to function which handles the message. Any ideas? Thanks! Marcus Spitzmiller "Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer

    N 1 Reply Last reply
    0
    • M Marcus Spitzmiller

      Anyone have any idea why when I call PostMessage in a callback function, it works just fine on W2K and WinXP, but doesn't work on Win98SE? On all of the above O/S's, it makes it to the callback just fine, and the PostMessage() succeeds, but on Win98, it never makes it to function which handles the message. Any ideas? Thanks! Marcus Spitzmiller "Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      Are you sure the HWND you are posting to is valid and correct. Have you tried running Spy++ to see if the posted message is being received by the window in question. You might just be lucky that it is working on XP etc. You didn't mention what the callback is (yours / windows) but that shouldn't make any difference, unless there is some specific Windows Callback where PostMessage can't be used, but I doubt it. I've never encountered a problem where PostMessage() didn't do what I expected and I use it quite a bit. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

      M 1 Reply Last reply
      0
      • N Neville Franks

        Are you sure the HWND you are posting to is valid and correct. Have you tried running Spy++ to see if the posted message is being received by the window in question. You might just be lucky that it is working on XP etc. You didn't mention what the callback is (yours / windows) but that shouldn't make any difference, unless there is some specific Windows Callback where PostMessage can't be used, but I doubt it. I've never encountered a problem where PostMessage() didn't do what I expected and I use it quite a bit. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

        M Offline
        M Offline
        Marcus Spitzmiller
        wrote on last edited by
        #3

        Hi Neville - Well, I've been able to use Spy++ on XP to see that the HWND is indeed correct and the CWnd derived class that I'm posting to is indeed receiving the message (WM_USER + 1). On Win98, i've been able to verify that PostMessage is posting to the correct HWND, however, I can't verify that the CWnd derived class is receiving the message, because I can't get spy++ to run on Windows 98! :doh: Any ideas how to do that? Or do you know of a different tool I can use to check that? By the way, the callback is waveOutProc, which should have no problem using PostMessage within the callback. Thanks for the help! Marcus Spitzmiller "Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer

        N 1 Reply Last reply
        0
        • M Marcus Spitzmiller

          Hi Neville - Well, I've been able to use Spy++ on XP to see that the HWND is indeed correct and the CWnd derived class that I'm posting to is indeed receiving the message (WM_USER + 1). On Win98, i've been able to verify that PostMessage is posting to the correct HWND, however, I can't verify that the CWnd derived class is receiving the message, because I can't get spy++ to run on Windows 98! :doh: Any ideas how to do that? Or do you know of a different tool I can use to check that? By the way, the callback is waveOutProc, which should have no problem using PostMessage within the callback. Thanks for the help! Marcus Spitzmiller "Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #4

          Hi Marcus, I haven't used W98 in some time but don't recall having problems running Spy++. You could try Winspector Spy http://www.windows-spy.com/[^] You could add a PreTranslateMessage() into the target CWnd then in that look for your WM_USER+1. Also not that WM_USER messages aren't recommended and instead you should use WM_APP. See the article http://www.codeproject.com/dialog/messagemgmt.asp[^] If the callback isn't in the main app thread you shouldn't be using CWnd*'s. Post a reply if you need more info on this or look for more J. Newcomer articles on threads. Hope that helps. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

          M 1 Reply Last reply
          0
          • N Neville Franks

            Hi Marcus, I haven't used W98 in some time but don't recall having problems running Spy++. You could try Winspector Spy http://www.windows-spy.com/[^] You could add a PreTranslateMessage() into the target CWnd then in that look for your WM_USER+1. Also not that WM_USER messages aren't recommended and instead you should use WM_APP. See the article http://www.codeproject.com/dialog/messagemgmt.asp[^] If the callback isn't in the main app thread you shouldn't be using CWnd*'s. Post a reply if you need more info on this or look for more J. Newcomer articles on threads. Hope that helps. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

            M Offline
            M Offline
            Marcus Spitzmiller
            wrote on last edited by
            #5

            Thanks very much! - I wasn't aware of the WM_USER thing. After changing it to WM_APP, everything is working fine! Thanks again for the help, and thanks for the links!! :) Marcus Spitzmiller "Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer

            N 1 Reply Last reply
            0
            • M Marcus Spitzmiller

              Thanks very much! - I wasn't aware of the WM_USER thing. After changing it to WM_APP, everything is working fine! Thanks again for the help, and thanks for the links!! :) Marcus Spitzmiller "Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer

              N Offline
              N Offline
              Neville Franks
              wrote on last edited by
              #6

              Happy to be of help. You can have the rest of the year off now.:-D Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

              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