再び右クリックでメニュー画面消すという処理をしたいのですが
以下のコードで右クリックすると2回連続で押されたことになり、一瞬表示→消える になってしまいます
#include "DxLib.h"
void char_disp();
int Key[256];
////////Button[0]は左クリック、[1]は右クリック
typedef struct{
int x;
int y; //座標
int WheelRotVol;//ホイールの回転量
unsigned int Button[8]; //ボタンの押した状態
}Mouse_t;
Mouse_t Mouse;
int GetHitMouseStateAll_2(Mouse_t *Nezumi){
if(GetMousePoint( &Nezumi->x, &Nezumi->y ) == -1){ //マウスの位置取得
return -1;
}
int MouseInput=GetMouseInput(); //マウスの押した状態取得
for(int i=0; i<8; i++){ //マウスのキーは最大8個まで確認出来る
if( (MouseInput & 1<<i ) != 0 ) Nezumi->Button[i]++; //押されていたらカウントアップ
else Nezumi->Button[i] = 0; //押されてなかったら0
}
Nezumi->WheelRotVol = GetMouseWheelRotVol() ; //ホイール回転量取得
return 0;
}int menuflag; int White;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
//ウィンドウモードで起動
ChangeWindowMode( TRUE );
DATEDATA Date ;
if( DxLib_Init() == -1 ) // DXライブラリ初期化処理
{
return -1; // エラーが起きたら直ちに終了
}
// 現在経過時間を得る
int StartTime = GetNowCount() ;
//色とy座標の宣言
White = GetColor( 255 , 255 , 255 ) ;
// 現在時刻を得る
int yu=GetDateTime( &Date ) ;
//デバッグ用にコンソールを呼び出す
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONIN$", "r", stdin);
while(ProcessMessage()==0 && ClearDrawScreen()==0 && Key[KEY_INPUT_ESCAPE]==0)
{
// メッセージ処理
if( ProcessMessage() == -1 )
{
break ; // エラーが起きたらループから抜ける
}
GetHitMouseStateAll_2(&Mouse);
//右クリックでメニュー
if(Mouse.Button[1]==1){
menuflag=1;
}
if(menuflag==1 ) {
char_disp();
}
ScreenFlip();
}
//コンソール解放
FreeConsole();
DxLib_End() ; // DXライブラリ使用の終了処理
return 0 ; // ソフトの終了
}
//メニュー画面
void char_disp(){
DrawString( 150 , 100 , "■" , White );
DrawString( 170 , 100 , "セーブする" , White );
DrawString( 170 , 120 , "ロードする" , White );
DrawString( 170 , 140 , "履歴" , White );
DrawString( 170 , 160 , "CONTINUE3" , White );
DrawString( 170 , 180 , "CONTINUE4" , White );
DrawString( 170 , 200 , "CONTINUE5" , White );
DrawString( 170 , 220 , "CONTINUE6" , White );
DrawString( 170 , 240 , "戻る" , White );
//右クリックでメニュー画面消す
if(Mouse.Button[1]==1){menuflag=0;printf("マウスの右\n");}
}