Thread: x on upper right corner not working

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    204

    x on upper right corner not working

    Here's the .c file:
    Code:
    #include <windows.h>
    #include "resource.h"
    
    BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch(LOWORD(wParam))
        {
        case WM_INITDIALOG:
            return TRUE;
        break;
    
        case ID_INVERT:
        {
            int length = GetWindowTextLength(GetDlgItem(hDlg, ID_TXT_NORMAL));
            if(length > 0)
                MessageBox(hDlg, "Cool, it's working!", "Warning", MB_OK);
    
            else
                MessageBox(hDlg, "Type something!", "Warning", MB_OK);
        }
        break;
    
        case WM_CLOSE:
            EndDialog(hDlg, 0);
            return TRUE;
        break;
        }
    
        return FALSE;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       PSTR szCmdLine, int iCmdShow)
    {
        return DialogBox(hInstance, MAKEINTRESOURCE(ID_MAIN), NULL, DlgProc);
    }
    Here's the .h file:
    Code:
    //{{NO_DEPENDENCIES}}
    // Microsoft Visual C++ generated include file.
    // Used by aa.rc
    //
    #define ID_MAIN                100
    #define ID_COPY                         101
    #define ID_INVERT                       1001
    #define ID_TXT_NORMAL                   1002
    #define ID_TXT_INVERTED                 1003
    #define ID_TRANSLATE            1005
    #define ID_ICON                103
    
    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        102
    #define _APS_NEXT_COMMAND_VALUE         40001
    #define _APS_NEXT_CONTROL_VALUE         1004
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif
    And here's the .rc file:
    Code:
    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    #include "afxres.h"
    
    /////////////////////////////////////////////////////////////////////////////
    #undef APSTUDIO_READONLY_SYMBOLS
    
    /////////////////////////////////////////////////////////////////////////////
    // English (U.S.) resources
    
    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
    #ifdef _WIN32
    LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
    #pragma code_page(1252)
    #endif //_WIN32
    
    #ifdef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // TEXTINCLUDE
    //
    
    1 TEXTINCLUDE 
    BEGIN
        "resource.h\0"
    END
    
    2 TEXTINCLUDE 
    BEGIN
        "#include ""afxres.h""\r\n"
        "\0"
    END
    
    3 TEXTINCLUDE 
    BEGIN
        "\r\n"
        "\0"
    END
    
    #endif    // APSTUDIO_INVOKED
    
    
    /////////////////////////////////////////////////////////////////////////////
    //
    // Dialog
    //
    
    ID_MAIN DIALOGEX 0, 0, 171, 135
    STYLE DS_MODALFRAME | DS_CENTER |DS_FIXEDSYS | WS_POPUP | WS_CAPTION | 
        WS_SYSMENU
    CAPTION "De trás pra frente!"
    FONT 8, "MS Shell Dlg", 400, 0, 0x1
    BEGIN
        GROUPBOX        " Inverter ",IDC_STATIC,4,0,163,66
        EDITTEXT        ID_TXT_NORMAL,10,12,151,31,ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN
        PUSHBUTTON      "Inverter",ID_INVERT,10,48,62,14
        DEFPUSHBUTTON   "Copiar",ID_COPY,100,48,61,14
        
        GROUPBOX        "Traduzir ",IDC_STATIC,4,66,163,66
        EDITTEXT        ID_TXT_INVERTED,10,78,151,30,ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN
        PUSHBUTTON      "Traduzir",ID_TRANSLATE,52,113,67,14
    END
    
    
    /////////////////////////////////////////////////////////////////////////////
    //
    // DESIGNINFO
    //
    
    #ifdef APSTUDIO_INVOKED
    GUIDELINES DESIGNINFO 
    BEGIN
        IDD_DIALOG1, DIALOG
        BEGIN
            LEFTMARGIN, 7
            RIGHTMARGIN, 162
            TOPMARGIN, 7
            BOTTOMMARGIN, 129
        END
    END
    #endif    // APSTUDIO_INVOKED
    
    #endif    // English (U.S.) resources
    /////////////////////////////////////////////////////////////////////////////
    
    
    
    #ifndef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 3 resource.
    //
    
    
    /////////////////////////////////////////////////////////////////////////////
    #endif    // not APSTUDIO_INVOKED
    Why isn't the x working? If I switch() "message", it works but the "Inverter" button won't. Thanks.

  2. #2
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    You need to have your main switch be checking "message". Your inverter button doesn't work when you do this probably because you are confused into how to process button messages. Look at this thread . I explained button messages there.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM
  5. Newbie working on a lift simulation
    By dethray79 in forum C++ Programming
    Replies: 1
    Last Post: 10-07-2001, 08:28 AM