We are Permanently Move to vupk.net Please Join us there.
Showing posts with label CS410. Show all posts
Showing posts with label CS410. Show all posts

CS410 GDB Solution Spring 2012

 CS410 GDB Solution Spring 2012

Why it is important to study detailed code or functions of windows / visual programming, rather there are many professional tools like Visual Studio etc. available that do the same in mush less time as compared to write a detailed code.
Solution:
Advantages of using professional tools like Visual Studio etc.
  • Good debuggers
  • Editing running code(when available)
  • Advanced code refactoring capabilities
  • Plugins for source control etc.
  • Automatic error checking, auto-completion etc.

CS410 Assignment No 4 Spring 2012 solution

CS410 Assignment No 4 Spring 2012 solution

Task 1: (Marks = 2)
Draw a simple Window using ‘windows.h’

Task 2: (Marks = 8 (1 + 1 + 2 + 2 + 2))
When program will execute,
1 – Windows Title Bar has text as your VU ID.
2 – In client area, first line of the windows have your name as Name = XYZ       *Replace XYZ with your Name
3 – In next line, a Solid line would be appeared.
4 – After that, Text ‘Current Semester Registered Courses’ will appear. And in next line to that, there will be a dash line.
5 – After step 4, Courses ID with Course names would be displayed (One Course Code and Name per line).
6 – At last, a line is drawn with pattern brush to finish your task.

Sample output screen shot is provided below;


Solution:
#include <windows.h>
LRESULT CALLBACK WndProc(
HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam ) {
switch( msg ) {
case WM_PAINT: {
POINT pntArray[2];
pntArray[0].x=05;
pntArray[0].y=30;
pntArray[1].x=625;
pntArray[1].y=30;
POINT pntArraySec[2];
pntArraySec[0].x=05;
pntArraySec[0].y=90;
pntArraySec[1].x=625;
pntArraySec[1].y=90;
POINT pntArrayThird[2];
pntArrayThird[0].x=05;
pntArrayThird[0].y=250;
pntArrayThird[1].x=625;
pntArrayThird[1].y=250;
PAINTSTRUCT ps;
HDC hDC = BeginPaint( hWnd, &ps );
HPEN PenSolid=CreatePen(PS_SOLID, 2, RGB(0,0,0));
HPEN PenDash=CreatePen(PS_DASH, 1, RGB(0,0,0));
HPEN PenDastDot=CreatePen(PS_DASHDOT, 1, RGB(0,0,0));
TextOut(hDC, 20, 05, “Name: XYZ”, 9);
SelectObject(hDC,PenSolid);
Polyline(hDC, pntArray, 2);
TextOut(hDC, 20, 60, “Current Semester Registered Courses”, 35);
SelectObject(hDC,PenDash);
Polyline(hDC, pntArraySec, 2);
TextOut(hDC, 20, 120, “CS410 Visual Programming”, 34);
TextOut(hDC, 20, 140, “CS410 Visual Programming”, 34);
TextOut(hDC, 20, 160, “CS410 Visual Programming”, 34);
TextOut(hDC, 20, 180, “CS410 Visual Programming”, 34);
TextOut(hDC, 20, 200, “CS410 Visual Programming”, 34);
TextOut(hDC, 20, 200, “CS410 Visual Programming”, 34);
SelectObject(hDC,PenDastDot);
Polyline(hDC, pntArrayThird, 2);
EndPaint( hWnd, &ps );
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc( hWnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wce;
wce.cbSize = sizeof(wce);
wce.style = CS_VREDRAW | CS_HREDRAW;
wce.lpfnWndProc = (WNDPROC) WndProc;
wce.cbClsExtra = 0;
wce.cbWndExtra = 0;
wce.hInstance = hInstance;
wce.hIcon = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
wce.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wce.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wce.lpszMenuName = 0;
wce.lpszClassName = “createClass”,
wce.hIconSm = 0;
if (!RegisterClassEx(&wce)) return 0;
HWND hWnd = CreateWindowEx(
0,
“createClass”,
“ABC123 (WRITE YOUR ROLL NUMBER HERE)”,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
650,
500,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow( hWnd, nCmdShow );
MSG msg;
int r;
while ((r = GetMessage(&msg, NULL, 0, 0 )) != 0) {
if (r == -1) {
;
}
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
};