Thread: Windows Skelton Help

  1. #1
    redsoxj69
    Guest

    Windows Skelton Help

    Hi, i am typing a code in C. i am trying to get my code in a windows skelton and i can't get it to work. when i put my code in the workspace it still compiles into a DOS window. is this because this program has no extra memory? Please help me.
    here is the code:
    #include <windows.h>

    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
    char szWinName[] = "MyWin";
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    LPSTR lpszArgs, int nWinMode)
    {
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wcl;

    wcl.cbSize = sizeof(WNDCLASSEX);

    wcl.hInstance = hThisInst;
    wcl.lpszClassName = szWinName;
    wcl.lpfnWndProc = WindowFunc;
    wcl.style = 0;

    wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcl.hIconSm = NULL;
    wcl.hCursor = LoadCursor(NULL, IDC_ARROW);

    wcl.lpszMenuName = NULL;
    wcl.cbClsExtra = 0;
    wcl.cbWndExtra = 0;

    wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

    if(!RegisterClassEx(&wcl)) return 0;

    hwnd = CreateWindow(
    szWinName,
    "Windows 2000 Skeleton",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    NULL,
    NULL,
    hThisInst,
    NULL
    );

    ShowWindow(hwnd, nWinMode);
    UpdateWindow(hwnd);

    while(GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return msg.wParam;
    }


    LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
    WPARAM wParam, LPARAM lParam)
    {
    switch(message) {
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hwnd, message, wParam, lParam);
    }
    return 0;
    }

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    First off, use code tags - please.

    Secondly what compiler are you using? If you are using MSVC then
    you have to make sure you create a new Win32 app and NOT a
    new Win32 Console App.

    Another thing I noticed is that you left out WS_VISIBLE in your
    call to CreateWindow.

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    You're trying to get your code into a windows skeleton, but when you try to put your code into the workspace it still compiles a dos box.

    What compiler are you using?
    What are you doing when you try to "put the code into the workspace"?

    [ c o d e ]

    // BOO

    [ / c o d e ]

    Without any spaces...

    Code:
        // BOO
    Code tags are your friend.

    - edit -
    Nearly indentical posts...woah. Well, he has help now.
    The world is waiting. I must leave you now.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by jdinger

    Another thing I noticed is that you left out WS_VISIBLE in your
    call to CreateWindow.

    No need as he is calling ShowWindow() right after it....


    But echo the above....you need to disclose the compiler you are using.......

    If you need a windows compiler....try downloading DevC++ or get a magazine that has codewarrior on it (details of both of these compilers are peppered on this board)

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Ah! Thanks, Fordy. I skimmed the code and didn't even pay
    attention to the call to ShowWindow().

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    57
    If you are using Dev-C++ then all you gotta do is go to:

    Options --> Compiler Options --> Linker Tab -->

    Then check the COmpile as win32.

    Something like that, i use MSVC right now.
    Language: C++
    Compiler: Visual C++ 6.0
    Currently Working On: Simple OpenGL aspects

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Anyone using Windows 7?
    By Sharke in forum General Discussions
    Replies: 60
    Last Post: 07-12-2009, 08:05 AM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  4. Dos differences in Windows NT and Windows XP
    By Ruchikar in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 09-17-2003, 11:36 PM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM