Visual C++ 2008

Visual C++ 2008

offline
  • lnenad  Male
  • Stručni saradnik
    Web
  • Nenad
  • Arhitetak
  • Pridružio: 16 Jan 2007
  • Poruke: 2860
  • Gde živiš: Bijeljina

E ovako, ja sam programer ali do sada nisam nikada u ovom programu radio, imam iskustva sa C++ ali to je do sada uglavnom bilo u radu sa devc++, e sad da pocnem pricu o problemu, napravim program win32 obican i sad (prvi mi je program hocu da napravim digitron (prosto nesto dvije tekst kutije i 4 dugmeta za operacije)) kliknem desnim klikom na folder Source u "solution explorer"-u>add>windows form i sad, nesto me pita da konvertujem projekt u neku stvar, (mislim da nije vazno pa kliknem na ok) i sad napravim ja to sve i sad ne znam da li ja sad taj header fajl da includujem u glavni cpp fajl ili sta i kad includujem prijavljuje nekih milion gresaka a kad ne includujem (stavim da se klikom prikaze messagebox) prijavi gresku

Citat:1>c:\documents and settings\nenad l\my documents\visual studio 2008\projects\digitron\digitron\forma_digitron.h(144) : error C2065: 'NULL' : undeclared identifier
1>c:\documents and settings\nenad l\my documents\visual studio 2008\projects\digitron\digitron\forma_digitron.h(144) : error C2065: 'MB_OK' : undeclared identifier


Moze li mi neko pomoci i objasniti kako se ovo radi...



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Pridružio: 30 Maj 2005
  • Poruke: 1014
  • Gde živiš: Mbabane

Jos kad bi napisao u koju stvar i to sve i sad taj header isto, i to sto include-ujes i sta nije vazno ... mozda bi ti neko i pomogao.

Problema sa kontantama i header-ima u Visual-u ces svakako imati. Ako su ti samo ovo greske, onda definisi sam NULL kao 0,a MB_OK kao neku pozitivnu vrijednost .. mada sumnjam da ce to biti jedine...



offline
  • lnenad  Male
  • Stručni saradnik
    Web
  • Nenad
  • Arhitetak
  • Pridružio: 16 Jan 2007
  • Poruke: 2860
  • Gde živiš: Bijeljina

Ok

Evo sta mi kaze kad ubacim windows form u source

  1. You are adding a CLR component to a native library. Your project will be converted to have common language runtime support.


Izaberem yes i nesto komp obavi ali nisam primjetio neku promjenu u kodu

Glavni source
  1. // digitron.cpp : Defines the entry point for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "digitron.h"
  6.  
  7. #define MAX_LOADSTRING 100
  8.  
  9. // Global Variables:
  10. HINSTANCE hInst;                        // current instance
  11. TCHAR szTitle[MAX_LOADSTRING];               // The title bar text
  12. TCHAR szWindowClass[MAX_LOADSTRING];         // the main window class name
  13.  
  14. // Forward declarations of functions included in this code module:
  15. ATOM            MyRegisterClass(HINSTANCE hInstance);
  16. BOOL            InitInstance(HINSTANCE, int);
  17. LRESULT CALLBACK   WndProc(HWND, UINT, WPARAM, LPARAM);
  18. INT_PTR CALLBACK   About(HWND, UINT, WPARAM, LPARAM);
  19.  
  20. int APIENTRY _tWinMain(HINSTANCE hInstance,
  21.                      HINSTANCE hPrevInstance,
  22.                      LPTSTR    lpCmdLine,
  23.                      int       nCmdShow)
  24. {
  25.    UNREFERENCED_PARAMETER(hPrevInstance);
  26.    UNREFERENCED_PARAMETER(lpCmdLine);
  27.  
  28.     // TODO: Place code here.
  29.    MSG msg;
  30.    HACCEL hAccelTable;
  31.  
  32.    // Initialize global strings
  33.    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  34.    LoadString(hInstance, IDC_DIGITRON, szWindowClass, MAX_LOADSTRING);
  35.    MyRegisterClass(hInstance);
  36.  
  37.    // Perform application initialization:
  38.    if (!InitInstance (hInstance, nCmdShow))
  39.    {
  40.       return FALSE;
  41.    }
  42.  
  43.    hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DIGITRON));
  44.  
  45.    // Main message loop:
  46.    while (GetMessage(&msg, NULL, 0, 0))
  47.    {
  48.       if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  49.       {
  50.          TranslateMessage(&msg);
  51.          DispatchMessage(&msg);
  52.       }
  53.    }
  54.  
  55.    return (int) msg.wParam;
  56. }
  57.  
  58.  
  59.  
  60. //
  61. //  FUNCTION: MyRegisterClass()
  62. //
  63. //  PURPOSE: Registers the window class.
  64. //
  65. //  COMMENTS:
  66. //
  67. //    This function and its usage are only necessary if you want this code
  68. //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
  69. //    function that was added to Windows 95. It is important to call this function
  70. //    so that the application will get 'well formed' small icons associated
  71. //    with it.
  72. //
  73. ATOM MyRegisterClass(HINSTANCE hInstance)
  74. {
  75.    WNDCLASSEX wcex;
  76.  
  77.    wcex.cbSize = sizeof(WNDCLASSEX);
  78.  
  79.    wcex.style         = CS_HREDRAW | CS_VREDRAW;
  80.    wcex.lpfnWndProc   = WndProc;
  81.    wcex.cbClsExtra      = 0;
  82.    wcex.cbWndExtra      = 0;
  83.    wcex.hInstance      = hInstance;
  84.    wcex.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DIGITRON));
  85.    wcex.hCursor      = LoadCursor(NULL, IDC_ARROW);
  86.    wcex.hbrBackground   = (HBRUSH)(COLOR_WINDOW+1);
  87.    wcex.lpszMenuName   = MAKEINTRESOURCE(IDC_DIGITRON);
  88.    wcex.lpszClassName   = szWindowClass;
  89.    wcex.hIconSm      = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
  90.  
  91.    return RegisterClassEx(&wcex);
  92. }
  93.  
  94. //
  95. //   FUNCTION: InitInstance(HINSTANCE, int)
  96. //
  97. //   PURPOSE: Saves instance handle and creates main window
  98. //
  99. //   COMMENTS:
  100. //
  101. //        In this function, we save the instance handle in a global variable and
  102. //        create and display the main program window.
  103. //
  104. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  105. {
  106.    HWND hWnd;
  107.  
  108.    hInst = hInstance; // Store instance handle in our global variable
  109.  
  110.    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  111.       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  112.  
  113.    if (!hWnd)
  114.    {
  115.       return FALSE;
  116.    }
  117.  
  118.    ShowWindow(hWnd, nCmdShow);
  119.    UpdateWindow(hWnd);
  120.  
  121.    return TRUE;
  122. }
  123.  
  124. //
  125. //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  126. //
  127. //  PURPOSE:  Processes messages for the main window.
  128. //
  129. //  WM_COMMAND   - process the application menu
  130. //  WM_PAINT   - Paint the main window
  131. //  WM_DESTROY   - post a quit message and return
  132. //
  133. //
  134. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  135. {
  136.    int wmId, wmEvent;
  137.    PAINTSTRUCT ps;
  138.    HDC hdc;
  139.  
  140.    switch (message)
  141.    {
  142.    case WM_COMMAND:
  143.       wmId    = LOWORD(wParam);
  144.       wmEvent = HIWORD(wParam);
  145.       // Parse the menu selections:
  146.       switch (wmId)
  147.       {
  148.       case IDM_ABOUT:
  149.          DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
  150.          break;
  151.       case IDM_EXIT:
  152.          DestroyWindow(hWnd);
  153.          break;
  154.       default:
  155.          return DefWindowProc(hWnd, message, wParam, lParam);
  156.       }
  157.       break;
  158.    case WM_PAINT:
  159.       hdc = BeginPaint(hWnd, &ps);
  160.       // TODO: Add any drawing code here...
  161.       EndPaint(hWnd, &ps);
  162.       break;
  163.    case WM_DESTROY:
  164.       PostQuitMessage(0);
  165.       break;
  166.    default:
  167.       return DefWindowProc(hWnd, message, wParam, lParam);
  168.    }
  169.    return 0;
  170. }
  171.  
  172. // Message handler for about box.
  173. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  174. {
  175.    UNREFERENCED_PARAMETER(lParam);
  176.    switch (message)
  177.    {
  178.    case WM_INITDIALOG:
  179.       return (INT_PTR)TRUE;
  180.  
  181.    case WM_COMMAND:
  182.       if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  183.       {
  184.          EndDialog(hDlg, LOWORD(wParam));
  185.          return (INT_PTR)TRUE;
  186.       }
  187.       break;
  188.    }
  189.    return (INT_PTR)FALSE;
  190. }


Source forme headera
  1. #pragma once
  2.  
  3. using namespace System;
  4. using namespace System::ComponentModel;
  5. using namespace System::Collections;
  6. using namespace System::Windows::Forms;
  7. using namespace System::Data;
  8. using namespace System::Drawing;
  9.  
  10.  
  11. namespace digitron {
  12.  
  13.    /// <summary>
  14.    /// Summary for forma_digitron
  15.    ///
  16.    /// WARNING: If you change the name of this class, you will need to change the
  17.    ///          'Resource File Name' property for the managed resource compiler tool
  18.    ///          associated with all .resx files this class depends on.  Otherwise,
  19.    ///          the designers will not be able to interact properly with localized
  20.    ///          resources associated with this form.
  21.    /// </summary>
  22.    public ref class forma_digitron : public System::Windows::Forms::Form
  23.    {
  24.    public:
  25.       forma_digitron(void)
  26.       {
  27.          InitializeComponent();
  28.          //
  29.          //TODO: Add the constructor code here
  30.          //
  31.       }
  32.  
  33.    protected:
  34.       /// <summary>
  35.       /// Clean up any resources being used.
  36.       /// </summary>
  37.       ~forma_digitron()
  38.       {
  39.          if (components)
  40.          {
  41.             delete components;
  42.          }
  43.       }
  44.    private: System::Windows::Forms::TextBox^  textBox1;
  45.    protected:
  46.    private: System::Windows::Forms::TextBox^  textBox2;
  47.    private: System::Windows::Forms::Button^  button1;
  48.    private: System::Windows::Forms::Button^  button2;
  49.    private: System::Windows::Forms::Button^  button3;
  50.    private: System::Windows::Forms::Button^  button4;
  51.  
  52.    private:
  53.       /// <summary>
  54.       /// Required designer variable.
  55.       /// </summary>
  56.       System::ComponentModel::Container ^components;
  57.  
  58. #pragma region Windows Form Designer generated code
  59.       /// <summary>
  60.       /// Required method for Designer support - do not modify
  61.       /// the contents of this method with the code editor.
  62.       /// </summary>
  63.       void InitializeComponent(void)
  64.       {
  65.          this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  66.          this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  67.          this->button1 = (gcnew System::Windows::Forms::Button());
  68.          this->button2 = (gcnew System::Windows::Forms::Button());
  69.          this->button3 = (gcnew System::Windows::Forms::Button());
  70.          this->button4 = (gcnew System::Windows::Forms::Button());
  71.          this->SuspendLayout();
  72.          //
  73.          // textBox1
  74.          //
  75.          this->textBox1->Location = System::Drawing::Point(50, 42);
  76.          this->textBox1->Name = L"textBox1";
  77.          this->textBox1->Size = System::Drawing::Size(100, 20);
  78.          this->textBox1->TabIndex = 0;
  79.          //
  80.          // textBox2
  81.          //
  82.          this->textBox2->Location = System::Drawing::Point(199, 42);
  83.          this->textBox2->Name = L"textBox2";
  84.          this->textBox2->Size = System::Drawing::Size(100, 20);
  85.          this->textBox2->TabIndex = 1;
  86.          //
  87.          // button1
  88.          //
  89.          this->button1->Location = System::Drawing::Point(60, 99);
  90.          this->button1->Name = L"button1";
  91.          this->button1->Size = System::Drawing::Size(75, 23);
  92.          this->button1->TabIndex = 2;
  93.          this->button1->Text = L"Saberi";
  94.          this->button1->UseVisualStyleBackColor = true;
  95.          //
  96.          // button2
  97.          //
  98.          this->button2->Location = System::Drawing::Point(215, 99);
  99.          this->button2->Name = L"button2";
  100.          this->button2->Size = System::Drawing::Size(75, 23);
  101.          this->button2->TabIndex = 3;
  102.          this->button2->Text = L"Oduzmi";
  103.          this->button2->UseVisualStyleBackColor = true;
  104.          //
  105.          // button3
  106.          //
  107.          this->button3->Location = System::Drawing::Point(60, 161);
  108.          this->button3->Name = L"button3";
  109.          this->button3->Size = System::Drawing::Size(75, 23);
  110.          this->button3->TabIndex = 4;
  111.          this->button3->Text = L"Podjeli";
  112.          this->button3->UseVisualStyleBackColor = true;
  113.          //
  114.          // button4
  115.          //
  116.          this->button4->Location = System::Drawing::Point(215, 160);
  117.          this->button4->Name = L"button4";
  118.          this->button4->Size = System::Drawing::Size(75, 23);
  119.          this->button4->TabIndex = 5;
  120.          this->button4->Text = L"Pomnozi";
  121.          this->button4->UseVisualStyleBackColor = true;
  122.          this->button4->Click += gcnew System::EventHandler(this, &forma_digitron::button4_Click);
  123.          //
  124.          // forma_digitron
  125.          //
  126.          this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  127.          this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  128.          this->ClientSize = System::Drawing::Size(376, 311);
  129.          this->Controls->Add(this->button4);
  130.          this->Controls->Add(this->button3);
  131.          this->Controls->Add(this->button2);
  132.          this->Controls->Add(this->button1);
  133.          this->Controls->Add(this->textBox2);
  134.          this->Controls->Add(this->textBox1);
  135.          this->Name = L"forma_digitron";
  136.          this->Text = L"forma_digitron";
  137.          this->Load += gcnew System::EventHandler(this, &forma_digitron::forma_digitron_Load);
  138.          this->ResumeLayout(false);
  139.          this->PerformLayout();
  140.  
  141.       }
  142. #pragma endregion
  143.    private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
  144.          MessageBox(NULL, "Klikn na dijeljenje", "Zelite da podjelite", MB_OK);
  145.           }
  146. private: System::Void forma_digitron_Load(System::Object^  sender, System::EventArgs^  e) {
  147.        }
  148. };
  149. }


Dopuna: 19 Apr 2008 10:19

E ovako, greska je bila u tome da pri kreiranju treba da izaberem CLR pa Windows form application, i tek onda je sve pravilno linkovano i sredjeno...

Ko je trenutno na forumu
 

Ukupno su 1216 korisnika na forumu :: 81 registrovanih, 11 sakrivenih i 1124 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: A.R.Chafee.Jr., Ageofloneliness, ajo baba, Aleksandar Tomić, Alexa77, Ares12356, armor, Asteker, Automaticar, Ba4e, babaroga, Bane san, bbrasnjo3, bojcistv, boromir, bukefal, Citalac, comi_pfc, cvrle312, dacanaldo, darkojovxp, del boy, Denaya, Dimitrise93, Django777, doktor097, Dovla 1980, drpera, Duh sa sekirom, eagle.rs, FOX, Georgius, hellenic, janezek67, jon istvan, Kalem, Konda, Kubovac, kybonacci, Lap720, lcc, ljuba, LUDI, Macalone, Mercury, Milos1389, Mskok, nelezele, nemkea71, nenad81, nikolapetkovic, oldtimer, Panter, Parker, Povratak1912, precan, PrincipL, radionica1, raketaš, saki80, sedan, sekretar, sluga, Srle993, Str2022, SympathyForTheDevil, Tafocus, Tibor, Token, trajkoni018, TRZH92, Username1000, vasa.93, Velički, vensla, vidra boy, VJ, vladetije, zdrebac, 1107, 79693