Code:
#include <windows.h>
#include <commdlg.h>
#include "resource.h"
#include "Functions.h"
#include "Variables.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc; //Structure and call RegisterClassEX()
HWND MainWindow;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX); //Size of the structure
wc.style = CS_HREDRAW |CS_VREDRAW; //Class Styles(cs_*), not be confused withwindow Styles(WS_*)This can usually be set to 0.
wc.lpfnWndProc = WndProc; //Pointer to the window procedure for this window class.
wc.cbClsExtra = 0; //Amount of extra data allocated for this class in memory. Usually 0.
wc.cbWndExtra = 0; //Amount of extra data allocatedin memory per window of this type. Usually 0.
wc.hInstance = hInstance; //Handle to application instance( that I got in the first parameter of WinMain().
wc.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor that will be displayed over the window.
wc.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH);//Background brush to set the color of the window.
wc.lpszMenuName = NULL; //Name of a menu resource to use for the windows with this class.
wc.lpszClassName= main_window; //Name to identify the class with.
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, 0);
if(!RegisterClassEx(&wc)) // To check for failure
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}//End of IF
//************************************************************************
MainWindow = CreateWindowEx( //Create a the window
WS_EX_CLIENTEDGE, //Extended windows style
main_window, //Class name
"Busby Cabinets", //Title
WS_OVERLAPPEDWINDOW | WS_MAXIMIZE, //Window style parameter
0,0, CW_USEDEFAULT, CW_USEDEFAULT, //X,Y coordinates or use CW_USEDEFAULT, CW_USEDEFAULT for default positioning
NULL, NULL, hInstance, NULL); //Parent window, menu handle, windows on application handle,
//pointer to window creation data.
//************************************************************************
if(MainWindow == NULL) // Check to make sure that we have a valid handle.
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
//************************************************************************
ShowWindow(MainWindow, nCmdShow);
UpdateWindow(MainWindow);
//************************************************************************
//The Message LOOP
while(GetMessage(&Msg, NULL, 0, 0) > 0) //Gets a message from your application's message queue.
{
TranslateMessage(&Msg); //Requesting the next available message
DispatchMessage(&Msg); //Does some more processing
}
return Msg.wParam;
}
//***********************************************************************
//The Window Procedure
LRESULT CALLBACK WndProc(HWND MainWindow, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HBITMAP hBitmap;
static RECT rect;
static int cxClient, cyClient, cxSource, cySource;
BITMAP bitmap1;
HINSTANCE hInstance;
PAINTSTRUCT ps;
HDC hdc, hdcMem;
switch(msg)
{
case WM_CREATE:
//**************************************************
HMENU hMenuMain;
hMenuMain = LoadMenu(hInst,MAKEINTRESOURCE (IDR_MENU1));
hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
hBitmap = LoadBitmap(hInstance,TEXT("Bee"));
GetObject (hBitmap, sizeof (BITMAP), &bitmap1);
cxSource = bitmap1.bmWidth;
cySource = bitmap1.bmHeight;
SetMenu(MainWindow,hMenuMain);
return 0;
//**************************************************
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint(MainWindow, &ps);
hdcMem = CreateCompatibleDC(hdc);
SelectObject (hdcMem, hBitmap);
SetStretchBltMode(hdc,STRETCH_DELETESCANS);
StretchBlt (hdc,0,0,cxClient, cyClient, hdcMem,0,0,cxSource, cySource, MERGECOPY);
DeleteDC (hdcMem);
EndPaint(MainWindow, &ps);
return 0;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_NEW_BSIGNATURE:
switch (msg)
{
case WM_COMMAND:
MessageBox(MainWindow, TEXT ("BSignature's library is not Implemented at this time."),"BSignature",0);
case WM_CREATE:
HWND Bsignature;
HMENU hmenu;
hmenu = LoadMenu(hInst,MAKEINTRESOURCE (IDR_MENU2));
SetMenu(MainWindow,hmenu);
case WM_PAINT:
InvalidateRect(MainWindow, &rect,TRUE);
Bsignature = CreateWindow(main_window,NULL, WS_CHILD | WS_VISIBLE, 200,
0, 200,200,MainWindow,NULL,hInst,NULL, NULL);
return 0;
}
////////////////////////////////////////////////////////////////////
///////// Menu For BSignature /////////////////////////////////
case ID_FILE_SAVE40012:
return 0;
case ID_FILE_SAVEAS40013:
return 0;
case ID_FILE_CLOSE40014:
case WM_CREATE:
HMENU hMenuMain;
hMenuMain = LoadMenu(hInst,MAKEINTRESOURCE (IDR_MENU1));
SetMenu(MainWindow,hMenuMain);
UpdateWindow(MainWindow);
case ID_EDIT_UNDO40015:
return 0;
case ID_EDIT_REDO40016:
return 0;
case ID_EDIT_UNITSOFMEASURE:
return 0;
case ID_WINDOW:
return 0;
case ID_HELP40019:
return 0;
////////////////////////////////////////////////////////////////////
case ID_NEW_BSELECT:
return 0;
case ID_NEW_KC:
return 0;
case ID_NEW_KC40009:
return 0;
case ID_NEW_EK:
return 0;
case ID_FILE_SAVE40003:
return 0;
case ID_FILE_SAVEAS:
return 0;
case ID_FILE_OPEN40002:
MessageBox(MainWindow, TEXT ("OPEN is not Implemented at this time."),"Open",0);
return 0;
case ID_FILE_EXIT:
SendMessage (MainWindow, WM_CLOSE, 0, 0);
return 0;
case ID_ABOUT:
MessageBox(MainWindow,TEXT ("Version = [Prototype]\n")
TEXT ("Company = [C]\n")
TEXT ("Designer = []\n")
TEXT ("Program = [B]\n"),"About",MB_ICONINFORMATION);
return 0;
break;
}//End Switch
case WM_DESTROY:
DeleteObject(hBitmap);
PostQuitMessage(0);
return 0;
break;
default:
return DefWindowProc(MainWindow, msg, wParam, lParam);
}//End Switch
return 0;
}//End WinProc
//*****************************************************************