TEXTLAB (1058813), страница 2
Текст из файла (страница 2)
{
switch (wParam)
{
case IDOK:
EndDialog(hDlg, TRUE);
return(TRUE);
default:
return(TRUE);
}
}
return(FALSE);
}
#pragma argsused
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)
{
HWND hWnd, hButton1;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = 5;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szClassName;
if (!RegisterClass(&wndclass))
exit(FALSE);
hWnd = CreateWindow(szClassName,
szWindowName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if (!hWnd)
exit(FALSE);
hInst = hInstance;
RECT rc;
GetWindowRect(hWnd, &rc);
hButton1 = CreateWindow("BUTTON", "Call Dialog", WS_VISIBLE | WS_CHILD,
(rc.right - rc.left - 145) / 2 , (rc.bottom - rc.top) / 2 - 25, 145, 25, hWnd, HMENU (IDM_CALL_DIALOG), hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
// if(!hDlgModeless || !IsDialogMessage(hDlgModeless, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch (iMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_CALL_DIALOG:
// DLGPROC dlgproc = (DLGPROC) MakeProcInstance(WinLab_06_DLG, hInst);
HWND hDlg;
// hDlg = CreateDialog(hInst, MakeProcInstance(WinLab_06_DLG, hInst), hWnd, 0);
break;
}
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
NAME N06
DESCRIPTION 'Term II. Windows Lab 06.'
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120
include "n06.h"
WinLab_06_DLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 22, 17, 144, 75
CAPTION "WinLab_06_DLG"
STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP
BEGIN
CONTROL "Oleg Doubovskoi, IU5-44", -1, "STATIC", WS_GROUP | SS_CENTER, 0, 5, 144, 8
CONTROL "OK", IDOK, "BUTTON", WS_GROUP | BS_DEFPUSHBUTTON, 56, 51, 32, 14
END
#if !defined( __N06_H )
#define __N06_H
#define IDM_CALL_DIALOG 101
#define WinLab_06_DLG 201
#endif // __N06_H
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <string.h>
#define DELIMITERS 5
const char szClassName[] = "WinLab_07";
const char szWindowName[] = "Term II. Windows Lab 07.";
HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
#pragma argsused
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)
{
HWND hWnd;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = 5;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szClassName;
if (!RegisterClass(&wndclass))
exit(FALSE);
hWnd = CreateWindow(szClassName,
szWindowName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if (!hWnd)
exit(FALSE);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (iMessage)
{
case WM_COMMAND:
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
RECT rt;
GetClientRect(hWnd, &rt);
int m_x = ((rt.right - 40) - (rt.left + 40))/(DELIMITERS*2);
int m_y = ((rt.bottom - 40) - (rt.top + 40))/(DELIMITERS*2);
SetBkColor(hdc, RGB(190,190,190));
TextOut(hdc, 10, 10, "Масшаб по оси ОХ (ед.отр/пикс):", strlen("Масшаб по оси ОХ (ед.отр/пикс):"));
TextOut(hdc, 10, 30, "Масшаб по оси ОY (ед.отр/пикс):", strlen("Масшаб по оси ОХ (ед.отр/пикс):"));
char m_x_str[5];
itoa(m_x, m_x_str, 10);
TextOut(hdc, 235, 10, m_x_str, strlen(m_x_str));
char m_y_str[5];
itoa(m_y, m_y_str, 10);
TextOut(hdc, 235, 30, m_y_str, strlen(m_y_str));
int x_center = (rt.right - rt.left)/2;
int y_center = (rt.bottom - rt.top)/2;
TextOut(hdc, x_center - 10, y_center, "0", 1);
MoveTo(hdc, rt.left + 40, y_center);
LineTo(hdc, rt.right - 40, y_center);
TextOut(hdc, rt.right - 30, y_center - 8, "X", 1);
for (int i = 0; i <= DELIMITERS; i++) // цифры
{
MoveTo(hdc, x_center + i*m_x, y_center - 3);
LineTo (hdc, x_center + i*m_x, y_center + 3);
MoveTo(hdc, x_center - i*m_x, y_center - 3);
LineTo (hdc, x_center - i*m_x, y_center + 3);
if (i != 0)
{
char temp_str[5];
itoa(i, temp_str, 10);
TextOut(hdc, x_center + i*m_x - 3, y_center + 3, temp_str, strlen(temp_str));
itoa(i*(-1), temp_str, 10);
TextOut(hdc, x_center - i*m_x - 6, y_center + 3, temp_str, strlen(temp_str));
}
}
// Ось OY
MoveTo(hdc, x_center, rt.top + 40);
LineTo(hdc, x_center, rt.bottom - 40);
TextOut(hdc, x_center - 5, rt.top + 20, "Y", 1);
for (i = 0; i <= DELIMITERS; i++)
{
MoveTo(hdc, x_center - 3 , y_center + i*m_y);
LineTo (hdc, x_center + 3, y_center + i*m_y);
MoveTo(hdc, x_center - 3 , y_center - i*m_y);
LineTo (hdc, x_center + 3, y_center - i*m_y);
if (i != 0)
{
char temp_str[5];
itoa(i, temp_str, 10);
TextOut(hdc, x_center - 20, y_center - i*m_y - 5, temp_str, strlen(temp_str));
itoa(i*(-1), temp_str, 10);
TextOut(hdc, x_center - 20, y_center + i*m_y - 5, temp_str, strlen(temp_str));
}
}
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
#include <windows.h>
#include "wcyclic.h"
MENU_1 MENU
{
POPUP "&Работа"
{
MENUITEM "&Запуск", CM_WORKRUN
MENUITEM SEPARATOR
MENUITEM "&Выход", CM_WORKEXIT
}
POPUP "&Справка"
{
MENUITEM "&Содержание", CM_HELPCONTENTS
MENUITEM "&О программе...", CM_HELPABOUT
}
}