Thread: Simple Windows GUI Application " The system cannot find the file specified"

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    141

    Simple Windows GUI Application " The system cannot find the file specified"

    I'm using DevC++

    And I get this error:
    The system cannot find the file specified

    even though windows.h does exist, and I'm using Windows XP SP2


    Heres my code:
    Code:
    #include <windows.h>
    
    LRESULT CALLBACK WndProc ( HWND, UINT, WPARAM, LPARAM );
    
    static char sClassName[] = "MyClass";
    static HINSTANCE zhInstance = NULL;
    
    int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
        WNDCLASSEX WndClass;
        HWND hwnd;
        MSG Msg;
        
        zhInstance = hInstance;
        
        WndClass.cbSize = sizeof(WNDCLASSEX);
        WndClass.style = NULL;
        WndClass.lpfnWndProc = WndProc;
        WndClass.cbClsExtra = 0;
        WndClass.cbWndExtra = 0;
        WndClass.hInstance = zhInstance;
        WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
        WndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
        WndClass.lpszMenuName = NULL;
        WndClass.lpszClassName = sClassName;
        WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
        
        
        if (!RegisterClassEx(&WndClass)) {
                                         MessageBox( 0,"Error registering Class!","Error!",MB_ICONSTOP | MB_OK );
                                         return 0;
                                         }
                                         
                                         hwnd = CreateWindowEx( WS_EX_STATICEDGE, sClassName, "my first gui! in win32 :P", WS_OVERLAPPED_WINDOW, CW_USEDEFAULT,
                                         CW_USEDEFAULT, 320, 240, NULL, NULL, zhInstance, NULL
                                         
                                          );
                                          
                                          if (hwnd == NULL) {
                                                   
                                                   MessageBox(0, "Error Creating Window!", "Error!", MB_ICONSTOP | MB_OK );
                                                   return 0;
                                                   
                                                   }
                                         
                                         
                                         ShowWindow(hwnd,nCmdShow);
                                         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 ) {
                switch(Message)
                {
                               case WM_CLOSE:
                                    DestroyWindow(hwnd);
                                    break;
                                    
                                    case WM_DESTROY:
                                         PostQuitMessage(0);
                                         break;
                                         
                                         default:
                                                 return DefWindowProc(hwnd,Message,wParam,lParam);
                                                 
                                                 
                                                 } 
                                                 
                                                 return 0;
                               
                               }
                               
                }
    }

  2. #2
    Banned
    Join Date
    Nov 2007
    Posts
    678
    That's awesome *dude* !!!
    Just do not panic, please make sure women and children are at a safe distance from this whole mess, and ... mean while I call for backup force, please, wear this bulletproof jacket also!

    (*_*)

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by manav View Post
    That's awesome *dude* !!!
    Just do not panic, please make sure women and children are at a safe distance from this whole mess, and ... mean while I call for backup force, please, wear this bulletproof jacket also!

    (*_*)
    Eh? Are you going to help me or not? Cause I'm stumped. :/

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Where is windows.h located, and where is Dev-C++ looking for include files? There should be a setting for your project, as well as a global setting.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by medievalelks View Post
    Where is windows.h located, and where is Dev-C++ looking for include files? There should be a setting for your project, as well as a global setting.
    Dunno, I'm a beginner, this is just a C Source File in "My Documents" :P

  6. #6
    Banned
    Join Date
    Nov 2007
    Posts
    678
    :&#112; ok

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    *should be in windows programming*

    Open up Dev, create a new project, choose win32 app. c++ lang (default). Give your project a name and choose to save all files inside of one directory (folder) including the main file you wish to compile. Doing the above will auto-generate a simple window. From that point, goto the project window, add your original main file and del the auto generated one. Save project, compile -

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    That is with Visual Studio, not Dev-C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    May 2008
    Posts
    141
    So I cant make simple windows guis in DevC++? If so, piece of ........ing ......... I have express of visual studio but meh.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No, you can.
    There's just no pre-defined templates.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Quote Originally Posted by Elysia View Post
    That is with Visual Studio, not Dev-C++.
    Hu? I gave instructions for DevC++. Doing the above creates a simple window, a monkey could do it.

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Really? That sounded a lot like VS.
    I don't think I remember anything such, but whatever.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    I've never used VS; I'm a little surprised that the steps are so similar.

  14. #14
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by Oldman47 View Post
    Hu? I gave instructions for DevC++. Doing the above creates a simple window, a monkey could do it.
    lol a monkey, my relatives think you need to be a genius to actually program. LOL

  15. #15
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Moved to the Windows Programming forum.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM