- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •If (!hWnd) return false;
- •If(!RegisterClass(&w)) return false;
- •If(!RegisterClass(&w)) return false;
- •If(!RegisterClass(&w)) return false;
- •InvalidateRect(hWnd,&rt,true);
- •If(!RegisterClass(&w)) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •InvalidateRect(hWnd,&rt,true);
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •If(!RegisterClass(&w)) return false;
If(!RegisterClass(&w)) return false;
hWnd=CreateWindow(ProgName, Title, WS_OVERLAPPEDWINDOW,
200,0,1010,740,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,nShowCmd);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LONG WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND r1,r2,r3,r4;
static HWND rButton[10];
static HWND hStatus;
char bname[40],buf[40];
int i;
static int che=-1;
switch(msg)
{case WM_CREATE:
hStatus=CreateStatusWindow(WS_CHILD|WS_VISIBLE,(LPCSTR)"Вывод",hWnd,ID_STATBAR);
for(i=0;i<5;i++)
{
if (i==0) sprintf(bname,"1");
if (i==1) sprintf(bname,"2");
if (i==2) sprintf(bname,"3");
if (i==3) sprintf(bname,"4");
if (i==4) sprintf(bname,"5");
rButton[i]=CreateWindow("button",bname,WS_TABSTOP|WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|BS_FLAT,500,140+i*20,35,25,hWnd,(HMENU)(ID_BUTTON1+i),NULL,NULL);
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_CHECK1:
{ che=1;
sprintf(buf,"%d",che);
SetWindowText(hStatus,buf);
}
break;
case ID_CHECK2:
{ che=2;
sprintf(buf,"%d",che);
SetWindowText(hStatus,buf);
}
break;
case ID_CHECK3:
{ che=3;
sprintf(buf,"%d",che);
SetWindowText(hStatus,buf);
}
break;
case ID_CHECK4:
{ che=4;
sprintf(buf,"%d",che);
SetWindowText(hStatus,buf);
}
break;
case ID_CHECK5:
{ che=5;
sprintf(buf,"%d",che);
SetWindowText(hStatus,buf);
}
break;
}
break;
case WM_SIZE:
MoveWindow(hStatus,0,0,0,0,TRUE);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
РИСОВАНИЕ ОТРЕЗКА
#include <windows.h>
#define ID_EDIT1 1001
#define ID_EDIT2 1002
#define ID_EDIT3 1003
#define ID_EDIT4 1004
#define ID_BUTTON 2001
HINSTANCE hInst;
LONG MyWinP(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{char ProgName[]="My Window";
char Title[]="Window";
HWND hWnd;
MSG msg;
WNDCLASS w;
w.lpszClassName=ProgName;
w.hInstance=hInstance;
w.lpfnWndProc=(WNDPROC)MyWinP;
w.hCursor=LoadCursor(NULL,IDC_ARROW);
w.hIcon=LoadIcon(NULL,IDI_APPLICATION);
w.lpszMenuName=NULL;
w.hbrBackground=(HBRUSH)(COLOR_WINDOW+7);
w.style=CS_HREDRAW|CS_VREDRAW;
w.cbClsExtra=0;
w.cbWndExtra=0;
hInst=hInstance;
If(!RegisterClass(&w)) return false;
hWnd=CreateWindow(ProgName, Title, WS_OVERLAPPEDWINDOW,
200,30,800,540,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,nShowCmd);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LONG MyWinP(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HDC hdc;
static PAINTSTRUCT ps;
static RECT rt;
static HWND edit1,edit2,edit3,edit4,btn;
static char buf[100],old_edit[100];
static int n_x,n_y,k_x,k_y;
switch(msg)
{case WM_CREATE:
CreateWindow("static","Координаты начала отрезка:",WS_CHILD|WS_VISIBLE|SS_CENTER,150,30,230,20,hWnd,NULL,NULL,NULL);
CreateWindow("static","x:",WS_CHILD|WS_VISIBLE|SS_CENTER,220,55,30,20,hWnd,NULL,NULL,NULL);
CreateWindow("static","y:",WS_CHILD|WS_VISIBLE|SS_CENTER,320,55,30,20,hWnd,NULL,NULL,NULL);
CreateWindow("static","Координаты конца отрезка:",WS_CHILD|WS_VISIBLE|SS_CENTER,390,30,230,20,hWnd,NULL,NULL,NULL);
CreateWindow("static","x:",WS_CHILD|WS_VISIBLE|SS_CENTER,420,55,30,20,hWnd,NULL,NULL,NULL);
CreateWindow("static","y:",WS_CHILD|WS_VISIBLE|SS_CENTER,520,55,30,20,hWnd,NULL,NULL,NULL);
edit1=CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_CENTER|ES_LOWERCASE,200,80,70,20,hWnd,(HMENU)ID_EDIT1,NULL,NULL);
edit2=CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_CENTER|ES_LOWERCASE,300,80,70,20,hWnd,(HMENU)ID_EDIT2,NULL,NULL);
edit3=CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_CENTER|ES_LOWERCASE,400,80,70,20,hWnd,(HMENU)ID_EDIT3,NULL,NULL);
edit4=CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_CENTER|ES_LOWERCASE,500,80,70,20,hWnd,(HMENU)ID_EDIT4,NULL,NULL);
btn=CreateWindow("button","Enter",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,340,130,100,30,hWnd,HMENU(ID_BUTTON),NULL,NULL);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{case ID_BUTTON:
GetWindowText(edit1,buf,sizeof(buf));
n_x=atof(buf);
GetWindowText(edit2,buf,sizeof(buf));
n_y=atof(buf);
GetWindowText(edit3,buf,sizeof(buf));
k_x=atof(buf);
GetWindowText(edit4,buf,sizeof(buf));
k_y=atof(buf);
GetClientRect(hWnd,&rt);