Taschenrechner in Windows Application



  • hät ich auch selbst sehen müssen 🙄
    jetzt habe ich auch schon weniger felher die letzten fehler sind diese

    144 D:\Dev-Cpp\main4.cpp syntax error before `.' token
    157 D:\Dev-Cpp\main4.cpp hexcalc.dlg: No such file or directory.
    153 D:\Dev-Cpp\main4.cpp syntax error before string constant
    D:\Dev-Cpp\Makefile.win [Build Error] [main4.o] Error 1

    hier sind jetzt die zeilen 144-157

    HEXCALC.RC (excerpts) 
    
    //Microsoft Developer Studio generated resource script. 
    #include "resource.h" 
    #include "afxres.h" 
    
    ///////////////////////////////////////////////////////////////////////////// 
    // Icon 
    
    HEXCALC                 ICON    DISCARDABLE     "HexCalc.ico" 
    
    ///////////////////////////////////////////////////////////////////////////// 
    
    #include "hexcalc.dlg"
    


  • Das sind ja auch nur Auszüge (engl.: Excerpts) aus dem Resource-File.

    Komplett ist's hier:

    //Microsoft Developer Studio 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 DISCARDABLE 
    BEGIN
        "resource.h\0"
    END
    
    2 TEXTINCLUDE DISCARDABLE 
    BEGIN
        "#include ""afxres.h""\r\n"
        "\0"
    END
    
    3 TEXTINCLUDE DISCARDABLE 
    BEGIN
        "#include ""hexcalc.dlg""\r\n"
        "\0"
    END
    
    #endif    // APSTUDIO_INVOKED
    
    /////////////////////////////////////////////////////////////////////////////
    //
    // Icon
    //
    
    // Icon with lowest ID value placed first to ensure application icon
    // remains consistent on all systems.
    HEXCALC                 ICON    DISCARDABLE     "HexCalc.ico"
    #endif    // English (U.S.) resources
    /////////////////////////////////////////////////////////////////////////////
    
    #ifndef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 3 resource.
    //
    #include "hexcalc.dlg"
    
    /////////////////////////////////////////////////////////////////////////////
    #endif    // not APSTUDIO_INVOKED
    

    Die Hexcalc.dlg mußt Du selber erstellen (Quelltext kannst Du Erhards Post entnehmen).



  • Die Hexcalc.dlg mußt Du selber erstellen (Quelltext kannst Du Erhards Post entnehmen).

    wie jetzt?
    ich habe den kompletten code von Erhards post genommen und als WinApi gespeichert. Und wo soll ich jetzt den code hin tun den du mir gesagt hast? in die Hexcalc.dlg ?



  • Du hast jetzt nicht Erhards komplettes Codeschnipsel in eine Datei gepackt, oder? 😮

    Was meinst Du weshalb da

    HEXCALC.C

    HEXCALC.RC

    HEXCALC.DLG

    im Quelltext steht, gefolgt von entsprechenden Kommentaren?



  • also muss das os aussehen

    #include <windows.h> 
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; 
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                        PSTR szCmdLine, int iCmdShow) 
    { 
         static TCHAR szAppName[] = TEXT ("HexCalc") ; 
         HWND         hwnd ; 
         MSG          msg ; 
         WNDCLASS     wndclass ; 
    
         wndclass.style         = CS_HREDRAW | CS_VREDRAW; 
         wndclass.lpfnWndProc   = WndProc ; 
         wndclass.cbClsExtra    = 0 ; 
         wndclass.cbWndExtra    = DLGWINDOWEXTRA ;    // Note! 
         wndclass.hInstance     = hInstance ; 
         wndclass.hIcon         = LoadIcon (hInstance, szAppName) ; 
         wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ; 
         wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1) ; 
         wndclass.lpszMenuName  = NULL ; 
         wndclass.lpszClassName = szAppName ; 
    
         if (!RegisterClass (&wndclass)) 
         { 
              MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
                          szAppName, MB_ICONERROR) ; 
              return 0 ; 
         } 
    
         hwnd = CreateDialog (hInstance, szAppName, 0, NULL) ; 
    
         ShowWindow (hwnd, iCmdShow) ; 
    
         while (GetMessage (&msg, NULL, 0, 0)) 
         { 
              TranslateMessage (&msg) ; 
              DispatchMessage (&msg) ; 
         } 
         return msg.wParam ; 
    } 
    
    void ShowNumber (HWND hwnd, UINT iNumber) 
    { 
         TCHAR szBuffer[20] ; 
    
         wsprintf (szBuffer, TEXT ("%X"), iNumber) ; 
         SetDlgItemText (hwnd, VK_ESCAPE, szBuffer) ; 
    } 
    
    DWORD CalcIt (UINT iFirstNum, int iOperation, UINT iNum) 
    { 
         switch (iOperation) 
         { 
         case `=`: return iNum ; 
         case `+': return iFirstNum +  iNum ; 
         case `-': return iFirstNum -  iNum ; 
         case `*': return iFirstNum *  iNum ; 
         case `&': return iFirstNum &  iNum ; 
         case `|': return iFirstNum |  iNum ; 
         case `^': return iFirstNum ^  iNum ; 
         case `<`: return iFirstNum << iNum ; 
         case `>`: return iFirstNum >> iNum ; 
         case `/': return iNum ? iFirstNum / iNum: MAXDWORD ; 
         case `%': return iNum ? iFirstNum % iNum: MAXDWORD ; 
         default : return 0 ; 
         } 
    } 
    
    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
    { 
         static BOOL  bNewNumber = TRUE ; 
         static int   iOperation = `=` ; 
         static UINT  iNumber, iFirstNum ; 
         HWND         hButton ; 
    
         switch (message) 
         { 
         case WM_KEYDOWN:                   // left arrow --> backspace 
              if (wParam != VK_LEFT) 
                   break ; 
              wParam = VK_BACK ; 
                                            // fall through 
         case WM_CHAR: 
              if ((wParam = (WPARAM) CharUpper ((TCHAR *) wParam)) == VK_RETURN) 
                   wParam = `=` ; 
    
              if (hButton = GetDlgItem (hwnd, wParam)) 
              { 
                   SendMessage (hButton, BM_SETSTATE, 1, 0) ; 
                   Sleep (100) ; 
                   SendMessage (hButton, BM_SETSTATE, 0, 0) ; 
              } 
              else 
              { 
                   MessageBeep (0) ; 
                   break ; 
              } 
                                            // fall through 
         case WM_COMMAND: 
              SetFocus (hwnd) ; 
    
              if (LOWORD (wParam) == VK_BACK)         // backspace 
                   ShowNumber (hwnd, iNumber /= 16) ; 
    
              else if (LOWORD (wParam) == VK_ESCAPE)  // escape 
                   ShowNumber (hwnd, iNumber = 0) ; 
    
              else if (isxdigit (LOWORD (wParam)))    // hex digit 
              { 
                   if (bNewNumber) 
                   { 
                        iFirstNum = iNumber ; 
                        iNumber = 0 ; 
                   } 
                   bNewNumber = FALSE ; 
    
                   if (iNumber <= MAXDWORD >> 4) 
                        ShowNumber (hwnd, iNumber = 16 * iNumber + wParam - 
                        (isdigit (wParam) ? `0': `A' - 10)) ; 
                   else 
                        MessageBeep (0) ; 
              } 
              else                                    // operation 
              { 
                   if (!bNewNumber) 
                        ShowNumber (hwnd, iNumber = 
                             CalcIt (iFirstNum, iOperation, iNumber)) ; 
                   bNewNumber = TRUE ; 
                   iOperation = LOWORD (wParam) ; 
              } 
              return 0 ; 
    
         case WM_DESTROY: 
              PostQuitMessage (0) ; 
              return 0 ; 
         } 
         return DefWindowProc (hwnd, message, wParam, lParam) ; 
    }
    

    und die HEXCALC.RC

    //Microsoft Developer Studio generated resource script. 
    #include "resource.h" 
    #include "afxres.h" 
    
    ///////////////////////////////////////////////////////////////////////////// 
    // Icon 
    
    HEXCALC                 ICON    DISCARDABLE     "HexCalc.ico" 
    
    ///////////////////////////////////////////////////////////////////////////// 
    
    #include "hexcalc.dlg"
    

    und die HEXCALC.DLG

    HexCalc DIALOG -1, -1, 102, 122 
    STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX 
    CLASS "HexCalc" 
    CAPTION "Hex Calculator" 
    { 
         PUSHBUTTON "D",       68,  8,  24, 14, 14 
         PUSHBUTTON "A",       65,  8,  40, 14, 14 
         PUSHBUTTON "7",       55,  8,  56, 14, 14 
         PUSHBUTTON "4",       52,  8,  72, 14, 14 
         PUSHBUTTON "1",       49,  8,  88, 14, 14 
         PUSHBUTTON "0",       48,  8, 104, 14, 14 
         PUSHBUTTON "0",       27, 26,   4, 50, 14 
         PUSHBUTTON "E",       69, 26,  24, 14, 14 
         PUSHBUTTON "B",       66, 26,  40, 14, 14 
         PUSHBUTTON "8",       56, 26,  56, 14, 14 
         PUSHBUTTON "5",       53, 26,  72, 14, 14 
         PUSHBUTTON "2",       50, 26,  88, 14, 14 
         PUSHBUTTON "Back",     8, 26, 104, 32, 14 
         PUSHBUTTON "C",       67, 44,  40, 14, 14 
         PUSHBUTTON "F",       70, 44,  24, 14, 14 
         PUSHBUTTON "9",       57, 44,  56, 14, 14 
         PUSHBUTTON "6",       54, 44,  72, 14, 14 
         PUSHBUTTON "3",       51, 44,  88, 14, 14 
         PUSHBUTTON "+",       43, 62,  24, 14, 14 
         PUSHBUTTON "-",       45, 62,  40, 14, 14 
         PUSHBUTTON "*",       42, 62,  56, 14, 14 
         PUSHBUTTON "/",       47, 62,  72, 14, 14 
         PUSHBUTTON "%",       37, 62,  88, 14, 14 
         PUSHBUTTON "Equals",  61, 62, 104, 32, 14 
         PUSHBUTTON "&&",      38, 80,  24, 14, 14 
         PUSHBUTTON "|",      124, 80,  40, 14, 14 
         PUSHBUTTON "^",       94, 80,  56, 14, 14 
         PUSHBUTTON "<",       60, 80,  72, 14, 14 
         PUSHBUTTON ">",       62, 80,  88, 14, 14 
    }
    

    muss das os aussehen?
    wenn ja habe ich mnoch eine frage wie kann ich bei DEV C++ eineHEXCALC.RC oder HEXCALC.DLG speichern?
    die HEXCALC.C habe4 ich über kompliern und da bei dateityp c ausgewählt nur da steht nichts von RC und DLG



  • Das hier ist die HEXCALC.RC:

    //Microsoft Developer Studio 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 DISCARDABLE 
    BEGIN 
        "resource.h\0" 
    END 
    
    2 TEXTINCLUDE DISCARDABLE 
    BEGIN 
        "#include ""afxres.h""\r\n" 
        "\0" 
    END 
    
    3 TEXTINCLUDE DISCARDABLE 
    BEGIN 
        "#include ""hexcalc.dlg""\r\n" 
        "\0" 
    END 
    
    #endif    // APSTUDIO_INVOKED 
    
    ///////////////////////////////////////////////////////////////////////////// 
    // 
    // Icon 
    // 
    
    // Icon with lowest ID value placed first to ensure application icon 
    // remains consistent on all systems. 
    HEXCALC                 ICON    DISCARDABLE     "HexCalc.ico" 
    #endif    // English (U.S.) resources 
    ///////////////////////////////////////////////////////////////////////////// 
    
    #ifndef APSTUDIO_INVOKED 
    ///////////////////////////////////////////////////////////////////////////// 
    // 
    // Generated from the TEXTINCLUDE 3 resource. 
    // 
    #include "hexcalc.dlg" 
    
    ///////////////////////////////////////////////////////////////////////////// 
    #endif    // not APSTUDIO_INVOKED
    

    Eine RC-Datei ist ein simples ResourcenSkript (evtl. kannst Du das im DevCpp deinem Projekt hinzufügen.

    Du kannst die Dateien alle auch mit'm Notepad erstellen und speichern, ist doch vollkommen Wurst...

    Dann fügst Du Deinem Projekt die .C und die .RC hinzu und kompilierst den Krempel... Ob's funktionieren wird, weiß ich nicht, da ich den DevCpp nicht kenne... schätze mal eher nicht, weil Dir die afxres.h fehlen wird.



  • ich kanns einfach nicht 😞
    also ich bin jetzt über Datei neu und dann Ressourcen Datei gegangen hab dann bei Neue Ressourcen zum Projekt einfügen auf ok geklickt und habe jetzt in einem neuen fenster Unbekannt1 dort habe ich dann denn RC code von dir eingefügt und jetzt versucht zu kompliern doch bei der main.cpp kommt

    165 D:\Dev-Cpp\main.cpp syntax error before `-' token

    dort steht

    HexCalc DIALOG -1, -1, 102, 122
    

    also im DLG bereich
    ich habe bei Dev c++ noch nicht gefunden wie ich daten als DLG speichern kann
    oder bin ich zu blöd



  • Dieser Thread wurde von Moderator/in flenders aus dem Forum WinAPI in das Forum Andere Compiler verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • Wenn du ein Anfänger bist, hast du es halt nicht leicht mit klassischer Windows-Programmierung. 😉
    Fang mal lieber da an: http://www.winprog.org/tutorial/ 🙂



  • als xxx.DLG speichern? einfach so abspeichern als xxx.DLG und als Datei dem Projekt zufügen wie alles andere auch.


Anmelden zum Antworten