Code:
#include <windows.h>
#include <fstream>
#define IDR_MYMENU 101
#define IDI_MYICON 201
#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002
#define ID_OPEN 9003
#define ID_SAVE 9004
#define ID_SELECT 9005
#define ID_MOVE 9006
#define ID_ROTATE 9007
#define ID_SCALE 9008
#define ID_DELETE 9009
#define ID_HELPTOPICS 9010
#define ID_ABOUT 9011
#define IDC_MAIN_EDIT
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_CROSS);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Halo Map Modelin Kit 1.0", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
600, /* The programs width */
400, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
ShowWindow (hwnd, nFunsterStil);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
PAINTSTRUCT ps;
HDC hdc;
case WM_CREATE:
HMENU m_MENU, m_SUBMENU;
m_MENU = CreateMenu();
m_SUBMENU = CreatePopupMenu();
AppendMenu(m_SUBMENU, MF_STRING, ID_OPEN, "&Open");
AppendMenu(m_SUBMENU, MF_STRING, ID_SAVE, "&Save");
AppendMenu(m_SUBMENU, MF_STRING, ID_FILE_EXIT, "&Exit");
AppendMenu(m_MENU, MF_STRING | MF_POPUP, (UINT)m_SUBMENU, "&File");
SetMenu(hwnd, m_MENU);
m_SUBMENU = CreatePopupMenu();
AppendMenu(m_SUBMENU, MF_STRING, ID_SELECT, "&Select");
AppendMenu(m_SUBMENU, MF_STRING, ID_MOVE, "&Move");
AppendMenu(m_SUBMENU, MF_STRING, ID_ROTATE, "&Rotate");
AppendMenu(m_SUBMENU, MF_STRING, ID_SCALE, "&Scale");
AppendMenu(m_SUBMENU, MF_STRING, ID_DELETE, "&Delete");
AppendMenu(m_MENU, MF_STRING | MF_POPUP, (UINT)m_SUBMENU, "&Tools");
SetMenu(hwnd, m_MENU);
m_SUBMENU = CreatePopupMenu();
AppendMenu(m_SUBMENU, MF_STRING, ID_HELPTOPICS, "&Help Topics");
AppendMenu(m_SUBMENU, MF_STRING, ID_ABOUT, "&About");
AppendMenu(m_MENU, MF_STRING | MF_POPUP, (UINT)m_SUBMENU, "&Help");
SetMenu(hwnd, m_MENU);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_LBUTTONDOWN:
break;
case WM_RBUTTONDOWN:
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:
if(MessageBox(hwnd, "Are you sure?", "Leave HaloMapModelinKit", MB_YESNO)== IDYES)
{
PostMessage(hwnd, WM_CLOSE, 0, 0);
}
break;
case ID_STUFF_GO:
break;
case ID_OPEN:
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetOpenFileName(&ofn))
{
// Do something usefull with the filename stored in szFileName
}
break;
}
case ID_SAVE:
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
ofn.lpstrDefExt = "txt";
if(GetSaveFileName(&ofn))
{
// Do something usefull with the filename stored in szFileName
}
break;
}
case ID_ABOUT:
{
// Code here
MessageBox(hwnd, "Halo Map Modelin Kit 1.0 Beta 1\n\nMade By Deadly Shadow\n\nSpecial Thanks to Kaptain Kommie", "About Halo Map Modelin Kit", MB_OK);
}
break;
case ID_HELPTOPICS:
{
// Code here
}
break;
case ID_SELECT:
{
// Code here
}
break;
case ID_MOVE:
{
// Code here
}
break;
case ID_ROTATE:
{
// Code here
}
break;
case ID_SCALE:
{
// Code here
}
break;
case ID_DELETE:
{
// Code here
}
break;
}
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}