Professional Documents
Culture Documents
Mobile Computing "Graphic Representation"
Mobile Computing "Graphic Representation"
Practical 1:
“Graphic representation”
Steps
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINMAIN.
Shapes shapes;
Shapes g_flag_shapes;
4) Then write the below code in switch (message) in switch(wm id) below the file exit
case
case ID_SHAPES_LINE:
g_flag_shapes = LINE;
DrawShapes(hWnd);
break;
case ID_SHAPES_CIRCLE:
g_flag_shapes = CIRCLE;
DrawShapes(hWnd);
break;
case ID_SHAPES_RECTANGLE:
g_flag_shapes = RECTANGLE;
DrawShapes(hWnd);
break;
case ID_SHAPES_ELLIPSE:
g_flag_shapes = ELLIPSE;
DrawShapes(hWnd);
break;
5) Now write the method of shapes after completion of case WM_DESTROY:
hdc = GetDC(hWnd);
switch(g_flag_shapes)
{
case LINE :
LineTo(hdc, 100, 100);
break;
case CIRCLE :
Ellipse(hdc, 45,50,60,60);
break;
case RECTANGLE :
Rectangle(hdc, 45, 50, 95, 100);
break;
case ELLIPSE :
Ellipse(hdc, 45, 50,60, 60);
break;
}
ReleaseDC(hWnd, hdc);
6) Now go to the Resource tab, in this tab go to menu folder, in that select IDM_MENU
7) After Help menu make menu name shapes, in shape make Line,, Circle, Rectangle,
Ellipse as shown below:
8) Now open the property window of the Line menu & copy the ID Shown below &
paste in the case you have written in step 4.
Steps
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINMAIN.
3) After include statement define the timer & intialize some variables.
#define ID_TIMER 1
int cx=0,cy=0,xi=2,yi=2;
4) Then inside the switch(wmId) after the code of help menu write the code for start &
stop menu
case ID_START:
SetTimer(hWnd,ID_TIMER,30,NULL);
Break;
case ID_STOP:
KillTimer(hWnd,ID_TIMER);
break;
5) Then inside the WM_PAINT case write the following code after the drawstring code
Rectangle(hdc,0,0,300,300);
if(cx<0||cx>150)
xi=-xi;
if(cy<0||cy>148)
yi=-yi;
cx=cx+xi;
cy=cy+yi;
SelectObject(hdc,hbr);
Ellipse(hdc,cx,cy,cx+30,cy+30);
DeleteObject(hbr);dd
case WM_TIMER:
InvalidateRect(hWnd,NULL,FALSE);
break;
7) Then select the resource tab in that select menu & add additional menu of start & stop
as shown below:
8) Now open the property window of the Line menu & copy the ID Shown below &
paste in the case you have written in step 4.
Steps
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINMAIN.
3) In WM_CREATE case write the code for the starting of the timer as below:
SetTimer (hWnd,1,300,NULL);
return 0;
4) Then after the end of the WM_CREATE case write the Timer case & in that write the
code for timer in this case
case WM_TIMER:
RECT rt1;
HBRUSH hbr;
hdc=GetDC(hWnd);
hbr=CreateSolidBrush (RGB(rand(),rand(),rand()));
SelectObject (hdc,hbr);
GetClientRect (hWnd,&rt1);
FillRect (hdc,&rt1,hbr);
return 0;
5) Then in the WM_DESTOY case write the code for the ending of timer as below:
KillTimer (hWnd,1);
break;
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINMAIN.
3) Then initialize the variables that you are going to use for the defining of buttons.
HWND hn,hn1,hn2;
hn = CreateWindow (TEXT("Edit"),TEXT("This"),WS_CHILD|WS_VISIBLE|
WS_BORDER,10,50,100,20,hWnd,NULL,NULL,NULL);
SetFocus(hn);
hn1 = CreateWindow
(TEXT("Button"),L"PushButton",WS_CHILD|WS_VISIBLE|
WS_BORDER,30,60,130,30,hWnd,NULL,NULL,NULL);
SetFocus (hn1);
hn2 = CreateWindow
(TEXT("Button"),L"RadioButton",WS_CHILD|WS_VISIBLE|
WS_BORDER,90,120,150,60,hWnd,NULL,NULL,NULL);
SetFocus (hn2);
Step:
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINPROC.
SetTimer (hWnd,1,300,NULL);
return 0;
4) The create the case for timer & write the following code in it:
case WM_TIMER:
RECT rt1;
HBRUSH hbr;
hdc=GetDC(hWnd);
hbr=CreateSolidBrush (RGB(rand(),rand(),rand()));
SelectObject (hdc,hbr);
Rectangle(hdc,100,100,200,200);
DeleteObject(hbr);
hbr=CreateSolidBrush (RGB(rand(),rand(),rand()));
SelectObject (hdc,hbr);
Ellipse(hdc,200,200,300,300);
DeleteObject(hbr);
ReleaseDC(hWnd,hdc);
return 0;
5) Then in WM_DESTROY write the following code for Killing the timer
KillTimer (hWnd,1);
Steps:
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINPROC.
3) Then go in Resource tab ,in resource tab go to Dialog folder in that left click & select
the insert dialog.
4) A dialog box will appear containing 2 command buttons. Now insert text box & label
as required.
5) in that select menu & add additional menu of Form & Appl as shown below:
7) Then add the following code in the WNDPROC after the file exit case
case ID_FORM_APP:
DialogBox(hInst, (LPCTSTR)IDD_DIALOG1, hWnd, (DLGPROC)Form);
break;
Step:
1) Click on new file select WCE Application, Give the name to the project, select
next then click finish.
3) Left click the dialog folder insert one dialog, insert label and text as required.
4) Insert one more dialog & insert label & text as required.
6) Now go to the Class Tab & go to the Initinstance & in forward declaration write
following code:
LRESULT CALLBACK Form (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Stream (HWND, UINT, WPARAM, LPARAM);
7) Then go in WndProc in switch(WmId) write the following code below file exit:
case ID_FORM_APPLN:
DialogBox(hInst, (LPCTSTR)IDD_FORM, hWnd, (DLGPROC)Form);
break;
8) Then write the following code for the Form dialog & Stream dialog after the
About code:
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
DialogBox(hInst, (LPCTSTR)IDD_STREAM, hDlg,
(DLGPROC)Stream);
return TRUE;
}
else if (LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) ==
IDCANCEL))
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
Steps:
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINPROC.
Rectangle(hdc,45,50,90,95);
Ellipse(hdc,110,110,160,160);
Steps:
1) Click on new file select WCE Application, Give the name to the project, select next
then click finish.
2) Then in class view select the Global, in global select the WINPROC.
HBRUSH hbr;
hdc = BeginPaint(hWnd, &ps);
hdc=GetDC(hWnd);
hbr=CreateSolidBrush (RGB(rand(),rand(),rand()));
SelectObject (hdc,hbr);
GetClientRect(hWnd, &rt);
FillRect (hdc,&rt,hbr);;