以下のようなコードを実行させたところ(本題に不要な部分もありますが、全て載せます)
source.cpp
#include "DxLib.h"
#include "Ztaizen.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
//宣言
int MouseX, MouseY;
int handle[4] = {
MakeScreen(1920, 1080, FALSE),
MakeScreen(1920, 1080, FALSE),
MakeScreen(1920, 1080, FALSE),
MakeScreen(1920, 1080, FALSE) };
int window = 0;
int mode[4] = { 0, 0, 0, 0 };
int cr = GetColor(255, 255, 255);
if (DxLib_Init() == -1) // DXライブラリ初期化処理
{
return -1; // エラーが起きたら直ちに終了
}
//設定
SetGraphMode(1920, 1080, 32);
ChangeWindowMode(TRUE);
SetWindowSizeChangeEnableFlag(TRUE);
window = 0;
SetDrawScreen(DX_SCREEN_BACK);
SetMouseDispFlag(TRUE);
//実行
while (ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0 && gpUpdateKey() == 0){
KeyToWM(&window,mode);
ClearDrawScreen();
GetMousePoint(&MouseX, &MouseY);
windomode(window, mode[window], handle);
DrawFormatString(0, 0, cr, "0,%d,%d", window, mode[window]);
DrawGraph(0, 0, handle[window], TRUE);
ScreenFlip();
WaitTimer(20);
}
for (int i = 0; i < 3; i++)
{
DeleteSoftImage(handle[i]);
}
DxLib_End(); // DXライブラリ使用の終了処理
return 0;
}
void windomode(int w, int m,int handle[4]);
static unsigned int Key[256];
extern int gpUpdateKey();
void KeyToWM(int* a,int b[4]);
int firstload();
と#include "DxLib.h"
#include"Ztaizen.h"
#include <share.h>
unsigned int Cr = GetColor(120, 0, 255);
int firstload(){
int clr = GetColor(0, 100, 20);
char name[] = "load1.txt";
char ch[20];
int i;
FILE *fp ;
if ((fp = _fsopen(name, "r", _SH_DENYNO)) == NULL)
{
DrawString(0,0, "ファイルのオープンに失敗 ", clr);
fp = _fsopen(name, "w", _SH_DENYNO);
fprintf(fp, "damedesita");
}
//DrawFormatString(60, 50, (GetColor(100, 100, 100)), "egw");
while (fscanf_s(fp, "%d,%s", &i, ch) != EOF){
DrawFormatString(0,0, clr,"%d:%s", &i,ch);
//DrawFormatString(60,60, (GetColor(100, 100, 100)), "4rea");
}
fclose(fp);
return 0;
}
void window0(int handle[4])
{
int p;
if (p = !0){
p = firstload();
}
SetDrawScreen(handle[0]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 255, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
DrawBox(265, 70, 510, 565, Cr, FALSE);
DrawBox(265, 575, 510, 1070, Cr, FALSE);
DrawFormatString(50,50, (GetColor(100,100,100)), "%d",p);
}
void window11(int handle[4])
{
SetDrawScreen(handle[1]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 255, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
DrawBox(265, 70, 510, 565, Cr, FALSE);
DrawBox(265, 575, 510, 1070, Cr, FALSE);
}
void window12(int handle[4])//パーツ配置
{ SetDrawScreen(handle[1]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 255, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
DrawBox(265, 70, 510, 565, Cr, FALSE);
DrawBox(265, 575, 510, 1070, Cr, FALSE);
}
void window13(int handle[4])
{ SetDrawScreen(handle[1]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 255, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
DrawBox(265, 70, 510, 565, Cr, FALSE);
DrawBox(265, 575, 510, 1070, Cr, FALSE);
}
void window14(int handle[4])
{ SetDrawScreen(handle[1]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 255, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
DrawBox(265, 70, 510, 565, Cr, FALSE);
DrawBox(265, 575, 510, 1070, Cr, FALSE);
}
void window21(int handle[4]){
SetDrawScreen(handle[2]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window22(int handle[4]){
SetDrawScreen(handle[2]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window23(int handle[4]){
SetDrawScreen(handle[2]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window24(int handle[4]){
SetDrawScreen(handle[2]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window31(int handle[4]){
SetDrawScreen(handle[3]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window32(int handle[4]){
SetDrawScreen(handle[3]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window33(int handle[4]){
SetDrawScreen(handle[3]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void window34(int handle[4]){
SetDrawScreen(handle[3]);
DrawBox(10, 10, 510, 60, Cr, FALSE);
DrawBox(10, 70, 510, 1070, Cr, FALSE);
DrawBox(520, 10, 1900, 1070, Cr, FALSE);
}
void(*windows[][4])(int handle[4]) =
{
{ window0, window0, window0, window0 },
{window11, window12, window13, window14 },
{ window21, window22, window23, window24 },
{ window31, window32, window33, window34 }
};
void windomode(int w, int m, int handle[4])
{
windows[w][m](handle);
}
int gpUpdateKey(){
char tmpKey[256]; // 現在のキーの入力状態を格納する
GetHitKeyStateAll(tmpKey); // 全てのキーの入力状態を得る
for (int i = 0; i<256; i++){
if (tmpKey[i] != 0){ // i番のキーコードに対応するキーが押されていたら
Key[i]++; // 加算
}
else { // 押されていなければ
Key[i] = 0; // 0にする
}
}
return 0;
}
void KeyToWM(int* a, int b[4]){
if (Key[KEY_INPUT_F1] == 1){
*a = 1;
}
if (Key[KEY_INPUT_F2] == 1){
*a = 2;
}
if (Key[KEY_INPUT_F3] == 1){
*a = 3;
}
if (Key[KEY_INPUT_BACK] == 1){
*a = 0;
}
if (Key[KEY_INPUT_LSHIFT] == 1){
if (b[*a]<3){
b[*a] = b[*a] + 1;
}
else
{
b[*a] = 0;
}
}
}
解決策があれば、教えてくださるとありがたいです。