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. Other Discussions
  3. IT & Infrastructure
  4. Console to win app

Console to win app

Scheduled Pinned Locked Moved IT & Infrastructure
c++helptutorialannouncementlearning
6 Posts 2 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.
  • D Offline
    D Offline
    dr eu
    wrote on last edited by
    #1

    Hello ! I am beginner in C++ and i need some help from you ! I want to make my console program into windows application, but I dont now how to do it. Please help me ! Thank you. Boco //PROGRAM FOR CALCULATING SUM AND AVERAGE OF TWO NUMBERS #include #include int main () { float num_1, num_2; double sum, average; cout << "\n\t\t******************************************* "; cout << "\n\t\t* PROGRAM FOR CALCULATING SUM AND AVERAGE * "; cout << "\n\t\t* OF TWO NUMBERS * "; cout << "\n\t\t* Version 1.0, February, 2004 * "; cout << "\n\t\t******************************************* "; cout << "\n\n\n\n\n Enter first number: "; cin >> num_1; cout << "\n Enter second number: "; cin >> num_2; sum = num_1 + num_2; average = sum / 2.0; cout << "\n\n Calculated sum is: " << sum << endl; cout << "\n Calculated average is: " << average << endl; cout << "\n\n\n\n\n For exit from program press [Enter] >>>>> "; getchar(); return (0); }

    G 1 Reply Last reply
    0
    • D dr eu

      Hello ! I am beginner in C++ and i need some help from you ! I want to make my console program into windows application, but I dont now how to do it. Please help me ! Thank you. Boco //PROGRAM FOR CALCULATING SUM AND AVERAGE OF TWO NUMBERS #include #include int main () { float num_1, num_2; double sum, average; cout << "\n\t\t******************************************* "; cout << "\n\t\t* PROGRAM FOR CALCULATING SUM AND AVERAGE * "; cout << "\n\t\t* OF TWO NUMBERS * "; cout << "\n\t\t* Version 1.0, February, 2004 * "; cout << "\n\t\t******************************************* "; cout << "\n\n\n\n\n Enter first number: "; cin >> num_1; cout << "\n Enter second number: "; cin >> num_2; sum = num_1 + num_2; average = sum / 2.0; cout << "\n\n Calculated sum is: " << sum << endl; cout << "\n Calculated average is: " << average << endl; cout << "\n\n\n\n\n For exit from program press [Enter] >>>>> "; getchar(); return (0); }

      G Offline
      G Offline
      Gerald Leslie Jones
      wrote on last edited by
      #2

      you should use WinMain.

      D 1 Reply Last reply
      0
      • G Gerald Leslie Jones

        you should use WinMain.

        D Offline
        D Offline
        dr eu
        wrote on last edited by
        #3

        Yes, I now, but how must do it ? :confused: Boco

        G 1 Reply Last reply
        0
        • D dr eu

          Yes, I now, but how must do it ? :confused: Boco

          G Offline
          G Offline
          Gerald Leslie Jones
          wrote on last edited by
          #4

          You should set the compiler option to compile it as Windows application.

          D 2 Replies Last reply
          0
          • G Gerald Leslie Jones

            You should set the compiler option to compile it as Windows application.

            D Offline
            D Offline
            dr eu
            wrote on last edited by
            #5

            I had done that, but I can made only static window with text and MessageBox with buttons Yes and No. Boco

            1 Reply Last reply
            0
            • G Gerald Leslie Jones

              You should set the compiler option to compile it as Windows application.

              D Offline
              D Offline
              dr eu
              wrote on last edited by
              #6

              This is example, I used once for static window, but is not good for my program above. Boco #include LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch(message) { case WM_DESTROY: { PostQuitMessage(0); break; } case WM_PAINT: { HDC hdc; hdc=GetDC(hwnd); TextOut(hdc, 163, 60, "HELLO !", strlen("HELLO !")); TextOut(hdc, 90, 120, "TODAY IS REALY NICE DAY.", strlen("TODAY IS REALY NICE DAY.")); TextOut(hdc, 52, 140, "RIGHT ONE FOR SITTING BEFORE PC.", strlen("RIGHT ONE FOR SITTING BEFORE PC.")); TextOut(hdc, 125, 220, "***** THE END *****", strlen("***** THE END *****")); ReleaseDC(hwnd, hdc); break; } return 0; } return (DefWindowProc(hwnd, message, wparam, lparam)); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { WNDCLASSEX winclass; const char AppName[] = "myClass"; winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = AppName; winclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); if (!(RegisterClassEx(&winclass))) {return 0;} CreateWindowEx (NULL, AppName, " WINDOW FOR TEXT", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 300, 200, 400, 300, NULL, NULL, hInstance, NULL); MSG message; while (GetMessage(&message, NULL, 0, 0)) { TranslateMessage(&message); DispatchMessage(&message); } MessageBox (NULL, "DO YOU WANT TO EXIT THIS PROGRAM ?" , " EXIT", 0 + MB_YESNO + MB_ICONQUESTION); return 0; }

              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