|
//******************************************
// Ewan Ward
// Copyright (C) Heavy Horse Research
// Program: OwnerDraw.exe
// FILE: main.CPP
//******************************************
#include "stdafx.h"
#include "MainDlg.h"
#include "commctrl.h"
#define OD_WINDOWNAME "OWNERDRAW_WINDOW"
#define OD_CLASSNAME "OWNERDRAW_CLASS"
HINSTANCE ghInst = NULL;
HWND ghMainWnd = NULL;
HWND ghDlgCurrent = NULL;
//
// FUNCTION: ODWndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK ODWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
UNREFERENCED_PARAMETER(nCmdShow);
ghInst = hInstance; // Store instance handle in our global variable
// setup invisible main window
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)ODWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(ghInst,MAKEINTRESOURCE(IDI_OWNERDRAW));
wc.hCursor = NULL;
wc.hbrBackground = 0;
wc.lpszClassName = OD_CLASSNAME;
wc.lpszMenuName = NULL;
RegisterClass(&wc);
ghMainWnd = CreateWindow(OD_CLASSNAME, OD_WINDOWNAME, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!ghMainWnd)
{
return FALSE;
}
return TRUE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
MSG msg;
HWND my_win = FindWindow(OD_CLASSNAME,OD_WINDOWNAME);
if (my_win)
{
// IEWalker is already running
ExitProcess(1);
}
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
InitCommonControls();
ghDlgCurrent = DoMainDlg(ghMainWnd);
// Main message loop:
while(GetMessage(&msg, NULL, 0, 0))
{
if (NULL == ghDlgCurrent || !IsDialogMessage(ghDlgCurrent, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Having been a jobbing programmer for longer than he cares to remember, he has finally bitten the bullet to seek his fortune with a (fairly recent) start up called "Heavy Horse". They have been doing consultancy for some time, but Ewan has joined them as they make their move into product development. So much for the plug (does this mean a pay rise guys?) He spends far too much time at the keyboard and not enough time with his young family. His favourite things in life are reading, rambling, taking in big gulps of fresh country air, and (last but by no means least!) being a family man.