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. How to simulate 'X' (the red button at the top right corner) ?

How to simulate 'X' (the red button at the top right corner) ?

Scheduled Pinned Locked Moved C / C++ / MFC
game-devc++graphicstutorialquestion
10 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.
  • H Offline
    H Offline
    Hanan888
    wrote on last edited by
    #1

    I'm developing a game in win32 c++ DirectX. On my graphic game window I have a picture of a 'close' button. When I click on it I want it to to the same as clicking the 'X' button. But although I tried several things: ::SendMessage(hWnd, WM_CLOSE, NULL, NULL); ::SendMessage(hWnd, WM_DESTROY, NULL, NULL); DestroyWindow(hWnd); I get strange bugs that won't happen when I click 'X'.

    L M 2 Replies Last reply
    0
    • H Hanan888

      I'm developing a game in win32 c++ DirectX. On my graphic game window I have a picture of a 'close' button. When I click on it I want it to to the same as clicking the 'X' button. But although I tried several things: ::SendMessage(hWnd, WM_CLOSE, NULL, NULL); ::SendMessage(hWnd, WM_DESTROY, NULL, NULL); DestroyWindow(hWnd); I get strange bugs that won't happen when I click 'X'.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      PostMessage(WM_SYSCOMMAND,SC_CLOSE,0);
      Best Wishes, -David Delaune

      H 1 Reply Last reply
      0
      • H Hanan888

        I'm developing a game in win32 c++ DirectX. On my graphic game window I have a picture of a 'close' button. When I click on it I want it to to the same as clicking the 'X' button. But although I tried several things: ::SendMessage(hWnd, WM_CLOSE, NULL, NULL); ::SendMessage(hWnd, WM_DESTROY, NULL, NULL); DestroyWindow(hWnd); I get strange bugs that won't happen when I click 'X'.

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Hanan888 wrote:

        ::SendMessage(hWnd, WM_DESTROY, NULL, NULL);

        Don't do that!  That doesn't destroy a window :) Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        H T 2 Replies Last reply
        0
        • L Lost User

          PostMessage(WM_SYSCOMMAND,SC_CLOSE,0);
          Best Wishes, -David Delaune

          H Offline
          H Offline
          Hanan888
          wrote on last edited by
          #4

          Thank you very much. It seems like all crazy bugs are gone.

          1 Reply Last reply
          0
          • M Mark Salsbery

            Hanan888 wrote:

            ::SendMessage(hWnd, WM_DESTROY, NULL, NULL);

            Don't do that!  That doesn't destroy a window :) Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            H Offline
            H Offline
            Hanan888
            wrote on last edited by
            #5

            Thanks. I Really shouldn't post ::SendMessage(hWnd, WM_DESTROY, NULL, NULL); as a real candidate. I was pretty desperate when I posted that message... :)

            M 1 Reply Last reply
            0
            • H Hanan888

              Thanks. I Really shouldn't post ::SendMessage(hWnd, WM_DESTROY, NULL, NULL); as a real candidate. I was pretty desperate when I posted that message... :)

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              hehe the last act of a desperate programmer :)

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              H 1 Reply Last reply
              0
              • M Mark Salsbery

                Hanan888 wrote:

                ::SendMessage(hWnd, WM_DESTROY, NULL, NULL);

                Don't do that!  That doesn't destroy a window :) Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                Mark Salsbery wrote:

                Don't do that! That doesn't destroy a window

                Opps, let me check how many windows has been destroyed by me till date!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                Never mind - my own stupidity is the source of every "problem" - Mixture

                cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                M 1 Reply Last reply
                0
                • M Mark Salsbery

                  hehe the last act of a desperate programmer :)

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  H Offline
                  H Offline
                  Hanan888
                  wrote on last edited by
                  #8

                  "He got sick of it. Sick of life, sick of people, sick of Win32. Desperate and dispirited, he code ::SendMessage(hWnd, WM_DESTROY, NULL, NULL);. And I can tell you this: whatever it does, it doesn't destroy a window..." :)

                  M 1 Reply Last reply
                  0
                  • H Hanan888

                    "He got sick of it. Sick of life, sick of people, sick of Win32. Desperate and dispirited, he code ::SendMessage(hWnd, WM_DESTROY, NULL, NULL);. And I can tell you this: whatever it does, it doesn't destroy a window..." :)

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    :laugh: Excellent!

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    1 Reply Last reply
                    0
                    • T ThatsAlok

                      Mark Salsbery wrote:

                      Don't do that! That doesn't destroy a window

                      Opps, let me check how many windows has been destroyed by me till date!

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                      Never mind - my own stupidity is the source of every "problem" - Mixture

                      cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #10

                      Huh?  What are you talking about Alok? :)

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      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