Framework application

Framework
Framework

This is a sample of an empty window. Great to start your application. Copy this code into your main.cpp and go. Or Download the solution(MS Visual Studio.NET) There's really nothing to it. Anyone who wants create an application quickly has to have something like this. Just don't use the MFC wizard. I always use CREATESTRUCT in the WndProc instead of having a global HINSTANCE handle. Don't use globals unless you really have to. In my opinion globals make messy applications.
#define   STRICT

#include  <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   CREATESTRUCT            *cs;

   switch (iMsg)
   {
   case WM_CREATE :
      cs = (LPCREATESTRUCT)lParam;
      break;

   case WM_CLOSE :
      DestroyWindow(hwnd);
      break;

   case WM_DESTROY :
      PostQuitMessage(0);
      break;
   }
   return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
   HWND        hwnd;
   MSG         msg;
   WNDCLASS    wndclass;
   char        szAppName[] = "FrameworkApp";

   wndclass.style         = 0;
   wndclass.lpfnWndProc   = WndProc;
   wndclass.cbClsExtra    = 0;
   wndclass.cbWndExtra    = 0;
   wndclass.hInstance     = hInstance;
   wndclass.hIcon         = LoadIcon(hInstance, szAppName);
   wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
   wndclass.lpszMenuName  = szAppName;
   wndclass.lpszClassName = szAppName;
   RegisterClass(&wndclass);

   hwnd = CreateWindow(szAppName,
      szAppName,
      WS_OVERLAPPEDWINDOW | WS_VISIBLE,
      0, 0, 400, 400,
      NULL, NULL, hInstance, szCmdLine);

   while (GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   return (int)msg.wParam;
}
Articles
info@win32apicode.com