TEXTLAB (ЛР №2 - Отправка сообщения в другое окно)
Описание файла
Файл "TEXTLAB" внутри архива находится в следующих папках: ЛР №2 - Отправка сообщения в другое окно, [APIWin] Лаборторная №2. Документ из архива "ЛР №2 - Отправка сообщения в другое окно", который расположен в категории "". Всё это находится в предмете "api windows" из 6 семестр, которые можно найти в файловом архиве МГТУ им. Н.Э.Баумана. Не смотря на прямую связь этого архива с МГТУ им. Н.Э.Баумана, его также можно найти и в других разделах. Архив можно найти в разделе "лабораторные работы", в предмете "api windows" в общих файлах.
Онлайн просмотр документа "TEXTLAB"
Текст из документа "TEXTLAB"
#include <windows.h>
#include <stdlib.h>
const char szClassName[] = "WinLab_01";
const char szWindowName[] = "Term II. Windows Lab 01.";
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)
{
switch (iMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
NAME N01
DESCRIPTION 'Term II. Windows Lab 01.'
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120
//#define STRICT
#include <windows.h>
#include <stdlib.h>
#include "n02a.h"
const char szClassName[] = "WinLab_02a";
const char szWindowName[] = "Term II. Windows Lab 02a.";
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 = "WinLab_02a";
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)
{
switch (iMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
#include "n02a.h"
WinLab_02a MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", IDM_NEW
MENUITEM "&Open...", IDM_OPEN
MENUITEM "&Save", IDM_SAVE
MENUITEM "Save &As...", IDM_SAVEAS
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_QUIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About...", IDM_ABOUT
END
END
#include <windows.h>
#include <stdlib.h>
const char szClassName[] = "WinLab_03a";
const char szWindowName[] = "Term II. Windows Lab 03a.";
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, hButton1, hButton2, hButton3;
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);
RECT rc;
GetWindowRect(hWnd, &rc);
hButton1 = CreateWindow("BUTTON", "Neutral", WS_VISIBLE | WS_CHILD,
(rc.right - rc.left) / 2 - 130, (rc.bottom - rc.top) / 2 - 25, 75, 25, hWnd, 0, hInstance, NULL);
hButton2 = CreateWindow("BUTTON", "Default", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
(rc.right - rc.left - 75) / 2, (rc.bottom - rc.top) / 2 - 25, 75, 25, hWnd, 0, hInstance, NULL);
hButton3 = CreateWindow("BUTTON", "Disabled", WS_VISIBLE | WS_CHILD | WS_DISABLED,
(rc.right - rc.left) / 2 + 50, (rc.bottom - rc.top) / 2 - 25, 75, 25, hWnd, 0, hInstance, NULL);
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)
{
switch (iMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
#include <windows.h>
#include <stdlib.h>
#include "n04.h"
const char szClassName[] = "WinLab_04";
const char szWindowName[] = "Term II. Windows Lab 04.";
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, hButton1, hButton2, hButton3;
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);
RECT rc;
GetWindowRect(hWnd, &rc);
hButton1 = CreateWindow("BUTTON", "Abort_Retry_Ignore", WS_VISIBLE | WS_CHILD, (rc.right - rc.left - 145) / 2 , (rc.bottom - rc.top) / 2 - 60, 145, 25, hWnd, HMENU (IDM_ABORTRETRYIGNORE), hInstance, NULL);
hButton2 = CreateWindow("BUTTON", "Yes_No_Cancel", WS_VISIBLE | WS_CHILD, (rc.right - rc.left - 125) / 2, (rc.bottom - rc.top) / 2 - 30, 125, 25, hWnd, HMENU (IDM_YESNOCANCEL), hInstance, NULL);
hButton3 = CreateWindow("BUTTON", "Ok_Cancel", WS_VISIBLE | WS_CHILD,
(rc.right - rc.left - 85) / 2, (rc.bottom - rc.top) / 2, 85, 25, hWnd, HMENU (IDM_OKCANCEL), hInstance, NULL);
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)
{
switch (iMessage)
{
case WM_DESTROY: //
PostQuitMessage(0);
break;
case WM_COMMAND: //
switch(LOWORD(wParam))
{
case IDM_ABORTRETRYIGNORE:
MessageBox(0,"Generated message", "MB_ABORTRETRYIGNORE", MB_ABORTRETRYIGNORE);
break;
case IDM_YESNOCANCEL:
MessageBox(0,"Generated message", "MB_YESNOCANCEL", MB_YESNOCANCEL);
break;
case IDM_OKCANCEL:
MessageBox(0,"Generated message", "MB_OKCANCEL", MB_OKCANCEL);
break;
}
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
#include <windows.h>
#include <stdlib.h>
#include "n05.h"
const char szClassName[] = "WinLab_05";
const char szWindowName[] = "Term II. Windows Lab 05.";
HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
//BOOL FAR PASCAL DialogProc(HWND hDlg, WORD message, WPARAM wParam, LPARAM lParam);
BOOL FAR PASCAL DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_DESTROY)
{
EndDialog(hDlg, TRUE);
return(TRUE);
}
if (message == WM_INITDIALOG)
return(TRUE);
else if (message == WM_COMMAND)
{
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))
{
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:
FARPROC dlgproc;
dlgproc = MakeProcInstance((FARPROC)DialogProc, hInst);
DialogBox(hInst,
MAKEINTRESOURCE(WinLab_05_DLG),
hWnd,
(DLGPROC)dlgproc);
FreeProcInstance(dlgproc);
break;
}
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
#include <windows.h>
#include <stdlib.h>
#include "n06.h"
const char szClassName[] = "WinLab_06";
const char szWindowName[] = "Term II. Windows Lab 06.";
HINSTANCE hInst;
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
BOOL FAR PASCAL DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_INITDIALOG)
return(TRUE);
else if (message == WM_COMMAND)