mkoday: You should use UINT instead of unsigned for your WndProc's second parameter. Also, if the problem persists, it would most likely be in your GameEnd() code. You should release DirectDraw surfaces before DirectDraw, and also any palettes and clippers, etc. Not just DirectDraw, unless that's a wrapper class you created, in which case you should check the release code in those functions. I'm going to compile the source you posted, and see if it causes that problem.
OK, had to add in some things to get it to compile. Ran it 30 times and at no time did the blank taskbar button show up. Don't forget to link it with ddraw.lib and dxguid.lib. The parts that I modified are well labeled. Here's the modified code, which is a complete Win32 app:
// winmain.cpp
// ADDED
#include "windows.h" // change these to brackets
#include "ddraw.h"
LPDIRECTDRAW g_pDD = NULL;
char* ErrStr = NULL;
void Game_End();
LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
template
inline void SafeRelease(PointerType*& pointer)
{
if( pointer != NULL )
{
pointer->Release();
pointer = NULL;
}
}
bool Init(HINSTANCE hInstance, int nCmdShow)
{
// Register the main window class
WNDCLASS wc;
ZeroMemory(&wc, sizeof(WNDCLASS));
wc.hInstance = hInstance;
wc.lpfnWndProc = WindowProc;
wc.lpszClassName = "My Window";
wc.hIcon = (HICON) LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = (HCURSOR) LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
RegisterClass(&wc);
// Create the main window
HWND hTemp = CreateWindow("My Window", "Main Window", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hTemp, nCmdShow);
return (hTemp != NULL) ? true : false;
}
// ADDED
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg; // message variable
if (!Init(hInstance, nCmdShow)) { // call the Init function
Game_End();
return false;
}
//testMap.Grid[move_x][move_y].WalkInto(pic);
while (true)
{
// Check for new messages to remove and process
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// If we recieve a quit message, break ou the of the main loop
if (msg.message == WM_QUIT)
break;
// Translate and dispatch the message to the MsgHandle function
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Update game logic and render one frame
//testMap.Draw();
// ADDED
Sleep(0);
// ADDED
}
Game_End();
return (msg.wParam);
}
// WindowProc
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return (0);
break;
case WM_KEYDOWN:
switch (wParam)
{
case VK_ESCAPE:
DestroyWindow(hWnd);
break;
default:
break;
}
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0L;
}
// GameEnd()
void Game_End()
{
SafeRelease(g_pDD);
/* REMOVED
if (ErrStr) {
MessageBox(NULL, ErrStr, Caption, MB_OK);
ErrStr = NULL;
}
*/
}
- null_pointer
Sabre Multimedia
Edited by - null_pointer on 4/30/00 7:59:38 AM