resource.rc CheckBox and Editfield

This is a discussion on resource.rc CheckBox and Editfield within the Windows Programming forums, part of the Platform Specific Boards category; Hello, i try to devolop a complet Window with the WinAPI, but my Compiler (C::B) answers with Syntax errors. Can ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    10

    resource.rc CheckBox and Editfield

    Hello,
    i try to devolop a complet Window with the WinAPI,
    but my Compiler (C::B) answers with Syntax errors. Can someone help me?
    I am from Germany and post this question to the biggest german c++ board, but nobody have a answer for me. I hope here are more people.

    resource.h :
    Code:
    #include <windows.h>
    
    // ID of Main Dialogs
    #define DLG_MAIN 101
    #define DLG_LOGIN 102
    
    // ID of Button Controls
    #define IDC_BTN_START 1001
    #define IDC_BTN_QUIT 1002
    #define IDC_BTN_LOG  1003
    #define IDC_CHECKBOX 1004
    #define IDC_USER 1005
    #define IDC_PW 1006



    resource.rc :
    Da wo die Kommentare mit den Zahlen befinden, sind die Fehler.
    Code:
    #include "resource.h"
    
    DLG_MAIN DIALOGEX 6, 5, 194, 106
    
    CAPTION "Dakron Bot v0.1"
    
    FONT 8, "MS Sans Serif", 0, 0, 1
    
    STYLE 0x10CE0804
    
    BEGIN
      CONTROL "&Start", IDC_BTN_START, "Button", 0x10010000, 138,  5, 46, 15
      CONTROL "&Beenden", IDC_BTN_QUIT, "Button", 0x10010000, 138, 29, 46, 15
      CHECKBOX "&Checkbox",IDC_CHECKBOX, "Checkbox", 0x10010000, 138, 44, 66, 15 // 14
    END
    
    
    DLG_LOGIN DIALOGEX 6, 5, 200, 100
    CAPTION "Dakron Bot Login"
    
    FONT 8, "MS Sans Serif", 0, 0, 1
    
    STYLE 0x10CE0804
    
    BEGIN
      CONTROL "&Login", IDC_BTN_LOG, "Button", 0x10010000, 138,  5, 46, 15
      LTEXT "Benutzername:", -1, 36, 24, 45, 8  // 27
      EDITTEXT IDC_USER, 83,22,61,13, ES_AUTOHSCROLL | WS_BORDER // 28
      LTEXT "Password:", -1, 36, 24, 45, 8  // 29
      EDITTEXT IDC_PW, 83,22,61,13, ES_AUTOHSCROLL | WS_BORDER // 30
    END
    main.cpp
    Code:
    #define WIN32_LEAN_AND_MEAN
    
    #include <windows.h>
    #include "resource.h"
    #include <iostream>
    #include <stdio.h>
    #include <tchar.h>
    
    using namespace std;
    
    int startgame();
    
    HINSTANCE hInst;
    
    
    
    BOOL CALLBACK DialogLogin(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        switch(uMsg)
        {
            case WM_INITDIALOG:
                return TRUE;
    
            case WM_CLOSE:
                EndDialog(hwndDlg, 0);
                return TRUE;
    
            case WM_COMMAND:
                switch(LOWORD(wParam)) {
                    case IDC_BTN_LOG:
                        // check the login
                        return TRUE;
                }
        }
    
        return FALSE;
    }
    
    
    
    BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        static HWND hEdit;
    
        switch(uMsg)
        {
            case WM_INITDIALOG:
    
                return TRUE;
    
            case WM_CLOSE:
                EndDialog(hwndDlg, 0);
                return TRUE;
    
            case WM_COMMAND:
                switch(LOWORD(wParam))
                {
    
                    case IDC_BTN_QUIT:
                        EndDialog(hwndDlg, 0);
                        return TRUE;
    
                    case IDC_BTN_START:
                        startgame();
                        return TRUE;
                }
        }
    
        return FALSE;
    }
    
    
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
        HWND hwndDlg;
        hInst = hInstance;
    
    
    
        // Start here the Login WIndow
        DialogBox(hInstance, MAKEINTRESOURCE(DLG_LOGIN), NULL, DialogLogin);
        // If login -> korrekt
        
        // Start the main window.
        return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, DialogProc);
    }
    The error wasnt helpful for me:
    resource.rc:x: syntax error

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    According to this MSDN page, the arguments to CHECKBOX aren't what you seem to think they are.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    10
    Thanks, you are right.

    But i have a other problem now (the syntax ist okay i can compile all).

    Code:
                    
                  case WM_CLOSE:
               // EndDialog(hwndDlg, 0);
                return TRUE;
    This code ist from the DialogLogin. If the Login is korrekt a next window open:
    info:
    BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    But the window open too if i clode the login (click normaly the x)

    What can i do to shut down the complet programm and not only this one window?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I'm not sure what's going on, given that you give one line of actual code there. But, anyway, you can use EndDialog to give information back to whatever popped up this thing, so maybe something like EndDialog(hwndDlg, IsValidLogin(whatever)) so that the parent window knows whether to continue or give you the login box back or something.

Popular pages Recent additions subscribe to a feed

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