Jump to content
  • Advertisement
Sign in to follow this  
Evil Booger

I'm tired of C++

This topic is 4634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm so frustrated...I wish a could make someone come to my house and make my c++ compiler work! I have Borland 5.5 and Dev 4.9.9.2 but none of the source code from my c++ book works! I can't make a blank window without a million errors! Please help before I kill myself.

Share this post


Link to post
Share on other sites
Advertisement
You may be programming, not on a computer, but on a large, sedentary, and confused German Shepherd. That won't work. Make sure that the thing you're programming on has a keyboard (computer!) and not a shaggy coat (dog!).

If you are indeed programming on a computer, post the EXACT code you're using and the EXACT error messages and we can help you.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Booger
Stupid stuff like "undefined symbol in function 1"


Are you making a windows program (with buttons and everything), or a console program? You will get undefined symbol errors if you try to make a program using the Win32 API if you don't create a windows project. In dev-C++ I believe you can do it like this:

project->project options-> and under "type" choose Win32 GUI.

Edit: OOps, that's undefined external. Ignore me.

Share this post


Link to post
Share on other sites
A couple...well more like 3 "Sams Programming C++ in 24 hours"; "Directx Programming in 21 days"; "Programming Role Playing Games with Directx."

Share this post


Link to post
Share on other sites
Here's the code:


//////////////////////////////////////////////////////
// BasicWindowsApp.cpp
//////////////////////////////////////////////////////

#include <windows.h>

// Function prototypes.
LRESULT WINAPI WndProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam);
void RegisterWindowClass(HINSTANCE hInstance);
void CreateAppWindow(HINSTANCE hInstance);
WPARAM StartMessageLoop();

// Global variables.
HWND g_hWnd;


//////////////////////////////////////////////////////
// WinMain()
//////////////////////////////////////////////////////
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT)
{
RegisterWindowClass(hInstance);
CreateAppWindow(hInstance);
ShowWindow(g_hWnd, SW_SHOWDEFAULT);
UpdateWindow(g_hWnd);
INT result = StartMessageLoop();
return result;
}

//////////////////////////////////////////////////////
// WndProc()
//////////////////////////////////////////////////////
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
return 0;

case WM_DESTROY:
PostQuitMessage( 0 );
return 0;

case WM_PAINT:
ValidateRect(g_hWnd, NULL);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}

//////////////////////////////////////////////////////
// RegisterWindowClass()
//////////////////////////////////////////////////////
void RegisterWindowClass(HINSTANCE hInstance)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "WinApp";
wc.hIconSm = NULL;

RegisterClassEx(&wc);
}

//////////////////////////////////////////////////////
// CreateAppWindow()
//////////////////////////////////////////////////////
void CreateAppWindow(HINSTANCE hInstance)
{
g_hWnd = CreateWindowEx(
NULL,
"WinApp",
"Basic Windows Application",
WS_OVERLAPPEDWINDOW,
100,
100,
648,
514,
GetDesktopWindow(),
NULL,
hInstance,
NULL);
}

//////////////////////////////////////////////////////
// StartMessageLoop()
//////////////////////////////////////////////////////
WPARAM StartMessageLoop()
{
MSG msg;
while(1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// Use idle time here.
}
}
return msg.wParam;
}

Share this post


Link to post
Share on other sites
Cool. And the exact error message? (BTW: in the future, if you post your code between [ source] and [ /source] tags (remove the spaces) it will be formatted nicely.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!