If I call the MessageBox function:

MessageBox(NULL, "Message", "Message", MB_OK);

for example, the box will not appear. It will make the beeping sound, though.

Why you do't you put your code down here.

Alright:

#include	<windows.h>
#include	<gl/gl.h>
#include	<gl/glu.h>
#include	<gl/glext.h>

#define ELEMENTS(var) sizeof(var) / sizeof(var[0])

#define TITLE "RPG!"
#define WIDTH 1024
#define HEIGHT 768
#define BITS 16

HDC			hDC = NULL;
HGLRC		hRC = NULL;
HWND		hWnd = NULL;
HINSTANCE	hInstance;

bool		keys[256];
bool		active = TRUE;
bool		fullscreen = TRUE;

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

bool LoadBitmap(char *file, BITMAP *BMP, bool DIB = false)
{
	HBITMAP hBMP;
	
	hBMP = (HBITMAP)LoadImage(GetModuleHandle(NULL), file, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
	if(!hBMP)
	{
		return FALSE;
	}
	GetObject(hBMP, sizeof(BMP), BMP);
	
	if(DIB)
	{
		BITMAPINFOHEADER bmInfoHeader;
		bmInfoHeader.biSize = sizeof(bmInfoHeader);
		bmInfoHeader.biWidth = BMP->bmWidth;
		bmInfoHeader.biHeight = BMP->bmHeight;
		bmInfoHeader.biPlanes = 1;
		bmInfoHeader.biBitCount = 16;
		bmInfoHeader.biCompression = BI_RGB;
		bmInfoHeader.biSizeImage = 0;
		bmInfoHeader.biXPelsPerMeter = 0;
		bmInfoHeader.biYPelsPerMeter = 0;
		bmInfoHeader.biClrUsed = 0;
		bmInfoHeader.biClrImportant = 0;
		
		BITMAPINFO bmInfo;
		bmInfo.bmiHeader = bmInfoHeader;
		
		GetDIBits(hDC, hBMP, 0, BMP->bmHeight, &(BMP->bmBits), &bmInfo, DIB_RGB_COLORS);
	}
	
	DeleteObject(hBMP);
	
	return TRUE;
}

bool LoadTexture(char *textureFile, GLuint *texture)
{
	BITMAP BMP;
	
	glGenTextures(1, texture);
	
	if(!LoadBitmap(textureFile, &BMP))
	{
		return FALSE;
	}
	
	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
	
	glBindTexture(GL_TEXTURE_2D, *texture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	//glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
		
	return TRUE;
}

void ResizeGLScene(GLsizei width, GLsizei height)
{
	if(height == 0)
	{
		height = 1;
	}
	
	glViewport(0, 0, width, height);
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f);
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

bool InitGL()
{
	glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	
	return TRUE;
}

bool DrawGLScene()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	
	glTranslatef(0.0f, 0.0f, -5.0f);
	
	glColor3f(0.0f, 0.0f, 1.0f);
	glBegin(GL_QUADS);
		glVertex3f(0.0f, 1.0f, 0.0f);
		glVertex3f(1.0f, 1.0f, 0.0f);
		glVertex3f(1.0f, 0.0f, 0.0f);
		glVertex3f(0.0f, 0.0f, 0.0f);
	glEnd();
	
	return TRUE;
}

void KillGLWindow()
{
	if(fullscreen)
	{
		ChangeDisplaySettings(NULL, 0);
		ShowCursor(TRUE);
	}
	
	if(hRC)
	{
		if(!wglMakeCurrent(NULL, NULL))
		{
			MessageBox(NULL, "Failed to release DC and RC.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		}
		
		if(!wglDeleteContext(hRC))
		{
			MessageBox(NULL, "Failed to release rendering context.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		}
		hRC = NULL;
	}
	
	if(hDC && !ReleaseDC(hWnd, hDC))
	{
		MessageBox(NULL, "Failed to release device context.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		hDC = NULL;
	}
	
	if(hWnd && !DestroyWindow(hWnd))
	{
		MessageBox(NULL, "Failed to release hWnd.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		hWnd = NULL;
	}
	
	if(!UnregisterClass("OpenGL", hInstance))
	{
		MessageBox(NULL, "Failed to unregister class.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		hInstance = NULL;
	}
}

bool CreateGLWindow(char *title, int width, int height, int bits, bool fullscreenFlag)
{
	GLuint pixelFormat;
	WNDCLASS wc;
	DWORD dwExStyle, dwStyle;
	
	RECT wndRect;
	wndRect.left = 0;
	wndRect.top = 0;
	wndRect.right = width;
	wndRect.bottom = height;
	
	fullscreen = fullscreenFlag;
	
	hInstance = GetModuleHandle(NULL);
	
	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_WINLOGO);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "OpenGL";
	
	if(!RegisterClass(&wc))
	{
		MessageBox(NULL, "Failed to register class.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	if(fullscreen)
	{
		DEVMODE dmScreenSettings;
		memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
		dmScreenSettings.dmSize = sizeof(dmScreenSettings);
		dmScreenSettings.dmPelsWidth = width;
		dmScreenSettings.dmPelsHeight = height;
		dmScreenSettings.dmBitsPerPel = bits;
		dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
		
		if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN != DISP_CHANGE_SUCCESSFUL))
		{
			if(MessageBox(NULL, "The requested fullscreen mode is not supported by\nyour video card.", title, MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
			{
				fullscreen = FALSE;
			}
			else
			{
				MessageBox(NULL, "Program will now close.", title, MB_ICONEXCLAMATION | MB_OK);
				return FALSE;
			}
		}
	}
	
	if(fullscreen)
	{
		dwExStyle = WS_EX_APPWINDOW;
		dwStyle = WS_POPUP;
		ShowCursor(FALSE);
	}
	else
	{
		dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
		dwStyle = WS_OVERLAPPEDWINDOW;
	}
	
	AdjustWindowRectEx(&wndRect, dwStyle, FALSE, dwExStyle);
	
	hWnd = CreateWindowEx(dwExStyle,
						  "OpenGL",
						  title,
						  dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
						  0,
						  0,
						  wndRect.right - wndRect.left,
						  wndRect.bottom - wndRect.top,
						  NULL,
						  NULL,
						  hInstance,
						  NULL);
	
	if(!hWnd)
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to create window.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	static PIXELFORMATDESCRIPTOR pfd;
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = bits;
	pfd.cDepthBits = 16;
	pfd.iLayerType = PFD_MAIN_PLANE;
	
	hDC = GetDC(hWnd);
	if(!hDC)
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to create GL device context.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	pixelFormat = ChoosePixelFormat(hDC, &pfd);
	if(!pixelFormat)
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to find suitable pixel format.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	if(!SetPixelFormat(hDC, pixelFormat, &pfd))
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to set pixel format.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	hRC = wglCreateContext(hDC);
	if(!hRC)
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to create GL rendering context.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	if(!wglMakeCurrent(hDC, hRC))
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to activate GL rendering context.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	ShowWindow(hWnd, SW_SHOW);
	SetForegroundWindow(hWnd);
	SetFocus(hWnd);
	ResizeGLScene(width, height);
	
	if(!InitGL())
	{
		KillGLWindow();
		MessageBox(NULL, "Failed to initialize Open GL.", "Error!", MB_ICONEXCLAMATION | MB_OK);
		return FALSE;
	}
	
	return TRUE;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
		case WM_ACTIVATE:
		{
			if(!HIWORD(wParam))
			{
				active = TRUE;
			}
			else
			{
				active = FALSE;
			}
			
			return 0;
		}
		
		case WM_SYSCOMMAND:
		{
			switch(wParam)
			{
				case SC_SCREENSAVE:
				case SC_MONITORPOWER:
				return 0;
			}
			break;
		}
		
		case WM_CLOSE:
		{
			PostQuitMessage(0);
			return 0;
		}
		
		case WM_KEYDOWN:
		{
			keys[wParam] = TRUE;
			break;
		}
		
		case WM_KEYUP:
		{
			keys[wParam] = FALSE;
			break;
		}
		
		case WM_SIZE:
		{
			ResizeGLScene(LOWORD(lParam), HIWORD(lParam));
			return 0;
		}
	}
	
	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	MSG msg;
	bool quit = FALSE;
	
	if(MessageBox(NULL, "Would you like to run in fullscreen mode?", "Run Fullscreen?", MB_ICONQUESTION | MB_YESNO) == IDNO)
	{
		fullscreen = FALSE;
	}
	
	if(!CreateGLWindow(TITLE, WIDTH, HEIGHT, BITS, fullscreen))
	{
		return 0;
	}
	
	while(!quit)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if(msg.message == WM_QUIT)
			{
				quit = TRUE;
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			if(active)
			{
				if(keys[VK_ESCAPE])
				{
					quit = TRUE;
				}
				else
				{
					DrawGLScene();
					SwapBuffers(hDC);
				}
			}
			
			if(keys[VK_F1])
			{
				keys[VK_F1] = FALSE;
				KillGLWindow();
				fullscreen = !fullscreen;
				if(!CreateGLWindow(TITLE, WIDTH, HEIGHT, BITS, fullscreen))
				{
					return 0;
				}
			}
		}
	}
	
	KillGLWindow();
	return (msg.wParam);
}

The message asking if they want to run in fullscreen mode (line 387) never comes up, it just shows a black screen with the blue square I created.

Give me the source file on share ,because i can't compile it because of the numbers.
Anyway i am a noob in win32 api so i think i can solve your problem.

Are you sure that you can have 2 WndProc?

You can click on the link that says "Toggle Plain Text" and just copy it from there. And the first WndProc is just a definition, because one of the other functions uses it before it is defined. Otherwise it would be a compiler error, and this compiles fine.

I can't even compile it with Dev-C++,
I try to open projects like OpenGL in C ,and WIN API in C ,and none of them can compile it sorry because i am a noob .

You have to set the project as Windows GUI type and add the opengl libraries to the project. But thats alright, thanks for the effort at least.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.