📄 myapp.cpp
字号:
/****************************************************
Author: S. Senthil kumar
File: myapp.cpp
Purpose: Windows startup class
******************************************************/
#include "stdafx.h"
#include "Global.h"
#include "OneMove.h"
#include "LastMove.h"
#include "myapp.h"
#include "myframe.h"
extern void AssignDefaults(int sndenable,int autoplay,CString deflevel,CString defdir,int whitesq,int blacksq);
extern COLORREF WHITESQUARE;
extern COLORREF BLACKSQUARE;
int myapp::InitInstance()
{
SetDialogBkColor(RGB(60,60,192),RGB(255,255,100));
myframe *p=new myframe;
p->ShowWindow(SW_MAXIMIZE);
m_pMainWnd=p;
//Loads user settings from Registry.
LoadDefaults();
return 1;
}
void myapp::LoadDefaults()
{
//Access Registry and use GetProfilexxx to get user settings.
SetRegistryKey(TEXT("The Genius"));
int sndenable=GetProfileInt(TEXT("Options"),TEXT("SoundEnable"),0);
CString deflevel=GetProfileString(TEXT("Options"),TEXT("DefaultLevel"),TEXT(""));
int autoplay=GetProfileInt(TEXT("Options"),TEXT("AutoPlay"),0);
char *buf=new char[100];
::GetCurrentDirectory(100,buf);
CString appdefault=(CString)buf+(CString)"\\Sounds";
delete [] buf;
CString defdir=GetProfileString(TEXT("Options"),TEXT("MusicDir"),appdefault);
COLORREF whitesquare=(COLORREF)GetProfileInt(TEXT("Options"),TEXT("WhiteSquare"),RGB(0,0,0));
COLORREF blacksquare=(COLORREF)GetProfileInt(TEXT("Options"),TEXT("BlackSquare"),RGB(100,100,115));
//Assign values to global variables
AssignDefaults(sndenable,autoplay,deflevel,defdir,whitesquare,blacksquare);
}
void myapp::StoreOptions(int autoplay,int sndenable,CString deflevel,CString defdir)
{
//Store Options using WriteProfileInt.
int errorval=0;
errorval=WriteProfileInt(TEXT("Options"),TEXT("AutoPlay"),autoplay);
if (errorval==0) MessageBox(NULL,TEXT("Autoplay Not assigned"),TEXT(""),0);
errorval=WriteProfileInt(TEXT("Options"),TEXT("SoundEnable"),sndenable);
if (errorval==0) MessageBox(NULL,TEXT("SndEnable Not assigned"),TEXT(""),0);
errorval=WriteProfileString(TEXT("Options"),TEXT("DefaultLevel"),deflevel);
if (errorval==0) MessageBox(NULL,TEXT("DefLevel Not assigned"),TEXT(""),0);
errorval=WriteProfileString(TEXT("Options"),TEXT("MusicDir"),defdir);
if (errorval==0) MessageBox(NULL,TEXT("MusicDir Not assigned"),TEXT(""),0);
WriteProfileInt(TEXT("Options"),TEXT("WhiteSquare"),WHITESQUARE);
WriteProfileInt(TEXT("Options"),TEXT("BlackSquare"),BLACKSQUARE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -