You are on page 1of 3

#include <windows.

h>
#include <fcntl.h>
#include <conio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
// defintion of constants of buttons ui
#define IDBUTTON 102
#define IDBUTTON2 103
#define IDBUTTON3 104
// add buttons as you need as mentioned in the previous lines :)
#define MAX 25

// make your functions prototypes


//for ex :
void file_locking();
//
#define PACKAGE "crlock"
HWND hwndLabel;
/* Make the class name into a global variable */
char szClassName[ ] = "MyFirstProgram";
void display();
void getdata();
void waitTime();
void turnAroundTime();
int n, a[100],b[100];
HINSTANCE g_hInst;
/* Declare Windows procedure */
// generating UI functions and events -- try to read and think of the code
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam){
HWND hwndButton;
switch (message) { /* Handles all Windows Messages */
case WM_COMMAND:{
if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED)){
int iMID;
iMID = LOWORD(wParam);
// reading events
switch(iMID){
case IDBUTTON:{
// Do somthing --> call a function
break;
}
case IDBUTTON2:{
// Do somthing --> call a function
break;
}
/*
add your cases here
*/
default:
break;
}
}
break;
}
case WM_DESTROY:{
PostQuitMessage (0); /* send a WM_QUIT to Message Queue, to shut off program */
break;
}
case WM_CREATE:{
hwndLabel = CreateWindow("STATIC","OS Project",
WS_VISIBLE | WS_CHILD | SS_RIGHT,
60,10,200,200,hwnd,NULL,g_hInst,NULL);
// making the shape of Buttons
hwndButton = CreateWindowEx(0, /* more or ''extended'' styles */
TEXT("BUTTON"), /* GUI ''class'' to create */
TEXT("Btn name"), /* GUI caption */
WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, /* control styles separated by | */
/* put the position*/, /* LEFT POSITION (Position from left) */
/* put the position*/, /* TOP POSITION (Position from Top) */
/* put the position*/, /* WIDTH OF CONTROL */
/* put the position*/, /* HEIGHT OF CONTROL */
hwnd, /* Parent window handle */
(HMENU)IDBUTTON, /* control''s ID for WM_COMMAND */
g_hInst, /* application instance */
NULL);
/*
You can here add any number of buttons :))
*/
}
default: /* messages that we will not process */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
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 */
/* The Window structure */
g_hInst = hThisInstance;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows''s default color as the background of the window */
wincl.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let''s create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"title label", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
700, /* Windows decides the position */
300, /* where the window ends up on the screen */
470, /* The programs width */
300, /* 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 */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, SW_SHOW);
UpdateWindow(hwnd);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/*
your functions here
like allocation and file locking and so on
*

You might also like