Adding resources

Started by
1 comment, last by chockydavid1983 16 years, 3 months ago
Hey everyone Does anyone have any links that explain really well how to manually add resources to a win32 api console application. I'm using visual c++ 8 express and so don't have resource view. I'm trying to add icons, menus and bitmaps by creating resource.h files and resource.rc files. If you need any more info, please let me know. Thanks, Chris.
Advertisement
Here is an example of what I'm trying to do- add a menu

resource.h

//{{NO_DEPENDENCIES}}// Microsoft Visual C++ generated include file.// Used by menu.rc#ifndef MENU_H#define MENU_H#define IDR_MENU1                       101#define ID_FILE_EXIT                    102#define ID_PRIMITIVE_LINE               103#define ID_PRIMITIVE_RECTANGLE          104#define ID_PRIMITIVE_ELLIPSE            105#define ID_PRIMITIVE_TEXT               106#define ID_PENCOLOR_BLACK               107#define ID_PENCOLOR_WHITE               108#define ID_PENCOLOR_RED                 109#define ID_PENCOLOR_GREEN               110#define ID_PENCOLOR_BLUE                111#define ID_BRUSHCOLOR_BLACK             112#define ID_BRUSHCOLOR_WHITE             113#define ID_BRUSHCOLOR_RED               114#define ID_BRUSHCOLOR_GREEN             115#define ID_BRUSHCOLOR_BLUE              116#define ID_HELP117                      117#define ID_PENSTYLE_SOLID               118#define ID_PENSTYLE_NULL                119#define ID_PENSTYLE_DOTTED              120#define ID_PENSTYLE_DASHED              121#define ID_BRUSHSTYLE_SOLID             122#define ID_BRUSHSTYLE_NULL              123#define ID_BRUSHSTYLE_DIAGONAL          124#define ID_BRUSHSTYLE_CROSS             125#endif // MENU_H


resource.rc

#include "resource.h"#include <windows.h>IDR_MENU1 MENUBEGIN    POPUP "&File"    BEGIN        MENUITEM "E&xit",ID_FILE_EXIT    END    POPUP "&Primitive"    BEGIN        MENUITEM "Line",ID_PRIMITIVE_LINE        MENUITEM "Rectangle",ID_PRIMITIVE_RECTANGLE        MENUITEM "Ellipse",ID_PRIMITIVE_ELLIPSE    END    POPUP "Pe&n Colour"    BEGIN        MENUITEM "Black",ID_PENCOLOR_BLACK        MENUITEM "White",ID_PENCOLOR_WHITE        MENUITEM "Red",ID_PENCOLOR_RED        MENUITEM "Green",ID_PENCOLOR_GREEN        MENUITEM "Blue",ID_PENCOLOR_BLUE    END    POPUP "&Brush Colour"    BEGIN        MENUITEM "Black",ID_BRUSHCOLOR_BLACK        MENUITEM "White",ID_BRUSHCOLOR_WHITE        MENUITEM "Red",ID_BRUSHCOLOR_RED        MENUITEM "Green",ID_BRUSHCOLOR_GREEN        MENUITEM "Blue",ID_BRUSHCOLOR_BLUE    END    POPUP "Pe&n Style"    BEGIN        MENUITEM "Solid",ID_PENSTYLE_SOLID        MENUITEM "Dotted",ID_PENSTYLE_DOTTED        MENUITEM "Dashed",ID_PENSTYLE_DASHED    END    POPUP "Brush &Style"    BEGIN        MENUITEM "Solid",ID_BRUSHSTYLE_SOLID        MENUITEM "Empty",ID_BRUSHSTYLE_NULL        MENUITEM "Diagonal",ID_BRUSHSTYLE_DIAGONAL        MENUITEM "Cross",ID_BRUSHSTYLE_CROSS    ENDEND


menu.cpp

#include <windows.h>#include <string>#include <vector>#include "Shape.h"#include "resource.h"using namespace std;//=========================================================// Globals.const COLORREF BLACK = RGB(0, 0, 0);const COLORREF WHITE = RGB(255, 255, 255);const COLORREF RED   = RGB(255, 0, 0);const COLORREF GREEN = RGB(0, 255, 0);const COLORREF BLUE  = RGB(0, 0, 255);HWND      ghMainWnd = 0;HINSTANCE ghAppInst = 0;HMENU     ghMenu    = 0;vector<Shape*> gShapes;Shape* gShape = 0;bool gMouseDown = false;int gCurrPrimSel       = ID_PRIMITIVE_LINE;int gCurrPenColSel     = ID_PENCOLOR_BLACK;int gCurrBrushColSel   = ID_BRUSHCOLOR_BLACK;int gCurrPenStyleSel   = ID_PENSTYLE_SOLID;int gCurrBrushStyleSel = ID_BRUSHSTYLE_SOLID;LOGPEN gLogPen;LOGBRUSH gLogBrush;//=========================================================// Step 1: Define and implement the window procedure.LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){		// Objects for painting.	HDC hdc = 0;	PAINTSTRUCT ps;	POINT p0;	POINT p1;	switch( msg )	{		case WM_CREATE:		CheckMenuItem(ghMenu, ID_PRIMITIVE_LINE, MF_CHECKED);		CheckMenuItem(ghMenu, ID_PENCOLOR_BLACK, MF_CHECKED);		CheckMenuItem(ghMenu, ID_BRUSHCOLOR_BLACK, MF_CHECKED);		CheckMenuItem(ghMenu, ID_PENSTYLE_SOLID, MF_CHECKED);		CheckMenuItem(ghMenu, ID_BRUSHSTYLE_SOLID, MF_CHECKED);		return 0;	// User selected a menu item.	case WM_COMMAND:		// Determine which menu item.		switch( LOWORD(wParam) )		{		//=======================================		// File Menu              		//=======================================		case ID_FILE_EXIT:			DestroyWindow(ghMainWnd);			return 0;		//=======================================		// Primitive Types (Shape Types)             		//=======================================		case ID_PRIMITIVE_LINE:			CheckMenuItem(ghMenu, ID_PRIMITIVE_LINE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPrimSel, MF_UNCHECKED);			gCurrPrimSel = ID_PRIMITIVE_LINE;			return 0;		case ID_PRIMITIVE_RECTANGLE:			CheckMenuItem(ghMenu, ID_PRIMITIVE_RECTANGLE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPrimSel, MF_UNCHECKED);			gCurrPrimSel = ID_PRIMITIVE_RECTANGLE;			return 0;		case ID_PRIMITIVE_ELLIPSE:			CheckMenuItem(ghMenu, ID_PRIMITIVE_ELLIPSE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPrimSel, MF_UNCHECKED);			gCurrPrimSel = ID_PRIMITIVE_ELLIPSE;			return 0;		//=======================================		// Pen Colors              		//=======================================		case ID_PENCOLOR_BLACK:			CheckMenuItem(ghMenu, ID_PENCOLOR_BLACK, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenColSel, MF_UNCHECKED);			gCurrPenColSel = ID_PENCOLOR_BLACK;			gLogPen.lopnColor = BLACK;			return 0;		case ID_PENCOLOR_WHITE:			CheckMenuItem(ghMenu, ID_PENCOLOR_WHITE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenColSel, MF_UNCHECKED);			gCurrPenColSel = ID_PENCOLOR_WHITE;			gLogPen.lopnColor = WHITE;			return 0;		case ID_PENCOLOR_RED:			CheckMenuItem(ghMenu, ID_PENCOLOR_RED, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenColSel, MF_UNCHECKED);			gCurrPenColSel = ID_PENCOLOR_RED;			gLogPen.lopnColor = RED;			return 0;		case ID_PENCOLOR_GREEN:			CheckMenuItem(ghMenu, ID_PENCOLOR_GREEN, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenColSel, MF_UNCHECKED);			gCurrPenColSel = ID_PENCOLOR_GREEN;			gLogPen.lopnColor = GREEN;			return 0;		case ID_PENCOLOR_BLUE:			CheckMenuItem(ghMenu, ID_PENCOLOR_BLUE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenColSel, MF_UNCHECKED);			gCurrPenColSel = ID_PENCOLOR_BLUE;			gLogPen.lopnColor = BLUE;			return 0;		//=======================================		// Brush Colors              		//=======================================		case ID_BRUSHCOLOR_BLACK:			CheckMenuItem(ghMenu, ID_BRUSHCOLOR_BLACK, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushColSel, MF_UNCHECKED);			gCurrBrushColSel = ID_BRUSHCOLOR_BLACK;			gLogBrush.lbColor = BLACK;			return 0;		case ID_BRUSHCOLOR_WHITE:			CheckMenuItem(ghMenu, ID_BRUSHCOLOR_WHITE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushColSel, MF_UNCHECKED);			gCurrBrushColSel = ID_BRUSHCOLOR_WHITE;			gLogBrush.lbColor = WHITE;			return 0;		case ID_BRUSHCOLOR_RED:			CheckMenuItem(ghMenu, ID_BRUSHCOLOR_RED, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushColSel, MF_UNCHECKED);			gCurrBrushColSel = ID_BRUSHCOLOR_RED;			gLogBrush.lbColor = RED;			return 0;		case ID_BRUSHCOLOR_GREEN:			CheckMenuItem(ghMenu, ID_BRUSHCOLOR_GREEN, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushColSel, MF_UNCHECKED);			gCurrBrushColSel = ID_BRUSHCOLOR_GREEN;			gLogBrush.lbColor = GREEN;			return 0;		case ID_BRUSHCOLOR_BLUE:			CheckMenuItem(ghMenu, ID_BRUSHCOLOR_BLUE, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushColSel, MF_UNCHECKED);			gCurrBrushColSel = ID_BRUSHCOLOR_BLUE;			gLogBrush.lbColor = BLUE;			return 0;		//=======================================		// Pen Styles              		//=======================================		case ID_PENSTYLE_SOLID:			CheckMenuItem(ghMenu, ID_PENSTYLE_SOLID, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenStyleSel, MF_UNCHECKED);			gCurrPenStyleSel = ID_PENSTYLE_SOLID;			gLogPen.lopnStyle = PS_SOLID;			return 0;		case ID_PENSTYLE_DOTTED:			CheckMenuItem(ghMenu, ID_PENSTYLE_DOTTED, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenStyleSel, MF_UNCHECKED);			gCurrPenStyleSel = ID_PENSTYLE_DOTTED;			gLogPen.lopnStyle = PS_DOT;			return 0;		case ID_PENSTYLE_DASHED:			CheckMenuItem(ghMenu, ID_PENSTYLE_DASHED, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrPenStyleSel, MF_UNCHECKED);			gCurrPenStyleSel = ID_PENSTYLE_DASHED;			gLogPen.lopnStyle = PS_DASH;			return 0;		//=======================================		// Brush Styles              		//=======================================		case ID_BRUSHSTYLE_SOLID:			CheckMenuItem(ghMenu, ID_BRUSHSTYLE_SOLID, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushStyleSel, MF_UNCHECKED);			gCurrBrushStyleSel = ID_BRUSHSTYLE_SOLID;			gLogBrush.lbStyle = BS_SOLID;			return 0;		case ID_BRUSHSTYLE_NULL:			CheckMenuItem(ghMenu, ID_BRUSHSTYLE_NULL, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushStyleSel, MF_UNCHECKED);			gCurrBrushStyleSel = ID_BRUSHSTYLE_NULL;			gLogBrush.lbStyle = BS_NULL;			return 0;		case ID_BRUSHSTYLE_DIAGONAL:			CheckMenuItem(ghMenu, ID_BRUSHSTYLE_DIAGONAL, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushStyleSel, MF_UNCHECKED);			gCurrBrushStyleSel = ID_BRUSHSTYLE_DIAGONAL;			gLogBrush.lbStyle = BS_HATCHED;			gLogBrush.lbHatch = HS_BDIAGONAL;			return 0;		case ID_BRUSHSTYLE_CROSS:			CheckMenuItem(ghMenu, ID_BRUSHSTYLE_CROSS, MF_CHECKED);			CheckMenuItem(ghMenu, gCurrBrushStyleSel, MF_UNCHECKED);			gCurrBrushStyleSel = ID_BRUSHSTYLE_CROSS;			gLogBrush.lbStyle = BS_HATCHED;			gLogBrush.lbHatch = HS_CROSS;			return 0;		}	// Handle left mouse button click message.	case WM_LBUTTONDOWN:		// Capture the mouse (we still get mouse input 		// even after the mouse cursor moves off the client area.		SetCapture(hWnd);		gMouseDown = true;		// Point that was clicked is stored in the lParam.		p0.x = LOWORD(lParam);		p0.y = HIWORD(lParam);		p1.x = 0;		p1.y = 0;		switch( gCurrPrimSel )		{		case ID_PRIMITIVE_LINE:			gShape = new LineShape(p0, p1, gLogPen, gLogBrush);			break;		case ID_PRIMITIVE_RECTANGLE:			gShape = new RectShape(p0, p1, gLogPen, gLogBrush);			break;		case ID_PRIMITIVE_ELLIPSE:			gShape = new EllipseShape(p0, p1, gLogPen, gLogBrush);			break;		};		return 0;		// Message sent whenever the mouse moves.	case WM_MOUSEMOVE:		if(gMouseDown)		{			// Current mouse position is stored in the lParam.			p1.x = LOWORD(lParam);			p1.y = HIWORD(lParam);			gShape->setEndPt(p1);			InvalidateRect(hWnd, 0, true);		}		return 0;	case WM_LBUTTONUP:				// Release the captured mouse when the left mouse button is lifted.		ReleaseCapture();		gMouseDown = false;		// Current mouse position is stored in the lParam.		p1.x = LOWORD(lParam);		p1.y = HIWORD(lParam);		gShape->setEndPt(p1);		gShapes.push_back( gShape );		InvalidateRect(hWnd, 0, true);		return 0;	case WM_PAINT:		hdc = BeginPaint(hWnd, &ps);		if( gMouseDown )			gShape->draw(hdc);		for(int i = 0; i < (signed)gShapes.size(); ++i)			gShapes->draw(hdc);		EndPaint(hWnd, &ps);	// Handle key down message.	case WM_KEYDOWN:			if( wParam == VK_ESCAPE )			DestroyWindow(ghMainWnd);		return 0;		// Handle destroy window message.	case WM_DESTROY: 			PostQuitMessage(0); 		return 0;		}		// Forward any other messages we didn't handle to the	// default window procedure.	return DefWindowProc(hWnd, msg, wParam, lParam);}// WinMain: Entry point for a Windows application.int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 		PSTR cmdLine, int showCmd){	// Save handle to application instance.	ghAppInst = hInstance;	// Step 2: Fill out a WNDCLASS instance.	WNDCLASS wc; 	wc.style         = CS_HREDRAW | CS_VREDRAW;	wc.lpfnWndProc   = WndProc;	wc.cbClsExtra    = 0;	wc.cbWndExtra    = 0;	wc.hInstance     = ghAppInst;	wc.hIcon         = ::LoadIcon(0, IDI_APPLICATION);	wc.hCursor       = ::LoadCursor(0, IDC_ARROW);	wc.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);	wc.lpszMenuName  = 0;	wc.lpszClassName = "MyWndClassName";	// Step 3: Register the WNDCLASS instance with Windows.	RegisterClass( &wc );	// Step 4: Create the window, and save handle in globla	// window handle variable ghMainWnd.	ghMenu = LoadMenu(ghAppInst, MAKEINTRESOURCE(IDR_MENU1));	ghMainWnd = ::CreateWindow("MyWndClassName", "My Paint Program",   		WS_OVERLAPPEDWINDOW, 200, 200, 640, 480, 0, ghMenu, ghAppInst, 0);	if(ghMainWnd == 0)	{		::MessageBox(0, "CreateWindow - Failed", 0, 0);		return false;	}	// Step 5: Show and update the window.	ShowWindow(ghMainWnd, showCmd);	UpdateWindow(ghMainWnd);	// Step 6: Enter the message loop and don't quit until	// a WM_QUIT message is received.	MSG msg;	ZeroMemory(&msg, sizeof(MSG));	while( GetMessage(&msg, 0, 0, 0) )	{		TranslateMessage(&msg);		DispatchMessage(&msg);	}	for(int i = 0; i < (signed)gShapes.size(); ++i)		delete gShapes;	// Return exit code back to operating system.	return (int)msg.wParam;}


Shape.h

// Shape.h#ifndef SHAPE_H#define SHAPE_H#include <windows.h>class Shape{public:	Shape(const POINT u, const POINT v, 		const LOGPEN& lp, const LOGBRUSH& lb);		virtual~Shape();	void setStartPt(const POINT& p0);	void setEndPt(const POINT& p1);	virtual void draw(HDC hdc) = 0;protected:	POINT  mPt0;	POINT  mPt1;	HPEN   mhPen;	HBRUSH mhBrush;	HPEN mhOldPen;	HBRUSH mhOldBrush;};class LineShape : public Shape{public:	LineShape(const POINT u, const POINT v, 		const LOGPEN& lp, const LOGBRUSH& lb);	void draw(HDC hdc);};class RectShape : public Shape{public:	RectShape(const POINT u, const POINT v, 		const LOGPEN& lp, const LOGBRUSH& lb);	void draw(HDC hdc);};class EllipseShape : public Shape{public:	EllipseShape(const POINT u, const POINT v, 		const LOGPEN& lp, const LOGBRUSH& lb);	void draw(HDC hdc);};#endif // SHAPE_H


Shape.cpp

// Shape.cpp#include "Shape.h"Shape::Shape(const POINT u, const POINT v, 			 const LOGPEN& lp, const LOGBRUSH& lb){	mPt0.x = u.x;	mPt0.y = u.y;	mPt1.x = v.x;	mPt1.y = v.y;	mhPen   = CreatePenIndirect(&lp);	mhBrush = CreateBrushIndirect(&lb);	mhOldPen   = 0;	mhOldBrush = 0;}Shape::~Shape(){	DeleteObject(mhPen);	DeleteObject(mhBrush);}void Shape::setStartPt(const POINT& p0){	mPt0 = p0;}void Shape::setEndPt(const POINT& p1){	mPt1 = p1;}LineShape::LineShape(const POINT u, const POINT v, 		             const LOGPEN& lp, const LOGBRUSH& lb)					 : Shape(u, v, lp, lb){}void LineShape::draw(HDC hdc){	// Select the current pen and brush.	mhOldPen   = (HPEN)SelectObject(hdc, mhPen);	mhOldBrush = (HBRUSH)SelectObject(hdc, mhBrush);	// Draw the line.	MoveToEx(hdc, mPt0.x, mPt0.y, 0);	LineTo(hdc, mPt1.x, mPt1.y);	// Restore the old pen and brush.	SelectObject(hdc, mhOldPen);	SelectObject(hdc, mhOldBrush);}RectShape::RectShape(const POINT u, const POINT v, 		             const LOGPEN& lp, const LOGBRUSH& lb)					 : Shape(u, v, lp, lb){}void RectShape::draw(HDC hdc){	// Select the current pen and brush.	mhOldPen   = (HPEN)SelectObject(hdc, mhPen);	mhOldBrush = (HBRUSH)SelectObject(hdc, mhBrush);	// Draw the rectangle.	Rectangle(hdc, mPt0.x, mPt0.y, mPt1.x, mPt1.y);	// Restore the old pen and brush.	SelectObject(hdc, mhOldPen);	SelectObject(hdc, mhOldBrush);}EllipseShape::EllipseShape(const POINT u, const POINT v, 		                   const LOGPEN& lp, const LOGBRUSH& lb)						   : Shape(u, v, lp, lb){}void EllipseShape::draw(HDC hdc){	// Select the current pen and brush.	mhOldPen   = (HPEN)SelectObject(hdc, mhPen);	mhOldBrush = (HBRUSH)SelectObject(hdc, mhBrush);	// Draw the ellipse.	Ellipse(hdc, mPt0.x, mPt0.y, mPt1.x, mPt1.y);	// Restore the old pen and brush.	SelectObject(hdc, mhOldPen);	SelectObject(hdc, mhOldBrush);}


I get the following errors:

------ Build started: Project: 15.9.1, Configuration: Debug Win32 ------Compiling resources...Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0Copyright (C) Microsoft Corporation.  All rights reserved.Linking...menu.obj : error LNK2028: unresolved token (0A0002B4) "extern "C" int __stdcall EndPaint(struct HWND__ *,struct tagPAINTSTRUCT const *)" (?EndPaint@@$$J18YGHPAUHWND__@@PBUtagPAINTSTRUCT@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A0002B7) "extern "C" int __stdcall DestroyWindow(struct HWND__ *)" (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A0002BC) "extern "C" int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function "extern "C" int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z)menu.obj : error LNK2028: unresolved token (0A0002C6) "extern "C" void __stdcall PostQuitMessage(int)" (?PostQuitMessage@@$$J14YGXH@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A0002CD) "extern "C" struct HWND__ * __stdcall SetCapture(struct HWND__ *)" (?SetCapture@@$$J14YGPAUHWND__@@PAU1@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A0002D5) "extern "C" struct HMENU__ * __stdcall LoadMenuA(struct HINSTANCE__ *,char const *)" (?LoadMenuA@@$$J18YGPAUHMENU__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A0002D7) "extern "C" struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)" (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A0002E4) "extern "C" struct HDC__ * __stdcall BeginPaint(struct HWND__ *,struct tagPAINTSTRUCT *)" (?BeginPaint@@$$J18YGPAUHDC__@@PAUHWND__@@PAUtagPAINTSTRUCT@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A0002EF) "extern "C" int __stdcall TranslateMessage(struct tagMSG const *)" (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A000300) "extern "C" int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PBD1I@Z)menu.obj : error LNK2028: unresolved token (0A000301) "extern "C" int __stdcall InvalidateRect(struct HWND__ *,struct tagRECT const *,int)" (?InvalidateRect@@$$J212YGHPAUHWND__@@PBUtagRECT@@H@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A00030F) "extern "C" struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)" (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A000313) "extern "C" long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)" (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A00031F) "extern "C" int __stdcall ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A000329) "extern "C" long __stdcall DispatchMessageA(struct tagMSG const *)" (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function "extern "C" long __cdecl DispatchMessage(struct tagMSG const *)" (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z)menu.obj : error LNK2028: unresolved token (0A00032D) "extern "C" int __stdcall ReleaseCapture(void)" (?ReleaseCapture@@$$J10YGHXZ) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A000337) "extern "C" int __stdcall UpdateWindow(struct HWND__ *)" (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A000339) "extern "C" struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)" (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A000340) "extern "C" void * __stdcall GetStockObject(int)" (?GetStockObject@@$$J14YGPAXH@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2028: unresolved token (0A000372) "extern "C" unsigned long __stdcall CheckMenuItem(struct HMENU__ *,unsigned int,unsigned int)" (?CheckMenuItem@@$$J212YGKPAUHMENU__@@II@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2028: unresolved token (0A00037B) "extern "C" unsigned short __stdcall RegisterClassA(struct tagWNDCLASSA const *)" (?RegisterClassA@@$$J14YGGPBUtagWNDCLASSA@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)Shape.obj : error LNK2028: unresolved token (0A000024) "extern "C" int __stdcall MoveToEx(struct HDC__ *,int,int,struct tagPOINT *)" (?MoveToEx@@$$J216YGHPAUHDC__@@HHPAUtagPOINT@@@Z) referenced in function "public: virtual void __thiscall LineShape::draw(struct HDC__ *)" (?draw@LineShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2028: unresolved token (0A00002C) "extern "C" int __stdcall LineTo(struct HDC__ *,int,int)" (?LineTo@@$$J212YGHPAUHDC__@@HH@Z) referenced in function "public: virtual void __thiscall LineShape::draw(struct HDC__ *)" (?draw@LineShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2028: unresolved token (0A000038) "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "public: virtual __thiscall Shape::~Shape(void)" (??1Shape@@$$FUAE@XZ)Shape.obj : error LNK2028: unresolved token (0A000039) "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject@@$$J18YGPAXPAUHDC__@@PAX@Z) referenced in function "public: virtual void __thiscall LineShape::draw(struct HDC__ *)" (?draw@LineShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2028: unresolved token (0A00003C) "extern "C" struct HPEN__ * __stdcall CreatePenIndirect(struct tagLOGPEN const *)" (?CreatePenIndirect@@$$J14YGPAUHPEN__@@PBUtagLOGPEN@@@Z) referenced in function "public: __thiscall Shape::Shape(struct tagPOINT,struct tagPOINT,struct tagLOGPEN const &,struct tagLOGBRUSH const &)" (??0Shape@@$$FQAE@UtagPOINT@@0ABUtagLOGPEN@@ABUtagLOGBRUSH@@@Z)Shape.obj : error LNK2028: unresolved token (0A000040) "extern "C" int __stdcall Rectangle(struct HDC__ *,int,int,int,int)" (?Rectangle@@$$J220YGHPAUHDC__@@HHHH@Z) referenced in function "public: virtual void __thiscall RectShape::draw(struct HDC__ *)" (?draw@RectShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2028: unresolved token (0A000041) "extern "C" struct HBRUSH__ * __stdcall CreateBrushIndirect(struct tagLOGBRUSH const *)" (?CreateBrushIndirect@@$$J14YGPAUHBRUSH__@@PBUtagLOGBRUSH@@@Z) referenced in function "public: __thiscall Shape::Shape(struct tagPOINT,struct tagPOINT,struct tagLOGPEN const &,struct tagLOGBRUSH const &)" (??0Shape@@$$FQAE@UtagPOINT@@0ABUtagLOGPEN@@ABUtagLOGBRUSH@@@Z)Shape.obj : error LNK2028: unresolved token (0A000044) "extern "C" int __stdcall Ellipse(struct HDC__ *,int,int,int,int)" (?Ellipse@@$$J220YGHPAUHDC__@@HHHH@Z) referenced in function "public: virtual void __thiscall EllipseShape::draw(struct HDC__ *)" (?draw@EllipseShape@@$$FUAEXPAUHDC__@@@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function "extern "C" int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)" (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" long __stdcall DispatchMessageA(struct tagMSG const *)" (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function "extern "C" long __cdecl DispatchMessage(struct tagMSG const *)" (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,char const *,char const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PBD1I@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)" (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" void __stdcall PostQuitMessage(int)" (?PostQuitMessage@@$$J14YGXH@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall EndPaint(struct HWND__ *,struct tagPAINTSTRUCT const *)" (?EndPaint@@$$J18YGHPAUHWND__@@PBUtagPAINTSTRUCT@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall BeginPaint(struct HWND__ *,struct tagPAINTSTRUCT *)" (?BeginPaint@@$$J18YGPAUHDC__@@PAUHWND__@@PAUtagPAINTSTRUCT@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall ReleaseCapture(void)" (?ReleaseCapture@@$$J10YGHXZ) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall InvalidateRect(struct HWND__ *,struct tagRECT const *,int)" (?InvalidateRect@@$$J212YGHPAUHWND__@@PBUtagRECT@@H@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall SetCapture(struct HWND__ *)" (?SetCapture@@$$J14YGPAUHWND__@@PAU1@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall DestroyWindow(struct HWND__ *)" (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" unsigned long __stdcall CheckMenuItem(struct HMENU__ *,unsigned int,unsigned int)" (?CheckMenuItem@@$$J212YGKPAUHMENU__@@II@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall TranslateMessage(struct tagMSG const *)" (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall UpdateWindow(struct HWND__ *)" (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)" (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" struct HMENU__ * __stdcall LoadMenuA(struct HINSTANCE__ *,char const *)" (?LoadMenuA@@$$J18YGPAUHMENU__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" unsigned short __stdcall RegisterClassA(struct tagWNDCLASSA const *)" (?RegisterClassA@@$$J14YGGPBUtagWNDCLASSA@@@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" void * __stdcall GetStockObject(int)" (?GetStockObject@@$$J14YGPAXH@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)" (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)menu.obj : error LNK2019: unresolved external symbol "extern "C" struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)" (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function "extern "C" int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" struct HBRUSH__ * __stdcall CreateBrushIndirect(struct tagLOGBRUSH const *)" (?CreateBrushIndirect@@$$J14YGPAUHBRUSH__@@PBUtagLOGBRUSH@@@Z) referenced in function "public: __thiscall Shape::Shape(struct tagPOINT,struct tagPOINT,struct tagLOGPEN const &,struct tagLOGBRUSH const &)" (??0Shape@@$$FQAE@UtagPOINT@@0ABUtagLOGPEN@@ABUtagLOGBRUSH@@@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" struct HPEN__ * __stdcall CreatePenIndirect(struct tagLOGPEN const *)" (?CreatePenIndirect@@$$J14YGPAUHPEN__@@PBUtagLOGPEN@@@Z) referenced in function "public: __thiscall Shape::Shape(struct tagPOINT,struct tagPOINT,struct tagLOGPEN const &,struct tagLOGBRUSH const &)" (??0Shape@@$$FQAE@UtagPOINT@@0ABUtagLOGPEN@@ABUtagLOGBRUSH@@@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "public: virtual __thiscall Shape::~Shape(void)" (??1Shape@@$$FUAE@XZ)Shape.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall LineTo(struct HDC__ *,int,int)" (?LineTo@@$$J212YGHPAUHDC__@@HH@Z) referenced in function "public: virtual void __thiscall LineShape::draw(struct HDC__ *)" (?draw@LineShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall MoveToEx(struct HDC__ *,int,int,struct tagPOINT *)" (?MoveToEx@@$$J216YGHPAUHDC__@@HHPAUtagPOINT@@@Z) referenced in function "public: virtual void __thiscall LineShape::draw(struct HDC__ *)" (?draw@LineShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject@@$$J18YGPAXPAUHDC__@@PAX@Z) referenced in function "public: virtual void __thiscall LineShape::draw(struct HDC__ *)" (?draw@LineShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall Rectangle(struct HDC__ *,int,int,int,int)" (?Rectangle@@$$J220YGHPAUHDC__@@HHHH@Z) referenced in function "public: virtual void __thiscall RectShape::draw(struct HDC__ *)" (?draw@RectShape@@$$FUAEXPAUHDC__@@@Z)Shape.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall Ellipse(struct HDC__ *,int,int,int,int)" (?Ellipse@@$$J220YGHPAUHDC__@@HHHH@Z) referenced in function "public: virtual void __thiscall EllipseShape::draw(struct HDC__ *)" (?draw@EllipseShape@@$$FUAEXPAUHDC__@@@Z)C:\Documents and Settings\C Moore Bling\My Documents\Visual Studio 2008\Projects\15.9.1\Debug\15.9.1.exe : fatal error LNK1120: 58 unresolved externalsBuild log was saved at "file://c:\Documents and Settings\C Moore Bling\My Documents\Visual Studio 2008\Projects\15.9.1\15.9.1\Debug\BuildLog.htm"15.9.1 - 59 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


When I run it anyway, it comes up "System cannot find the file specified.

Cheers, Chris.
Hi

I'm really stumped here. I've been looking around at other posts everywhere but I don't understand what they mean. They talk about files not linking properly and not defining stuff that you declare.

For my project, does it have to do with the things I declare in resoure.h and resource.rc and then use in menu.cpp and Shape.cpp?

Chris.

This topic is closed to new replies.

Advertisement