Code:
/*------------------------------------------------------------
Sia k
------------------------------------------------------------*/
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
static BOOL bbutton = FALSE;
WNDPROC ep;
BOOL CALLBACK AboutDlg2Proc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK editProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static CHAR szAppName[] = TEXT ("Hello Lovely Sara") ;
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
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 ;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The, Hello Lovely Sara"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
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)
{
static HBRUSH hbrush;
static HDC hdc;
PAINTSTRUCT ps ;
static int cxchar, cychar, cxclient, cyclient;
TEXTMETRIC tm;
static HINSTANCE hInstance;
switch (message)
{
case WM_CREATE:
hdc = GetDC(hwnd);
GetTextMetrics(hdc, &tm);
cxchar = tm.tmAveCharWidth;
cychar = tm.tmHeight + tm.tmExternalLeading;
ReleaseDC(hwnd, hdc);
hInstance = ((LPCREATESTRUCT) lParam) -> hInstance;
DialogBox (hInstance, TEXT("cal"), hwnd, AboutDlg2Proc) ;
return 0;
case WM_SIZE:
cxclient = LOWORD(lParam);
cyclient = HIWORD(lParam);
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
BOOL CALLBACK AboutDlg2Proc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
static HWND hedit;
static int m, p;
static int n[3];
static HDC hdc;
PAINTSTRUCT ps ;
switch (message)
{
case WM_INITDIALOG :
hedit = GetDlgItem(hDlg, 9); //get a handle on id "9" the editctl
ep = (WNDPROC)SetWindowLong(hedit, GWL_WNDPROC, (LONG)editProc);
SetFocus(hedit);
return FALSE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK:
EndDialog (hDlg, 0) ;
break;
case 10: //plus sign on dlg
n[0] = GetDlgItemInt(hDlg, 9, NULL, FALSE);
SendMessage(hedit, EM_SETSEL, (WPARAM)0, (LPARAM) 11);
SendMessage(hedit, WM_CLEAR, 0, 0);
SetFocus(hedit);
break;
case 12: //equal sign on dlg
bbutton = TRUE;
n[1] = GetDlgItemInt(hDlg, 9, NULL, FALSE);
p = n[1] + n[0];
SetDlgItemInt(hDlg,9, p, FALSE);
SetFocus(hedit);
break;
}
break;
}
return FALSE ;
}
LRESULT CALLBACK editProc (HWND hwedit, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps ;
static char pass2[50];
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hwedit, &ps);
EndPaint(hwedit, &ps);
break;
case WM_CHAR:
if(bbutton == TRUE){
SendMessage(hwedit, EM_SETSEL, (WPARAM)0, (LPARAM) 11);
SendMessage(hwedit, WM_CLEAR, 0, 0);
bbutton = FALSE;
break;
}
}
return CallWindowProc (ep, hwedit, message, wParam, lParam) ;
}