Code
//=================================================================================================
#include <windows.h>
#include <fstream.h>
#include <iostream.h>
//=================================================================================================
std::ofstream Log;
//=================================================================================================
bool InitApplication (HINSTANCE Instance );
//=================================================================================================
LRESULT CALLBACK WindowProcedureMainWindow (HWND Window ,
UINT Message ,
WPARAM First ,
LPARAM Second );
//=================================================================================================
int WINAPI WinMain (HINSTANCE Instance ,
HINSTANCE Previus ,
LPSTR CommandLine,
int Show )
{
Log.open("Log.Log");
Log<<"WinMain ="<<(void *)WinMain <<"."<<endl;
Log<<"InitApplication ="<<(void *)InitApplication <<"."<<endl;
Log<<"WindowProcedureMainWindow="<<(void *)WindowProcedureMainWindow<<"."<<endl;
Log<<"DefWindowProc ="<<(void *)DefWindowProc <<"."<<endl;
Log<<"WinMain is starting."<<endl;
Log<<"Instance ="<<(void *)Instance<<" at "<<(void *)&Instance<<"."<<endl;
Log<<"Previus ="<<(void *)Previus<<" at "<<(void *)&Previus<<"."<<endl;
Log<<"CommandLine=\""<<CommandLine<<"\" at "<<(void *)CommandLine<<", pointer at "<<(void *)&CommandLine<<"."<<endl;
Log<<"Show ="<<Show<<" at "<<(void *)&Show<<"."<<endl;
if (InitApplication(Instance))
{
}
Log.close();
return 0;
}
//=================================================================================================
bool InitApplication (HINSTANCE Instance )
{
char ApplicationName[16]="Sea jackals";
WNDCLASSEX WindowClass;
Log<<"InitApplication is starting."<<endl;
Log<<"ApplicationName=\""<<ApplicationName<<"\" at "<<(void *)ApplicationName<<", pointer at "<<(void *)&ApplicationName<<"."<<endl;
WindowClass.cbSize = sizeof (WindowClass );
WindowClass.style = CS_HREDRAW|
CS_VREDRAW;
WindowClass.lpfnWndProc = WindowProcedureMainWindow;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = Instance;
WindowClass.hIcon = LoadIcon (NULL , IDI_APPLICATION);
WindowClass.hCursor = LoadCursor (NULL , IDC_ARROW );
WindowClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH );
Log<<"WindowClass at "<<(void *)&WindowClass<<"."<<endl;
Log<<"WindowClass.cbSize ="<< WindowClass.cbSize <<" at "<<(void *)&WindowClass.cbSize <<"."<<endl;
Log<<"WindowClass.style ="<< WindowClass.style <<" at "<<(void *)&WindowClass.style <<"."<<endl;
Log<<"WindowClass.lpfnWndProc ="<<(void *)WindowClass.lpfnWndProc <<" at "<<(void *)&WindowClass.lpfnWndProc <<"."<<endl;
Log<<"WindowClass.cbClsExtra ="<< WindowClass.cbClsExtra <<" at "<<(void *)&WindowClass.cbClsExtra <<"."<<endl;
Log<<"WindowClass.cbWndExtra ="<< WindowClass.cbWndExtra <<" at "<<(void *)&WindowClass.cbWndExtra <<"."<<endl;
Log<<"WindowClass.hInstance ="<<(void *)WindowClass.hInstance <<" at "<<(void *)&WindowClass.hInstance <<"."<<endl;
Log<<"WindowClass.hIcon ="<<(void *)WindowClass.hIcon <<" at "<<(void *)&WindowClass.hIcon <<"."<<endl;
Log<<"WindowClass.hCursor ="<<(void *)WindowClass.hCursor <<" at "<<(void *)&WindowClass.hCursor <<"."<<endl;
Log<<"WindowClass.hbrBackground="<<(void *)WindowClass.hbrBackground<<" at "<<(void *)&WindowClass.hbrBackground<<"."<<endl;
return true;
}
//=================================================================================================
LRESULT CALLBACK WindowProcedureMainWindow (HWND Window ,
UINT Message ,
WPARAM First ,
LPARAM Second )
{
switch (Message)
{
case WM_DESTROY: PostQuitMessage(0);
break;
}
return DefWindowProc (Window, Message, First, Second);
}
//=================================================================================================
не компилится из-за строки Code
WindowClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH );
, если её заменить на Code
WindowClass.hbrBackground=NULL;
, то всё эйси. В чём дело и как с этим бороться?
Добавлено (24.04.2012, 05:52)
---------------------------------------------
И хорошо бы декларацию типа WNDCLASSEX.