Application closing by default?

This is a discussion on Application closing by default? within the Windows Programming forums, part of the Platform Specific Boards category; I seem to be having a simple problem with an application I made. It's just a window with a text ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Application closing by default?

    I seem to be having a simple problem with an application I made. It's just a window with a text box and a couple of straightforward text application things. ~The problem is, any action I preform seems to close the application ~ Save for opening a file, which the program then exits directly after. I thought it was because of a missing break; command, but I couldent find one missing.

    Heres the message loop, I'm almost positive the problem is here, but I cant seem to find it;

    Code:
    <defs>
    #define IDR_MENU1   	500
    
    #define ID_FILE_EXIT 	900
    #define ID_FILE_NEW  	901
    #define ID_FILE_OPEN 	902
    #define ID_FILE_SAVE	903
    #define ID_FILE_SAVE_AS	904
    
    #define ID_FUNCTION_NEW 100
    
    #define ID_SURFACE_EDIT 200
    <defs>
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
     switch(msg) {
    
      case WM_CREATE:
       TextBoxSetup(hwnd);
       break;
    
      case WM_SIZE: {		 //WM SIZE START---
       HWND hEdit;
       RECT rcClient;
    
       GetClientRect(hwnd, &rcClient);
    
       hEdit = GetDlgItem(hwnd, ID_SURFACE_EDIT);
       SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
      }
      break;			//END OF WM SIZE---
    
    
    
      case WM_COMMAND:		//COMMAND PARSE START---
       switch(LOWORD(wParam)){
    
        case ID_FILE_EXIT:
         PostMessage(hwnd, WM_CLOSE, 0, 0);
         break;
    
        case ID_FILE_NEW:
         break;
    
        case ID_FILE_OPEN:
         OpenFileName(hwnd);
         break;
    
        case ID_FILE_SAVE:
         break;
    
        case ID_FILE_SAVE_AS:
         break;
    
        default:
         break;
      }				//COMMAND PARSE END---
    
      case WM_CLOSE:
       DestroyWindow(hwnd);
       break;
    
      case WM_DESTROY:
       PostQuitMessage(0);
       break;
    
      default:
       return DefWindowProc(hwnd, msg, wParam, lParam);
    
     }
    
     return 0;
    }
    I've been poking around the code for awhile and I just dont see any issues -,-.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,538
    Missing break after WM_COMMAND switch.
    You also need to indent better. One space is not enough. I recommend at least 4 to make it more readable.
    Make sure to match proper indentation with the opening and closing {, to make it easier to read.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Bah! I knew that pesky thing was somewhere. Thanks, I didin't even realize I needed a break; after it.

    ~I indent with 1 space as a sort of bad habbit, the first time I ever got into coding I was using an old outdated language that required single-space indenting, and I never really got out of that habbit.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Default arguments
    By swgh in forum C Programming
    Replies: 5
    Last Post: 06-29-2007, 06:27 PM
  2. Closing Property Sheets - PSM_GETCURRENTPAGEHWND Test
    By Tonto in forum Windows Programming
    Replies: 1
    Last Post: 05-07-2007, 07:22 AM
  3. Closing the application window
    By Cojones893 in forum C++ Programming
    Replies: 4
    Last Post: 10-17-2004, 06:10 PM
  4. Closing an application
    By bdiamond in forum C++ Programming
    Replies: 3
    Last Post: 08-18-2004, 02:40 PM
  5. Help with default parameter value using ptr-to-functor
    By registering in forum C++ Programming
    Replies: 2
    Last Post: 03-24-2004, 03:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21