2024-12-22, 14:52 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
Pages: [1]
  Print  
Author Topic: code posting like phoenix (I hate windows)  (Read 4896 times)
0 Members and 1 Guest are viewing this topic.
LooF
 
Imp
**
Posts: 26

« on: 2004-09-08, 20:33 »

whenever I want to make a window I just use this template I wrote and now I never have to do it again.... have fun with it....!

I couldn't use the carrots so... put them yourself

#include windows.h
#include time.h
#include stdio.h

#define class_name "I hate windows"
#define HEIGHT 300
#define WIDTH 300
#define FPS 10

LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR cmdLine, int iShow)
{
   HWND hwnd;
   MSG msg;
   WNDCLASSEX wndclassex = {0};

   wndclassex.cbSize = sizeof(WNDCLASSEX);
   wndclassex.style = CS_HREDRAW | CS_VREDRAW;
   wndclassex.lpfnWndProc = WinProc;
   wndclassex.hInstance = hInstance;
   wndclassex.lpszClassName = class_name;
   wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
   RegisterClassEx(&wndclassex);
   hwnd = CreateWindowEx(NULL,
                    class_name,
                    class_name,
                    WS_SYSMENU | WS_CAPTION,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    WIDTH,
                    HEIGHT,
                    NULL,
                    NULL,
                    hInstance,
                    NULL);
   if(!hwnd)
      return EXIT_FAILURE;
   HDC   hdc = GetDC(hwnd);
   ShowWindow(hwnd, iShow);
   UpdateWindow(hwnd);
   
   while(1)
   {
      if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
      {
         if(msg.message == WM_QUIT)
            break;
            
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
      if(frame(FPS))
         /*********************
         all the magic goes here
         **********************/
   }
   ReleaseDC(hwnd, hdc);
   UnregisterClass(class_name, hInstance);
   return msg.wParam;
}

LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch(message)
   {
   case WM_CLOSE:
   case WM_DESTROY:
      PostQuitMessage(0);
   }
   return(DefWindowProc(hwnd, message, wParam, lParam));
}
« Last Edit: 2004-09-08, 20:37 by LooF » Logged
Phoenix
Bird of Fire
 

Team Member
Elite (7.5k+)
*********
Posts: 8815

WWW
« Reply #1 on: 2004-09-08, 21:14 »

If you use the [code] tags to encapsulate your posting, as I did with mine, you can use any characters you wish and they will not be converted to html tags.[/color]
Logged


I fly into the night, on wings of fire burning bright...
Pages: [1]
  Print  
 
Jump to: