Code:
#include <windows.h>
#include <commctrl.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
/* Global variables */
const int WINSIZEX = 400;
const int WINSIZEY = 300;
HWND hwnd, hwndTab, hwndStatus;
/* End global variables */
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR* szAppName = TEXT("PeaMain");
MSG msg;
WNDCLASS wndclass;
// For main window named "PeaMain"
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
// If we can't register the class, return an error
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT("ERROR This Program Requries NT!"),
szAppName, MB_ICONERROR);
return 0;
}
// Create main window
hwnd = CreateWindowEx (WS_EX_ACCEPTFILES,
szAppName, TEXT("Pea - Encryption / Decryption"),
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_BORDER | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, WINSIZEX, WINSIZEY,
NULL, NULL, hInstance, NULL);
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
TCITEM tcitem;
RECT rect;
HDC hdc;
switch (message)
{
case WM_CREATE:
// Set up for tabbed window
GetClientRect (hwnd, &rect);
InitCommonControls();
// Create tabbed window
hwndTab = CreateWindow (WC_TABCONTROL, "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
0, 0, rect.right + 2, rect.bottom, hwnd, NULL,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
// Create the status window
hwndStatus = CreateWindowEx (WS_EX_DLGMODALFRAME, STATUSCLASSNAME, "",
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
0, 0, 0, 0, hwnd, NULL,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
// Set the text on the status window
SendMessage (hwndStatus, SB_SETTEXT, 0, (LPARAM) TEXT("Standby"));
// Set up tabs
tcitem.mask = TCIF_TEXT;
// Create tabs
tcitem.pszText = "Main";
TabCtrl_InsertItem(hwndTab, 0, &tcitem);
tcitem.pszText = "Encrypt";
TabCtrl_InsertItem(hwndTab, 1, &tcitem);
tcitem.pszText = "Decrypt";
TabCtrl_InsertItem(hwndTab, 2, &tcitem);
tcitem.pszText = "About";
TabCtrl_InsertItem(hwndTab, 3, &tcitem);
// Change tab font
SendMessage (hwndTab, WM_SETFONT,
(WPARAM) GetStockObject (DEFAULT_GUI_FONT), 0);
return 0;
case WM_CLOSE:
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}