Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 4 của 4
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Lỗi chương trình HelloWin ko compile được

    Lỗi chương trình HelloWin ko compile được. Em đọc ebook mới gặp cái code này đã bị lỗi, mấy anh xem giúp em với. Thanks [IMG]images/smilies/biggrin.png[/IMG]


    Mã:
    HELLOWIN.C /*------------------------------------------------------------   HELLOWIN.C -- Displays "Hello, Windows 98!" in client area                 (c) Charles Petzold, 1998  ------------------------------------------------------------*/ #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 ("HelloWin") ;     HWND         hwnd ;     MSG          msg ;     WNDCLASS     wndclass ;      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;     wndclass.lpfnWndProc   = WndProc ;     wndclass.cbClsExtra    = 0 ;     wndclass.cbWndExtra    = 0 ;     wndclass.hInstance     = hInstance ;     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;     wndclass.lpszMenuName  = NULL ;     wndclass.lpszClassName = szAppName ;      if (!RegisterClass (&wndclass))     {          MessageBox (NULL, TEXT ("This program requires Windows NT!"),                       szAppName, MB_ICONERROR) ;          return 0 ;     }     hwnd = CreateWindow (szAppName,                  // window class name                          TEXT ("The Hello Program"), // window caption                          WS_OVERLAPPEDWINDOW,        // window style                          CW_USEDEFAULT,              // initial x position                          CW_USEDEFAULT,              // initial y position                          CW_USEDEFAULT,              // initial x size                          CW_USEDEFAULT,              // initial y size                          NULL,                       // parent window handle                          NULL,                       // window menu handle                          hInstance,                  // program instance handle                          NULL) ;                     // creation parameters          ShowWindow (hwnd, iCmdShow) ;     UpdateWindow (hwnd) ;          while (GetMessage (&msg, NULL, 0, 0))     {          TranslateMessage (&msg) ;          DispatchMessage (&msg) ;     }     return msg.wParam ;} LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){     HDC         hdc ;     PAINTSTRUCT ps ;     RECT        rect ;          switch (message)     {     case WM_CREATE:          PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;          return 0 ;      case WM_PAINT:          hdc = BeginPaint (hwnd, &ps) ;                    GetClientRect (hwnd, &rect) ;                    DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,                    DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;          EndPaint (hwnd, &ps) ;          return 0 ;               case WM_DESTROY:          PostQuitMessage (0) ;          return 0 ;     }     return DefWindowProc (hwnd, message, wParam, lParam) ;}

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    trong phần chú thích của ebook có ghi hướng dẫn thêm vào multimedia library, nhưng em ko biết làm vì hướng dẫn này ko dùng cho Visual Studio 2008.
    - A couple of warnings (2 điểm lưu ý): If you use Microsoft Visual C++ to create a new project for this program, you need to make an addition to the object libraries the linker uses. Select the Settings option from the Project menu, and pick the Link tab. Select General from the Category list box, and add WINMM.LIB ("Windows multimedia") to the Object/Library Modules text box. You need to do this because HELLOWIN makes use of a multimedia function call, and the multimedia object library isn't included in a default project. Otherwise (hoặc là, nếu ko) you'll get an error message from the linker indicating (cho biết) that the PlaySound function is unresolved (ko xử lí được).
    Em ko biết file WINMM.LIB nằm ở đâu. Mấy anh xem giúp em với.

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Nếu bạn dùng Visual studio 2008 thì có thể biên dịch như sau (không cần tạo project):
    Vào:
    Mã:
     Start -> All program -> Microsoft Visual Studio 2008 -> Visual Studio Tools -> Visual Studio 2008 Command Prompt
    Cửa sổ CMD hiện ra, bạn chuyển đến thư mục chứa file HELLOWIN.C (chuyển bằng lệnh cd thư_mục - chắc bạn biết rồi) rồi đánh lệnh sau:
    Mã:
    cl HELLOWIN.C user32.lib gdi32.lib winmm.lib
    Nó sẽ dịch ra file exe cho bạn.

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •