a4_t0002
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* acl4のページt0002
-(by [[K]], 2026.04.26)
** (1) 概要
-a4_t0002 は、 acl4v1 の1番目の補助ライブラリプログラムに...
-補助ライブラリというのは、 acl4 ライブラリに加えられるほ...
-提供される主な機能は、以下の通りです。
--(1-1)WindowsのAPIを使ってグラフィックウィンドウを開いて...
** (2) デモ
-''[t0002a.c]:''
#define a_Version 1
#include <acl4v1.c>
#include <windows.h>
#include "a4_t0002.c"
int main()
{
a_Win win[1]; int c;
a_Win_ini(_a_ win, 256, 256, "graph", 0x000000);
for (c = 0; c < 256 * 256; c++)
win->buf[c] = c << 8;
a_Win_flushAll0(win);
Sleep(1000 * 10); // 10秒後に勝手に終了.
return 0;
}
-実行結果:
--https://essen.osask.jp/files/pic20260331a.png
** (3) ライブラリプログラム
// #include <windows.h> してあることが前提.
a_class(a_Win) {
char title[256];
int xsz, ysz;
uint32_t *buf;
HWND hWin;
HINSTANCE hInst;
BITMAPINFO bmi;
};
a_static a_Win *a_Win_opened = NULL;
a_static LRESULT CALLBACK a_Win_wndProc(HWND hw, unsigne...
{
if (msg == WM_CLOSE) return 0; // closeボタンを無視.
if (msg == WM_DESTROY) { PostQuitMessage(0); return ...
a_Win *w = a_Win_opened;
if (w == NULL || w->hWin != hw)
return DefWindowProc(hw, msg, wp, lp);
if (msg == WM_PAINT) {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hw, &ps);
SetDIBitsToDevice(hdc, 0, 0, w->xsz, w->ysz, 0, ...
EndPaint(hw, &ps);
return 0;
}
return DefWindowProc(hw, msg, wp, lp);
}
a_static int a_Win_winThread(a_Win *w)
{
WNDCLASSEX wc;
RECT r;
int i;
MSG msg;
wc.cbSize = sizeof (WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = a_Win_wndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = w->hInst;
wc.hIcon = (HICON) LoadImage(NULL, MAKEINTRESOURCE(I...
wc.hIconSm = wc.hIcon;
wc.hCursor = (HCURSOR) LoadImage(NULL, MAKEINTRESOUR...
wc.hbrBackground = (HBRUSH) COLOR_APPWORKSPACE;
wc.lpszMenuName = NULL;
wc.lpszClassName = w->title;
if (RegisterClassEx(&wc) == 0) return 1;
r.left = 0; r.top = 0;
r.right = w->xsz; r.bottom = w->ysz;
AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW & ~WS_THICK...
w->hWin = CreateWindowA(wc.lpszClassName, w->title, ...
CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, ...
if (w->hWin == NULL) return 1;
ShowWindow(w->hWin, SW_SHOW);
UpdateWindow(w->hWin);
for (;;) {
i = GetMessage(&msg, NULL, 0, 0);
if (i == 0 || i == -1) break; // エラーもしくは...
// そのほかはとりあえずデフォルト処理で.
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnregisterClass(w->title, w->hInst);
return 0;
}
a_static void a_Win_ini(_aDef_ a_Win *w, int xsz, int y...
{
#if (a_DbgLv >= 2)
if (xsz < 192 || ysz < 64)
a_errExit("%s(%d): Win_ini: bad window size:...
if (title == NULL || strlen(title) == 0 || strle...
a_errExit("%s(%d): Win_ini: bad window title...
#endif
w->buf = a_malloc(_a_ xsz * ysz * sizeof (uint32_t));
int i;
for (i = 0; i < xsz * ysz; i++) { w->buf[i] = c; }
w->xsz = xsz; w->ysz = ysz;
strcpy(w->title, title);
w->bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
w->bmi.bmiHeader.biWidth = xsz;
w->bmi.bmiHeader.biHeight = - ysz;
w->bmi.bmiHeader.biPlanes = 1;
w->bmi.bmiHeader.biBitCount = 32;
w->bmi.bmiHeader.biCompression = BI_RGB;
a_Win_opened = w;
CreateThread(NULL, 0, (void *) a_Win_winThread, (voi...
Sleep(128);
}
a_static void a_Win_flushAll0(a_Win *w)
{
InvalidateRect(w->hWin, NULL, FALSE);
UpdateWindow(w->hWin);
}
** (99) 更新履歴
-2026.04.26(日) 初版
終了行:
* acl4のページt0002
-(by [[K]], 2026.04.26)
** (1) 概要
-a4_t0002 は、 acl4v1 の1番目の補助ライブラリプログラムに...
-補助ライブラリというのは、 acl4 ライブラリに加えられるほ...
-提供される主な機能は、以下の通りです。
--(1-1)WindowsのAPIを使ってグラフィックウィンドウを開いて...
** (2) デモ
-''[t0002a.c]:''
#define a_Version 1
#include <acl4v1.c>
#include <windows.h>
#include "a4_t0002.c"
int main()
{
a_Win win[1]; int c;
a_Win_ini(_a_ win, 256, 256, "graph", 0x000000);
for (c = 0; c < 256 * 256; c++)
win->buf[c] = c << 8;
a_Win_flushAll0(win);
Sleep(1000 * 10); // 10秒後に勝手に終了.
return 0;
}
-実行結果:
--https://essen.osask.jp/files/pic20260331a.png
** (3) ライブラリプログラム
// #include <windows.h> してあることが前提.
a_class(a_Win) {
char title[256];
int xsz, ysz;
uint32_t *buf;
HWND hWin;
HINSTANCE hInst;
BITMAPINFO bmi;
};
a_static a_Win *a_Win_opened = NULL;
a_static LRESULT CALLBACK a_Win_wndProc(HWND hw, unsigne...
{
if (msg == WM_CLOSE) return 0; // closeボタンを無視.
if (msg == WM_DESTROY) { PostQuitMessage(0); return ...
a_Win *w = a_Win_opened;
if (w == NULL || w->hWin != hw)
return DefWindowProc(hw, msg, wp, lp);
if (msg == WM_PAINT) {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hw, &ps);
SetDIBitsToDevice(hdc, 0, 0, w->xsz, w->ysz, 0, ...
EndPaint(hw, &ps);
return 0;
}
return DefWindowProc(hw, msg, wp, lp);
}
a_static int a_Win_winThread(a_Win *w)
{
WNDCLASSEX wc;
RECT r;
int i;
MSG msg;
wc.cbSize = sizeof (WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = a_Win_wndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = w->hInst;
wc.hIcon = (HICON) LoadImage(NULL, MAKEINTRESOURCE(I...
wc.hIconSm = wc.hIcon;
wc.hCursor = (HCURSOR) LoadImage(NULL, MAKEINTRESOUR...
wc.hbrBackground = (HBRUSH) COLOR_APPWORKSPACE;
wc.lpszMenuName = NULL;
wc.lpszClassName = w->title;
if (RegisterClassEx(&wc) == 0) return 1;
r.left = 0; r.top = 0;
r.right = w->xsz; r.bottom = w->ysz;
AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW & ~WS_THICK...
w->hWin = CreateWindowA(wc.lpszClassName, w->title, ...
CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, ...
if (w->hWin == NULL) return 1;
ShowWindow(w->hWin, SW_SHOW);
UpdateWindow(w->hWin);
for (;;) {
i = GetMessage(&msg, NULL, 0, 0);
if (i == 0 || i == -1) break; // エラーもしくは...
// そのほかはとりあえずデフォルト処理で.
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnregisterClass(w->title, w->hInst);
return 0;
}
a_static void a_Win_ini(_aDef_ a_Win *w, int xsz, int y...
{
#if (a_DbgLv >= 2)
if (xsz < 192 || ysz < 64)
a_errExit("%s(%d): Win_ini: bad window size:...
if (title == NULL || strlen(title) == 0 || strle...
a_errExit("%s(%d): Win_ini: bad window title...
#endif
w->buf = a_malloc(_a_ xsz * ysz * sizeof (uint32_t));
int i;
for (i = 0; i < xsz * ysz; i++) { w->buf[i] = c; }
w->xsz = xsz; w->ysz = ysz;
strcpy(w->title, title);
w->bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
w->bmi.bmiHeader.biWidth = xsz;
w->bmi.bmiHeader.biHeight = - ysz;
w->bmi.bmiHeader.biPlanes = 1;
w->bmi.bmiHeader.biBitCount = 32;
w->bmi.bmiHeader.biCompression = BI_RGB;
a_Win_opened = w;
CreateThread(NULL, 0, (void *) a_Win_winThread, (voi...
Sleep(128);
}
a_static void a_Win_flushAll0(a_Win *w)
{
InvalidateRect(w->hWin, NULL, FALSE);
UpdateWindow(w->hWin);
}
** (99) 更新履歴
-2026.04.26(日) 初版
ページ名: