Professional Documents
Culture Documents
Gurpreet DP Documentation Windows
Gurpreet DP Documentation Windows
Problem -1
SUBJECT
SUBMITTED BY:
SUBMITTED TO:
Name: Gurpreet Singh Lec. Mr.
Gaurav Raj
Roll No: 17
Department of CSE
Sec No: RA1805 LOVELY
PROFESSIONAL
Group No: G2
UNIVERSITY
Reg. No: 10805721
PROBLEM:
Create a win32 api based application which is displaying
different information regarding the student such that
student is able to display all the information regarding
him/her.
Expectations-
1. Student must display a menu having the different
options corresponding to the data that they want to
display.
2. Student must display a message box that it is the
version 1(or whatever, he choose), on the screen and
he must display some data on this message box on
the screen regarding the application developed.
3. Student should display an output with variable font
colors and background colors.
4. Student should use all predefined window controls
like Buttons etc.(that are in his course) in his code,
while working on these controls he can display the
information in client area or wherever he choose.
5. Student should comment the code regarding every
new block of code.
6. Student can design his own icon or any other
resource (if he wants, it is not compulsory).
Student should submit the code, resource file and the
executable file to the faculty
Source Code
#include <windows.h>
#include "resource.h"
#define ID_MYBUTTON1 1 //id of clear button
#define ID_MYBUTTON2 2 //id of show details button
#define IDC_HSCROLL 3 //id of horizontal scroll
#define IDC_VERT 4 //id of vertical scroll
#define ID_LISTBOX 5 //id of listbox
LRESULT CALLBACK
WndProc(HWND,UINT,WPARAM,LPARAM); //Forward
Decleration of WndProc function
HINSTANCE hInstance;
hInstance =
(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE);
MessageBox(hwnd,TEXT("Hello"),TEXT("Welcome"),MB_OK
| MB_ICONEXCLAMATION);
i = FALSE;
}
break;
/* This case would run if a menu item is pressed
or a button is pressed */
case WM_COMMAND:
/* Since WPARAM contains which menu item
or button has benn clicked so deciding on the basis of that
*/
switch(wparam)
{
/* this case would be executed when the
clear button is pressed */
case ID_MYBUTTON1:
/* If the list box is visible it would
destroy its contents and hide it */
if(static_check2 == TRUE)
{
ShowWindow(hlistbox,SW_HIDE);
SendMessage(hlistbox,LB_RESETCONTENT,0,0L);
}
/* if any static text or edit box is
visible then it would hide it */
if(static_check == TRUE)
{
ShowWindow(static_name,SW_HIDE);
ShowWindow(edit_name,SW_HIDE);
ShowWindow(static_age,SW_HIDE);
ShowWindow(edit_age,SW_HIDE);
ShowWindow(static_course,SW_HIDE);
ShowWindow(edit_course,SW_HIDE);
ShowWindow(static_stream,SW_HIDE);
ShowWindow(edit_stream,SW_HIDE);
ShowWindow(static_cgpa,SW_HIDE);
ShowWindow(edit_cgpa,SW_HIDE);
ShowWindow(static_regno,SW_HIDE);
ShowWindow(edit_regno,SW_HIDE);
ShowWindow(static_address,SW_HIDE);
ShowWindow(edit_address,SW_HIDE);
ShowWindow(static_phoneno,SW_HIDE);
ShowWindow(edit_phoneno,SW_HIDE);
static_check = FALSE;
}
static_check2 = FALSE;
break;
/* This case would be running when the
Show details button is pressed */
case ID_MYBUTTON2:
/* If the list box is visible it would
destroy its contents and hide it */
if(static_check2 == TRUE)
{
ShowWindow(hlistbox,SW_HIDE);
SendMessage(hlistbox,LB_RESETCONTENT,0,0L);
}
ShowWindow(static_name,SW_HIDE);
ShowWindow(edit_name,SW_HIDE);
ShowWindow(static_age,SW_HIDE);
ShowWindow(edit_age,SW_HIDE);
ShowWindow(static_course,SW_HIDE);
ShowWindow(edit_course,SW_HIDE);
ShowWindow(static_stream,SW_HIDE);
ShowWindow(edit_stream,SW_HIDE);
ShowWindow(static_cgpa,SW_HIDE);
ShowWindow(edit_cgpa,SW_HIDE);
ShowWindow(static_regno,SW_HIDE);
ShowWindow(edit_regno,SW_HIDE);
ShowWindow(static_address,SW_HIDE);
ShowWindow(edit_address,SW_HIDE);
ShowWindow(static_phoneno,SW_HIDE);
ShowWindow(edit_phoneno,SW_HIDE);
static_check = FALSE;
}
ShowWindow(hlistbox,SW_SHOWNORMAL);
/* This will add new items into the
list box */
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Name: Gurpreet Singh"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Age: 21"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Course: B.Tech(Hons.)"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Stream: CSE"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("CGPA: 9.0"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Reg. No. 10805721"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Address: Satnampura, Phagwara"));
SendMessage(hlistbox,LB_ADDSTRING,0,
(LPARAM)TEXT("Phone No. 9779430631"));
break;
break;
static_age =
CreateWindow(TEXT("STATIC"),TEXT("Student Age :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+25,150,18,hwnd,NULL,hInstance,NULL);
edit_age =
CreateWindow(TEXT("EDIT"),TEXT("21"),WS_VISIBLE |
WS_CHILD,
210,50+25,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_course =
CreateWindow(TEXT("STATIC"),TEXT("Student Course :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+50,150,18,hwnd,NULL,hInstance,NULL);
edit_course =
CreateWindow(TEXT("EDIT"),TEXT("B.Tech
(Hons.)"),WS_VISIBLE | WS_CHILD,
210,50+50,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_stream =
CreateWindow(TEXT("STATIC"),TEXT("Student Stream :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+75,150,18,hwnd,NULL,hInstance,NULL);
edit_stream =
CreateWindow(TEXT("EDIT"),TEXT("Computer
Science"),WS_VISIBLE | WS_CHILD,
210,50+75,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_cgpa =
CreateWindow(TEXT("STATIC"),TEXT("Student CGPA :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+100,150,18,hwnd,NULL,hInstance,NULL)
;
edit_cgpa =
CreateWindow(TEXT("EDIT"),TEXT("9.0"),WS_VISIBLE |
WS_CHILD,
210,50+100,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_regno =
CreateWindow(TEXT("STATIC"),TEXT("Student Reg. No. :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+125,150,18,hwnd,NULL,hInstance,NULL)
;
edit_regno =
CreateWindow(TEXT("EDIT"),TEXT("10805721"),WS_VISIBL
E | WS_CHILD,
210,50+125,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_address =
CreateWindow(TEXT("STATIC"),TEXT("Student Address :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+150,150,18,hwnd,NULL,hInstance,NULL)
;
edit_address =
CreateWindow(TEXT("EDIT"),TEXT("Old Stanampura,
Phagwara"),WS_VISIBLE | WS_CHILD,
210,50+150,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_phoneno =
CreateWindow(TEXT("STATIC"),TEXT("Student Phone No. :
"),WS_VISIBLE | SS_CENTER |
WS_CHILD,21,50+175,150,18,hwnd,NULL,hInstance,NULL)
;
edit_phoneno =
CreateWindow(TEXT("EDIT"),TEXT("9779430631"),WS_VISI
BLE | WS_CHILD,
210,50+175,150,18,hwnd,NULL,NULL,hInstance,NULL);
static_check = TRUE;
}
else
{
MessageBox(hwnd,TEXT("Firstly clear the client
area"),TEXT("Warning"),MB_OK | MB_ICONWARNING);
}
break;