Hmm, thanks for the reply, but it still doesn''t work
. I''ve added the #ifndef stuff to all of my files, including CPPs. But it still didn''t work! I took the #ifndefs out of the CPPs, but I''ll just give you a little code dump in case I''m missing some really easy-to-solve problem.
// Main.h#ifndef _MAIN_H_#define _MAIN_H_// Optimize Windows#define WIN32_LEAN_AND_MEAN#define INITGUID// #includes#include <windows.h> // Windows header file#include <ddraw.h> // DirectDraw header file// libs#pragma comment (lib,"DDRAW.LIB") // Link the DirectDraw library#pragma comment (lib,"DXGUID.LIB") // Link the DirectX GUID library#pragma comment (lib,"WINMM.LIB") // Link the Windows Media library// #defines// Basic key input#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)// MessageBox()#define MSGBox(text,cap) (MessageBox(NULL,text,cap,MB_OK))#define ErrorMSG(text) (MessageBox(NULL,text,"Error"MB_OK | MB_ICONEXCLAMATION ))// Globalsextern HWND hwnd; // Handle to window extern HDC hdc; // Handle to device contextextern WNDCLASSEX wc; // Window classextern PAINTSTRUCT ps; // Handle to painting structureextern MSG msg; // Handle messages// DirectDraw globalsextern LPDIRECTDRAW lpdd; // Pointer to the DirectDraw interfaceextern LPDIRECTDRAW7 lpdd7; // Pointer to the DirectDraw 7 interface// Function declarationsint WINAPI WinMain(HINSTANCE hInstance, // main() HINSTANCE hPrecInstance, LPSTR lpCmdLine, int nShowCmd);LRESULT CALLBACK WindowProc(HWND hwnd, // Window procedure UINT msg, WPARAM wparam, LPARAM lparam);int Init(); // Initializer functionint Main(); // Main functionint Shutdown(); // Shutdown function#endif// Graphics.h#ifndef _GRAPHICS_H_#define _GRAPHICS_H_// Includes#include "Main.h"// Globals// DirectDraw globalsextern LPDIRECTDRAW lpdd; // Pointer to the DirectDraw interfaceextern LPDIRECTDRAW7 lpdd7; // Pointer to the DirectDraw 7 interface// Function definitionsextern int GInit(); // Graphics initializationextern int GMain(); // Graphics main loopextern int GShutdown(); // Graphics shutdown#endif
// And now for Main.cpp and Graphics.cpp// Main.cpp// Includes#include "Main.h"// GlobalsHWND hwnd; // Handle to window HDC hdc; // Handle to device contextWNDCLASSEX wc; // Window classPAINTSTRUCT ps; // Handle to painting structureMSG msg; // Handle messagesint Init(); // Initializationint Main(); // Main loopint Shutdown(); // Program shutdown// Function definitions//////////////////////////////////////////////////////////////////////int Init(){ return 0;}//////////////////////////////////////////////////////////////////////int Main(){ if(KEYDOWN(VK_ESCAPE)) { Shutdown(); PostQuitMessage(0); } return 0;}//////////////////////////////////////////////////////////////////////int Shutdown(){ return 0;}//////////////////////////////////////////////////////////////////////LRESULT CALLBACK WindowProc(HWND hwnd, // Window Procedure function UINT msg, WPARAM wparam, LPARAM lparam){ // handle messages switch(msg) { case WM_CREATE: // initialization { return (0); } break; case WM_PAINT: // painting { // validate window hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); return (0); } break; case WM_DESTROY: // closing { // kill program PostQuitMessage(0); return (0); } break; default:break; } return (DefWindowProc(hwnd,msg,wparam,lparam));}//////////////////////////////////////////////////////////////////////int WINAPI WinMain(HINSTANCE hInstance, // WinMain() HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){ wc.cbSize = sizeof(WNDCLASSEX); // set the size of window class wc.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC | CS_DBLCLKS; // set the window style wc.lpfnWndProc = WindowProc; // specify function wc.cbClsExtra = 0; // extra class variable wc.cbWndExtra = 0; // extra window variable wc.hInstance = hInstance; // specify instance wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); // specify icon wc.hCursor = LoadCursor(NULL,IDC_ARROW); // specify cursor wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // white background wc.lpszMenuName = NULL; // no menu wc.lpszClassName = "WinClass"; // name of class wc.hIconSm = LoadIcon(NULL,IDI_APPLICATION); // small icon RegisterClassEx(&wc); // create window if (!(hwnd = CreateWindowEx(NULL, // no extended params "WinClass", // class name "Framework", // window name WS_OVERLAPPEDWINDOW | WS_VISIBLE, // popup window 0,0, // start window at top left 640,480, // specify window''s resolution NULL, // handle to parent NULL, // handle to menu hInstance, // handle to instance NULL))) // advanced window creation data { return 0; } UpdateWindow(hwnd); // force Windows to create WM_PAINT message Init(); // initialize program while(GetMessage(&msg,NULL,0,0)) // catch messages { // translate accelerator keys TranslateMessage(&msg); Main(); // main loop // send message to WindowProc() DispatchMessage(&msg); } Shutdown(); // shutdown program return (msg.wParam);}// Now for Graphics.cpp (don''t worry, this is shorter)// Includes#include "Graphics.h"// Globals// DirectDraw globalsLPDIRECTDRAW lpdd = NULL; // Pointer to the DirectDraw interfaceLPDIRECTDRAW7 lpdd7 = NULL; // Pointer to the DirectDraw 7 interface// Function definitionsint GInit(); // Graphics initializationint GMain(); // Graphics main loopint GShutdown(); // Graphics shutdown// Function declarations////////////////////////////////////////////////int GInit(){ // Create the DirectDraw interface DirectDrawCreate( NULL, &lpdd, NULL ); // Upgrade to DirectDraw 7 lpdd->QueryInterface( IID_IDirectDraw7, (LPVOID*)lpdd7 ); return 0;}////////////////////////////////////////////////int GMain(){ return 0;}////////////////////////////////////////////////int GShutdown(){ return 0;}
Whew. If any of you could see what I''m doing wrong, please reply
.