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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Redirect Message Box Messages,

Redirect Message Box Messages,

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
6 Posts 3 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.
  • J Offline
    J Offline
    Joschwenk666
    wrote on last edited by
    #1

    Hallo, I have a Windows Service written in Visual C++. It`s a loop that does certain things, and starts from the beginning after waiting a few seconds. My problem is, that when there occurs an error in the code, a messagebox pops up. And the code is not executed anymore, because you have to click on "ok" first. The messagebox is showed from some external library functions, so I can`t go to the source code. Is there any possibility to redirect all message boxes to a logfile or something like that, and continue executing the program without a click by the user? Thank you!

    C 1 Reply Last reply
    0
    • J Joschwenk666

      Hallo, I have a Windows Service written in Visual C++. It`s a loop that does certain things, and starts from the beginning after waiting a few seconds. My problem is, that when there occurs an error in the code, a messagebox pops up. And the code is not executed anymore, because you have to click on "ok" first. The messagebox is showed from some external library functions, so I can`t go to the source code. Is there any possibility to redirect all message boxes to a logfile or something like that, and continue executing the program without a click by the user? Thank you!

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Well, first of all, if there are errors popping up, shouldn't you rather try to figure out what causes them and try to fix it, besides, maybe the user has to/wants to know about these problems, so "supressing" message boxes might not be a good idea. Depending on how the message boxes are displayed, i can think of a possible way to do what you want if you insist.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      S 1 Reply Last reply
      0
      • C Code o mat

        Well, first of all, if there are errors popping up, shouldn't you rather try to figure out what causes them and try to fix it, besides, maybe the user has to/wants to know about these problems, so "supressing" message boxes might not be a good idea. Depending on how the message boxes are displayed, i can think of a possible way to do what you want if you insist.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        S Offline
        S Offline
        Sameerkumar Namdeo
        wrote on last edited by
        #3

        Code-o-mat wrote:

        i can think of a possible way to do what you want

        Please show how can the ::MessageBox() can be suppressed and corresponding message be directed to some file.

        My Blog.
        My codeproject Articles.

        C 1 Reply Last reply
        0
        • S Sameerkumar Namdeo

          Code-o-mat wrote:

          i can think of a possible way to do what you want

          Please show how can the ::MessageBox() can be suppressed and corresponding message be directed to some file.

          My Blog.
          My codeproject Articles.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Sorry for the late answer, wasn!t near net access for a day. So, you could try hooking the MessageBoxA and/or MessageBoxW API functions and provide your own implementations to write to a log file. I don't know what you are actually doing so i can't really judge but i still don't think supressing message boxes intended for the user is a BAD IDEA. Anyways, for api hooking, see API hooking revealed[^] here on Code Project.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

          J 1 Reply Last reply
          0
          • C Code o mat

            Sorry for the late answer, wasn!t near net access for a day. So, you could try hooking the MessageBoxA and/or MessageBoxW API functions and provide your own implementations to write to a log file. I don't know what you are actually doing so i can't really judge but i still don't think supressing message boxes intended for the user is a BAD IDEA. Anyways, for api hooking, see API hooking revealed[^] here on Code Project.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

            J Offline
            J Offline
            Joschwenk666
            wrote on last edited by
            #5

            Thank you for the Link, I will try this. As I described i`m working at a Windows Service. It is a loop that changes things in a database and send mails and things like that, so there is no user in front of the computer at all, and when a message box pops up, the whole service stops, and mails are not sent anymore. So this service has to continue running when an error occurs. I just want the error in a logfile to see what happened and fix it later.

            C 1 Reply Last reply
            0
            • J Joschwenk666

              Thank you for the Link, I will try this. As I described i`m working at a Windows Service. It is a loop that changes things in a database and send mails and things like that, so there is no user in front of the computer at all, and when a message box pops up, the whole service stops, and mails are not sent anymore. So this service has to continue running when an error occurs. I just want the error in a logfile to see what happened and fix it later.

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              I see, with no user at the box it makes more sense. Tell me if you run into trouble with the hooking and i will help if i can.

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

              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