Code:
/*------------------------------------------------------------
Dec 02
Sia k
------------------------------------------------------------*/
#define WIN32_LEAN_AND_MEAN
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glaux.lib")
#pragma comment(linker, "/subsystem:windows")
//-----------------------------------------------
#include <commdlg.h>
#define ID_EDIT 100
#define ID_LIST 101
#define MAXREAD 8192
#define dattr (DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | DDL_SYSTEM |
DDL_DIRECTORY | DDL_ARCHIVE | DDL_DRIVES)
#define dt$$$s (DT_WORDBREAK | DT_EXPANDTABS | DT_NOCLIP | DT_NOPREFIX)
WNDPROC lastlist;
#define ID_TIMER 2
BOOL siachcolor(HWND hwnd); // header for choosecolor common dlg
BOOL FontChooseFont(HWND hwnd); //choose font
void FontDeinitialize(void);
BOOL fontchoosecolor(HWND hwnd);
void FontInitialize(HWND hwnd);
HFONT FontSetFont(HWND hwnd);
void drawrect(HWND hwnd, int cxclient, int cyclient); //draw rec
void FileInitialize (HWND hwnd);
BOOL FileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName);
BOOL filesavedlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName);
void changedlgprop(HWND h, COLORREF cr);
HBITMAP fitbitmap(HBITMAP hBitmap1);
//-----------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "sia0016.h"
#include "resource.h"
#include <commctrl.h>
//-----------------------opengl headers and g_variables
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
float angle = 0.0f;
HDC g_HDC;
//--------------------------
static int e = 50;
HINSTANCE hInstance;
BOOL password = FALSE;
//-------------------------------opengl pixel format
void SetupPixelFormat(HDC hdc)
{
int npixelformat;
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0,};
npixelformat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, npixelformat, &pfd);
}
//--------------------------------
LRESULT CALLBACK circlepushbuttonProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK AboutDlg1Proc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK AboutDlg2Proc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK AboutDlgProc(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, Experimental all in one Program") ;
BOOL done;//opgl
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 (hInstance, MAKEINTRESOURCE(20));
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
wndclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(20));
RegisterClassEx(&wndclass);
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
wndclass.lpfnWndProc = circlepushbuttonProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ; //defining class for custom buttton
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = TEXT ("circlepushbutton") ;
wndclass.hIconSm = NULL;
RegisterClassEx (&wndclass) ;
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The, Hello Lovely Sara, Experimental all in one program"),
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, // 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 HGLRC hRC;//opengl
int width, height;//opengl
static HBRUSH hbrush, hb;
HPEN hpen;
PAINTSTRUCT ps ;
RECT rect;
HDC hdc;
static HDC hdcmem;
static int cxchar, cychar, cxcaps, cxclient,n = 0, u, cyclient, i = 0,j = 0,
y = 0, m = 0, r,
x = 0,cxchard, cychard, cxbuffer, cybuffer;
static short int g;
TEXTMETRIC tm;
static HMENU hmenu, hmenu1,hmpop;
HGLOBAL hgbl;
static HWND hwndedit, hwndlist, hnextclipowner;
POINT point;
static HINSTANCE hInstance;
static HFONT hfont;
static PTSTR phgbl;
static char name[] = TEXT ("sara");
static char *pbuffer = NULL;
static char ptext[50], a3[30];
static char achar;
static BOOL bdraw = FALSE, bwrite = FALSE, bclip = FALSE ;
static COLORREF cr;
DWORD color[3];
int aielements[3] = {COLOR_DESKTOP,
COLOR_MENU,
COLOR_WINDOW};
const DWORD dwresult = RGB(0x3e, 0x7d, 0x77), dwresult1 = RGB(0xba, 0xa8, 0x94); // function return value
static char buf[256];
DWORD bufsize;
const char *compinfo[] = {"Computer Name = ", "User Name = ",
"Path To Windows Directory = ", "Path To Sys Directory = "};
static char *tempinfo = NULL;
static char filename[MAX_PATH], titlename[MAX_PATH] ;
SYSTEMTIME st;
static SIZE size;
static LPTSTR lpszSystemInfo;
switch (message)
{
case WM_CREATE:
hInstance = ((LPCREATESTRUCT) lParam) -> hInstance;
DialogBox (hInstance, TEXT("inf"), hwnd, AboutDlg2Proc) ; //password dlg
if(password == TRUE){
cxchard = LOWORD (GetDialogBaseUnits ()) ;
cychard = HIWORD (GetDialogBaseUnits ()) ;
hwndedit = CreateWindow (TEXT ("edit"), NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
WS_BORDER | ES_LEFT | ES_MULTILINE |
ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 0, 0, hwnd, (HMENU) ID_EDIT,
((LPCREATESTRUCT) lParam) -> hInstance, NULL);
hwndlist =CreateWindow (TEXT ("listbox"), NULL,
WS_CHILDWINDOW | WS_VISIBLE | LBS_STANDARD | WS_BORDER ,
0, 0, 0, 0,hwnd, (HMENU) ID_LIST,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE),
NULL) ;
hmenu = LoadMenu(hInstance, TEXT ("sia0016"));
SetMenu(hwnd, hmenu);
FontInitialize(hwnd); //initializing cmmn dlg choose font
FileInitialize (hwnd) ; ///////////////fileopen dlg
hdc = GetDC(hwnd);
//----------------------- initializing opengl window
g_HDC = hdc;
SetupPixelFormat(hdc);
hRC = wglCreateContext(hdc);
wglMakeCurrent(hdc ,hRC);
//--------------------------------
GetTextMetrics(hdc, &tm);
cxchar = tm.tmAveCharWidth;
cychar = tm.tmHeight + tm.tmExternalLeading;
cxcaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxchar / 2;
pbuffer = (char *)malloc(400 * sizeof(char));
ReleaseDC(hwnd, hdc);
return 0;
}
else
SendMessage(hwnd, WM_CLOSE, 0, 0); //password not correct = close window
case WM_SIZE:
width = cxclient = LOWORD (lParam) ;
height = cyclient = HIWORD (lParam) ;
//---------------------------- //initializing size for opengl
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//------------------------------
return 0;
case WM_TIMER:
bdraw = !bdraw;
InvalidateRect(hwnd, NULL, FALSE);
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
if(n == 3){ //id counter for time menu
GetLocalTime(&st);
wsprintf(ptext, "%.2i:%.2i:%.2i", st.wHour,st.wMinute, st.wSecond);
//get time & date
TextOut(hdc, 0, 0,ptext,strlen(ptext) );
GetDateFormat(LOCALE_SYSTEM_DEFAULT, DATE_LONGDATE, &st, NULL, ptext, sizeof(ptext));
TextOut(hdc, 0, 2 * cychar,ptext,strlen(ptext) );
}
if(bclip == TRUE){
DrawText (hdc, phgbl, -1, &rect, DT_EXPANDTABS) ; //print clipboard content if bool true
bclip = FALSE;
}
if(n == 1){
if(bdraw = TRUE)
drawrect(hwnd, cxclient, cyclient);
}
EndPaint (hwnd, &ps) ;
return 0 ;
/* case WM_NCPAINT:
wdc = GetWindowDC(hwnd);
GetLocalTime(&st);
SetBkColor(wdc, GetSysColor(COLOR_ACTIVECAPTION));
//TextOut(wdc, cxclient - 180, 5, a3, wsprintf(a3, "%.2d:%.2d:%.2d",
// st.wHour, st.wMinute, st.wSecond));
TextOut(wdc, cxclient - 180, 5, "hello", 5);
GetWindowRect(hwnd, &rc);
InvalidateRect(hwnd, &rc, TRUE);
ReleaseDC(hwnd,wdc);
return 0;
case WM_SETFOCUS:
SetFocus(hwnd);
return 0;*/
case WM_KILLFOCUS:
SetFocus(hwndedit);
return 0;
case WM_CHANGECBCHAIN:
if((HWND)wParam == hnextclipowner)
hnextclipowner = (HWND)lParam;
else if(hnextclipowner)
SendMessage(hnextclipowner, message, wParam, lParam);
return 0;
case WM_DRAWCLIPBOARD:
if (hnextclipowner)
SendMessage (hnextclipowner, message, wParam, lParam) ;
InvalidateRect (hwnd, NULL, TRUE) ;
return 0 ;
case WM_COMMAND:
switch(LOWORD (wParam))
{
case 1 :
FileOpenDlg (hwnd, filename, titlename);
return 0;
case 5:
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 0;
case 6:
ExitWindowsEx( EWX_LOGOFF, 0);
return 0;
//logoff windows
case 11:
SendMessage(hwndedit, WM_UNDO, 0, 0);
return 0;
case 12:
SendMessage(hwndedit, WM_CUT, 0, 0);
return 0;
case 13:
SendMessage(hwndedit, WM_COPY, 0, 0);
return 0;
case 14:
SendMessage(hwndedit, WM_PASTE, 0, 0);
return 0;
case 16:
SendMessage(hwndedit, EM_SETSEL, 0, -1);
return 0;
case 17:
bwrite = TRUE;
return 0;
case 18:
bwrite = FALSE;
return 0;
case 20:
SendMessage(hwndedit, WM_CLEAR, 0, 0);
return 0;
case 21:
hmenu = LoadMenu(hInstance, TEXT ("sia0016"));
SetMenu(hwnd, hmenu); //sub menu back to main menu
return 0;
case 22:
bclip = TRUE;
hnextclipowner = SetClipboardViewer (hwnd);
OpenClipboard (hwnd) ;
hgbl = GetClipboardData (CF_TEXT) ;
// view clipboard menu
if (hgbl != NULL)
{
phgbl = (PTSTR) GlobalLock (hgbl) ;
GlobalUnlock (hgbl) ;
}
CloseClipboard ();
return 0;
case 23:
InvalidateRect(hwnd, NULL, TRUE); //terminate clip viwer
return 0;
case 31:
hbrush = CreateSolidBrush(siachcolor(hwnd));
SetClassLong(hwnd, GCL_HBRBACKGROUND, (LONG)hbrush); //background coloring
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case 32:
m++;
cr = siachcolor(hwndedit);
hb = CreateSolidBrush(cr);
InvalidateRect(hwndedit, NULL, TRUE); // choose color for edit
InvalidateRect(hwndlist, NULL, TRUE);
SetFocus(hwndedit);
return 0;
case 33:
color[0] = siachcolor(hwnd); //setting desktop color by using siachcolor func
SetSysColors(1, &aielements[0], &color[0]);
return 0;
case 34:
SetSysColors(1, &aielements[0], &dwresult); //setting original desktop color
return 0;
case 35:
color[1] = siachcolor(hwnd); //setting menu color for system
SetSysColors(1, &aielements[1], &color[1]);
return 0;
case 36:
SetSysColors(1, &aielements[1], &dwresult1); //setting original menu color
return 0;
case 41:
hdc = GetDC(hwnd);
if(FontChooseFont(hwnd)) //custom font using choosefont commn dlg
SelectObject(hdc, FontSetFont(hwnd));
SetTextColor(hdc, fontchoosecolor(hwnd));
ReleaseDC(hwnd, hdc);
r = MessageBox(NULL, "would you like to erase the current window content\'\n' after change of font?","Change Font Msg Box", MB_YESNO);
if(r == IDYES)
InvalidateRect(hwnd, NULL, TRUE);
else
InvalidateRect(hwnd, NULL, FALSE);
return 0;
case 42:
hdc = GetDC(hwnd);
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT))); //choose sys font
SetTextColor(hdc, RGB(0, 0, 0));
ReleaseDC(hwnd, hdc);
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case 51:
ShowWindow(hwndedit, TRUE);
MoveWindow(hwndedit, 0, 0, cxclient / 2, cyclient / 2, TRUE);//edit open
SetFocus(hwndedit);
return 0;
case 52:
SetFocus(hwnd);
MoveWindow(hwndedit, 0, 0, 0, 0, TRUE);
ShowWindow(hwndedit, FALSE); //edit close
return 0;
case 61:
SetTimer(hwnd, ID_TIMER, 1000, NULL);
n = 1;
return 0;
case 62:
n = 2;
KillTimer(hwnd, ID_TIMER);
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case 63:
//printing sara with stroke and filled path
hdc = GetDC(hwnd);
DialogBox (hInstance, TEXT("info"), hwnd, AboutDlg1Proc) ;
hfont = CreateFont(e, 0, 0, 200, FW_EXTRABOLD, 1, 0, 0, ARABIC_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_ROMAN,
"Times New Roman");
SelectObject(hdc, hfont);
GetTextExtentPoint32(hdc, name, lstrlen(name), &size);
hpen = CreatePen(PS_SOLID,2, RGB(255, 0, 0));
SelectObject(hdc, hpen);
SetBkMode(hdc, TRANSPARENT);
MessageBox(hwnd, TEXT(" Please Pick The Font Color of Your Choice"), TEXT("Font Color"), 0);
hbrush = CreateSolidBrush(siachcolor(hwnd));
SelectObject(hdc, hbrush);
BeginPath(hdc);
TextOut(hdc, (cxclient - size.cx) / 2, (cyclient - size.cy) / 2, name, lstrlen(name));
EndPath(hdc);
StrokeAndFillPath(hdc);
ReleaseDC(hwnd, hdc);
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
DeleteObject(SelectObject(hdc, GetStockObject(BLACK_PEN)));
DeleteObject(hbrush);
return 0;
case 64:
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case 65:
n = 4;
InvalidateRect(hwnd, NULL, FALSE);
return 0;
case 66:
n = 5;
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case 67:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
angle = angle + 0.7f;
if(angle >= 360.0f)
angle = 0.0f;
glTranslatef(0.0f, 0.0f, -5.0f);
glColor3f(1.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f, 0.0f, -1.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glEnd();
glColor3f(1.0f, 0.0f, 0.0f);
glRotatef(angle, 0.0f, 1.0f, 0.0f);
glBegin(GL_QUADS);
glVertex3f(1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.2f, 0.0f);
glVertex3f(-1.0f, 0.2f, 0.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);
glEnd();
SwapBuffers(g_HDC);
break;
return 0;
case 68:
hdc = GetDC(hwnd);
wglMakeCurrent(hdc, NULL);
wglDeleteContext(hRC);
if(hdc)
ReleaseDC(hwnd, hdc);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
break;
return 0;
case 71:
ShowWindow(hwndlist, TRUE);
MoveWindow(hwndlist, cxchard, cychard * 20,cxchard * 13 + GetSystemMetrics (SM_CXVSCROLL),
cychard * 10, TRUE);
SetFocus(hwndlist);
return 0;
case 72:
ShowWindow(hwndlist, FALSE);
MoveWindow(hwndlist, 0, cyclient, 0, cyclient, TRUE);
SetFocus(hwnd);
return 0;
case 81:
if(ID_TIMER)
KillTimer(hwnd, ID_TIMER);
n = 4; //boolian for print authoriz in wm_paint
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
tempinfo =(char *) malloc(255 * sizeof(char));
bufsize = sizeof(buf);
GetComputerName(buf, &bufsize); //getting computername and print it
hdc = GetDC(hwnd);
sprintf(tempinfo, "%s %s", *(compinfo + 0), buf);
tempinfo[strlen(tempinfo) + 1] = '\0';
SetBkMode(hdc, GetClassLong(hwnd,GCL_HBRBACKGROUND));
TextOut(hdc, 0, 0, tempinfo, strlen(tempinfo));
tempinfo =(char *) malloc(255 * sizeof(char));
bufsize = sizeof(buf);
GetUserName(buf, &bufsize); //get user name
sprintf(tempinfo, "%s %s", *(compinfo + 1), buf);
tempinfo[strlen(tempinfo) + 1] = '\0';
TextOut(hdc, 0, 30, tempinfo, strlen(tempinfo));
lpszSystemInfo = malloc(255 * sizeof(char));
GetWindowsDirectory(lpszSystemInfo, MAX_PATH+1); //getting windows directory
//lpszSystemInfo[MAX_PATH+1] = '\0';
sprintf(tempinfo, "%s %s", *(compinfo + 2),lpszSystemInfo );
tempinfo[strlen(tempinfo) + 1] = '\0';
TextOut(hdc, 0, 60, tempinfo, lstrlen(tempinfo));
GetSystemDirectory(lpszSystemInfo, MAX_PATH+1); //getting sys dir
sprintf(tempinfo, "%s %s", *(compinfo + 2),lpszSystemInfo );
tempinfo[strlen(tempinfo) + 1] = '\0';
TextOut(hdc, 0, 80, tempinfo, lstrlen(tempinfo));
ReleaseDC(hwnd, hdc);
InvalidateRect(hwnd, NULL, FALSE);
free(tempinfo);
return 0;
case 91:
n = 3;
SetTimer(hwnd, ID_TIMER, 1000, NULL);
// PlaySound (TEXT ("alarm.wav"), NULL, SND_FILENAME | SND_ASYNC); //time date menu
return 0;
case 201:
DialogBox (hInstance, TEXT("infodlg"), hwnd, AboutDlgProc) ;
return 0;
}
break;
case WM_QUERYENDSESSION:
r = MessageBox(NULL, "Shut down?","WM_QUERYENDSESSION", MB_YESNO);
// Return TRUE to allow shutdown, FALSE to stop.
if(r == IDYES)
return TRUE;
else
return FALSE;
break;
case WM_CTLCOLOREDIT:
//setting the hbrbkgr for edi
SetBkColor((HDC)wParam,m > 0 ? cr: RGB(255, 255, 217));
return (LRESULT) hb;
case WM_CTLCOLORLISTBOX:
//setting the hbrbkgr for list
SetBkColor((HDC)wParam,m > 0 ? cr: RGB(255, 255, 217));
return (LRESULT) hb;
case WM_CHAR:
if(bwrite == TRUE){
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
*(pbuffer + x) = (char) wParam;
*(pbuffer + x + 1) = '\0';
TextOut(hdc, i * cxchar, j * cychar , pbuffer + x, 1);
i++;
x++;
if((char) wParam == ('\r') || (i * cxchar) >= cxclient ){
j++;
i = 0;
}
InvalidateRect(hwnd, NULL, FALSE);
ReleaseDC(hwnd, hdc);
}
return 0;
case WM_RBUTTONUP:
hmenu1 = LoadMenu(hInstance, TEXT("sia0016sm"));
SetMenu(hwnd, hmenu1);
hmenu1 = GetSubMenu(hmenu1, 0);
point.x = LOWORD (lParam) ;
point.y = HIWORD (lParam) ;
ClientToScreen (hwnd, &point) ;
TrackPopupMenu (hmenu1, TPM_RIGHTBUTTON, point.x, point.y,
0, hwnd, NULL) ;
return 0 ;
case WM_DESTROY:
hdc = GetDC(hwnd);
DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
SetBkMode(hdc, OPAQUE);
ReleaseDC(hwnd, hdc);
if(pbuffer)
free(pbuffer);
if(ID_TIMER)
KillTimer(hwnd, ID_TIMER);
DeleteObject(hbrush);
if(lpszSystemInfo)
free(lpszSystemInfo);
DeleteObject(hmenu1);
FontDeinitialize();
DeleteObject(hb);
ChangeClipboardChain(hwnd, hnextclipowner);
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
static COLORREF cr1, cr2;
static HWND h1, h2,ht;
switch (message)
{
case WM_INITDIALOG :
h1 = GetDlgItem(hDlg, IDC_S1); //initz handle to ctl windows on dlg
h2 = GetDlgItem(hDlg, IDC_S);
cr1 = siachcolor(h1);
cr2 = siachcolor(h1); //choosing color for dlg box 2 ellipses
//any color we want
return FALSE ;
case WM_PAINT:
changedlgprop(h1, cr1);
//changing the ellipses colors
changedlgprop(h2, cr2);
break;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
EndDialog (hDlg, 0) ;
break;
case 250:
e = 250;
break;
}
break ;
}
return FALSE ;
}
LRESULT CALLBACK circlepushbuttonProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static char text[40] ;
static HBRUSH hBrush ;
static HDC hdc ;
PAINTSTRUCT ps ;
static RECT rect ;
POINT point;
switch (message)
{
case WM_PAINT :
GetClientRect (hwnd, &rect) ;
GetWindowText (hwnd, text, sizeof (text)) ; //customized push button shape ellipse
//color 2
hdc = BeginPaint (hwnd, &ps) ;
hBrush = CreateSolidBrush ( RGB(0, 128, 255));
hBrush = (HBRUSH) SelectObject (hdc, hBrush) ;
Ellipse (hdc, rect.left, rect.top, rect.right, rect.bottom) ;
SetBkColor (hdc, RGB(0, 128, 255));
SetTextColor (hdc, RGB(255, 0, 0)) ;
DrawText (hdc, text, -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
DeleteObject (SelectObject (hdc, hBrush)) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_KEYUP :
if (wParam != VK_SPACE)
break ;
case WM_LBUTTONDOWN:
hdc = GetDC(hwnd);
point.x = LOWORD(lParam);
point.y = HIWORD(lParam);
GetClientRect(hwnd, &rect);
if(PtInRect(&rect, point)){
GetWindowText (hwnd, text, sizeof (text)) ;
hBrush = CreateSolidBrush (RGB(254, 234, 1));
hBrush = (HBRUSH) SelectObject (hdc, hBrush) ;
Ellipse (hdc, rect.left, rect.top, rect.right, rect.bottom) ;
SetBkColor (hdc, RGB(254, 234, 1));
SetTextColor (hdc, RGB(128, 0, 255)) ;
DrawText (hdc, text, -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
DeleteObject (SelectObject (hdc, hBrush)) ;
}
ReleaseDC(hwnd, hdc);
return 0;
case WM_LBUTTONUP :
SendMessage (GetParent (hwnd), WM_COMMAND,
GetWindowLong (hwnd, GWL_ID), 0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
BOOL CALLBACK AboutDlg1Proc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
static COLORREF cr1, cr2;
switch (message)
{
case WM_INITDIALOG :
return FALSE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
EndDialog (hDlg, 0) ;
break;
case two_hundred:
e = 200;
break;
case two_fifty:
e = 250;
break;
case three_hundred:
e = 300; //menu for font size to print sara in
return 0;
case three_fifty: //many sizes using path
e = 350;
break;
case four_hundred:
e = 400;
break;
case four_fifty:
e = 450;
break;
case five_hundred:
e = 500;
break;
case five_fifty:
e = 550;
break;
case six_hundred:
e = 600;
break;
}
break ;
}
return FALSE ;
}
BOOL CALLBACK AboutDlg2Proc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
HWND h3;
LPSTR pass;
const char ba[] = "sara";
switch (message)
{
case WM_INITDIALOG :
h3 = GetDlgItem(hDlg, one_thousand);
SetFocus(h3);
return FALSE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
pass = malloc(20 * sizeof(char));
GetDlgItemText(hDlg, one_thousand, pass, 20); //dlg responsible for password verification
if(strcmp(pass, ba) == 0)
password = TRUE;
free(pass);
EndDialog (hDlg, 0) ;
break;
}
break;
}
return FALSE ;
}