⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sail2000.cpp

📁 winsail v2.0是用于DOS下的图形界面空间系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include <Conio.h>
#include <Bios.h>
#include <dir.h>
#include <direct.h>

#include <Symbol.h>
#include <MyFrame.h>

#include <Relay.h>
#include <Socket3.h>
#include <Socket4.h>

void far BarCodeDemo();
void far ArpDialog();
void far MenuInstance();
void far NetcardSetting();
void far DemoSliderAndProcess();
void far DemoMultiEditDialog();
void far DemoFileOpenDialog();
void far VirtualKeyboardDemo(CObject* pCurObj);
void far DialDemoDialog();
void far GraphDemoDialog();
void far LedDemoDialog();
void DemoWizard();
void far Demo_NumberKeyboard();


extern BOOL bAfxNetcard;
extern BOOL bAfxManager;
extern BOOL far bAfxGotoMonitor;
extern unsigned   _stklen=(60u*1024u);
extern CWindow*   pAfxWindow;


//该函数是用户必须实现的所有窗口默认的"附加键盘回调函数";内核代码创建窗口时,自动默认注册该函数。
int far TransrateKey(CObject*)
{
    return(0);
}

BOOL bAfxAgain = FALSE;

BOOL GetAgain()
{
	return(bAfxAgain);
}


void  SetAgain(BOOL bAgain)
{
	bAfxAgain = bAgain;
}


void far DisplayAttribSetting()
{
	if (!bAfxManager)
	{
		return;
	}

	//Create a Dialog On the Center of Desktop
	CDialog* pDialog = new CDialog;//分配实例
	pDialog->CreateWindow(0, 0, 313, 135, "显示属性");//建立窗口
	pDialog->Center();//窗口对中

	//Create Close's Button Control
	new CCloseButton(pDialog);//分配和建立关闭按钮

	//Create Combo Control
	CComboBox* pComboBox1 = new CComboBox(pDialog);
	pComboBox1->CreateCombo(9, 103, 195, 24, NULL);
	pComboBox1->SetID(COMBOBASE + 1 - 1);

	//Create a Button Control
	CButton* pButton1 = new CButton(pDialog);
	pButton1->CreateObject(222, 58, 75, 24, "确定(\x3\E\x3)");
	pButton1->SetShortcutKey(VK_ALT_E);
	pButton1->SetFc(ClickEnterButton);
	pButton1->SetID(BUTTONBASE + 1 - 1);

	//Create a Button Control
	CButton* pButton2 = new CButton(pDialog);
	pButton2->CreateObject(222, 103, 75, 24, "取消(\x3\C\x3)");
	pButton2->SetShortcutKey(VK_ALT_C);
	pButton2->SetFc(ClickCancelButton);
	pButton2->SetID(BUTTONBASE + 2 - 1);

	//Create a Label Control
	CLabel* pLabel1 = new CLabel(pDialog);
	pLabel1->CreateObject(7, 77, 85, 12, "请选择显示属性");
	pLabel1->SetID(LABELBASE + 1 - 1);


	//Create a ICON Control
	CLabel* pLabel2 = new CLabel(pDialog);
	pLabel2->CreateObject(24, 37, 31, 31, NULL);
	pLabel2->SetBitmapFlags(TRUE);
	pLabel2->SetBackColorDisplay(TRUE);
	pLabel2->SetBitmapFile("Bmp\\Display.ico");
	pLabel2->SetID(LABELBASE + 2 - 1);

	//Create Check Control
	CRadio* pCheck1 = new CRadio(pDialog);
	pCheck1->CreateObject(141, 77, 57, 24, "单色");
	pCheck1->SetBox(TRUE);
	pCheck1->SetID(CHECKBASE + 1 - 1);

    pComboBox1->SetCount(10);
	pComboBox1->SetSel(0,"VGA_640*480*16N");
	pComboBox1->SetSel(1, "VESA_800*600*16N");
	pComboBox1->SetSel(2, "VESA_640*400*256");
	pComboBox1->SetSel(3, "VESA_640*480*256");
	pComboBox1->SetSel(4, "VESA_800*600*16S");
	pComboBox1->SetSel(5, "VESA_800*600*256");
	pComboBox1->SetSel(6, "VESA_1024*768*16");
	pComboBox1->SetSel(7, "VESA_1024*768*256");
	pComboBox1->SetSel(8, "VESA_1280*1024*16");
	pComboBox1->SetSel(9, "VESA_1280*1024*256");

	if( GetDisplayDevice() == VESA)
	{
		pComboBox1->SetIndex(GetDisplayMode()+1);
	}
	else
	{
		pComboBox1->SetIndex(0);
	}

	pCheck1->SetRadio(AfxGetMonoAttrib());

	//Show Window
	pDialog->ShowWindow();//显示窗口


	if (pDialog->DoModal() == IDOK)
	{
    	BOOL bMono = pCheck1->GetRadio();
		int nIndex = pComboBox1->GetIndex();
		delete pDialog;


		CRegister* pRegister = new CRegister("Config.Sys");
		char* pStrSegment = "Display";
		if (nIndex == 0)
		{
			pRegister->WriteProfileInt(pStrSegment, "Device",VGA);
			pRegister->WriteProfileInt(pStrSegment, "Mode",VGAHI);
		}
		else
		{
			pRegister->WriteProfileInt(pStrSegment, "Device",VESA);
			pRegister->WriteProfileInt(pStrSegment, "Mode",nIndex-1);
		}
        pRegister->WriteProfileString(pStrSegment, "Mono",
			((bMono)?"True":"False"));


		delete pRegister;

		::CloseWindow(pDialog) ; ::ClearKeyboard();
		::SetAgain(TRUE); ::AddKeyboardString("Sail2000 觞\xd");
	}
	else
	{
		delete pDialog;
	}
	return;
}


//"开始菜单"的下一级菜单"附件菜单"的功能函数
void    far ClickSystemMenu_FrameWindow(int nUserLeft,int nUserTop,CBar* pBar)
{
    //死循环直到鼠标左键不再按下
	while(::IsMouseDown(MOUSE_LEFT)){};
   
    //分配"弹出菜单"实例
	CBar *pBar1 = new CBar(NULL);
     //建立"弹出菜单"
	pBar1->CreateObject(nUserLeft,nUserTop,120,60,NULL);

     //往"弹出菜单"中加入"菜单项"
	pBar1->AddItem("用户登录",(void (*)(CObject*))::UserRegister);
	pBar1->AddItem("修改权限",(void (*)(CObject*))::ModifyPriviledge);
    pBar1->AddSeparator();

	pBar1->AddItem("网络属性",(void (*)(CObject*))::CommSetting);
	pBar1->AddItem("显示属性" ,(void (*)(CObject*))::DisplayAttribSetting);
    pBar1->AddSeparator();
	pBar1->AddItem("驱动程序",(void (*)(CObject*))::AfxDeviceDialog);
	pBar1->AddItem("任务列表",(void (*)(CObject*))::AfxTaskDialog);
    pBar1->AddItem("对话框脚本",(void (*)(CObject*))::AfxLoadDialog);
    pBar1->AddSeparator();

	pBar1->AddItem("关于系统",(void (*)(CObject*))::AboutDialog, NULL);

    //重新修改菜单的位置
	int nLength = pBar1->GetScreenHeight();
	pBar1->SetLocation(pBar1->m_ScreenRect.left,
		pBar1->m_ScreenRect.top-nLength+1,
		pBar1->m_ScreenRect.right,
		pBar1->m_ScreenRect.top);

     //往其上一级菜单注册自己
	pBar->SetItemBar( pBar->GetIndex() , pBar1);
     //将"弹出菜单"的"父窗口"强置成"主窗口"
	pBar1->SetParent(pAfxWindow);

     //显示该"弹出菜单"
	pBar1->Show();
    //返回
	return;
}

// "开始菜单"功能
void    far ClickMenuButton_FrameWindow(CObject* pCurObj)
{
    //死循环,直至鼠标左键不再按下
	while(::IsMouseDown(MOUSE_LEFT)){};
     
	int nKey=VK_ESC;
	void far (*pFc)(CObject*)=NULL;
    //分配一个弹出菜单
	CBar *pBar1 = new CBar(NULL);
    //建立弹出菜单
	pBar1->CreateObject( 0 ,GetMaxY() + 1-25,120,60,NULL);

    //往弹出菜单中加入菜单条
    //   其中BAR_ATTRIB_NORMAL 表示不再有下一级弹出菜单
     //       BAR_ATTRIB_DIR     表示还有一级弹出菜单
	pBar1->AddItem("附  件",(void (*)(CObject*))ClickSystemMenu_FrameWindow,NULL,BAR_ATTRIB_DIR);
	pBar1->AddItem("查  找...",NULL,NULL,BAR_ATTRIB_NORMAL);
    pBar1->AddSeparator();
	pBar1->AddItem("运  行...",NULL,NULL,BAR_ATTRIB_NORMAL);
	pBar1->AddItem("退  出...",(void (*)(CObject*))CloseSystemDialog,NULL,BAR_ATTRIB_NORMAL);
    
    //修正弹出菜单的位置
	int nLength = pBar1->GetScreenHeight();
	pBar1->SetLocation(pBar1->m_ScreenRect.left,
		pBar1->m_ScreenRect.top-nLength+1,
		pBar1->m_ScreenRect.right,
		pBar1->m_ScreenRect.top);

     //将"弹出菜单"的"父窗口"与"主窗口"关联;这样,进入"弹出菜单"消息循环后仍然能执行"主窗口"的"定时器"
	pBar1->SetParent(pAfxWindow);
    //显示"弹出菜单"
	pBar1->Show();
    //循环,直至结束
	do
	{
		nKey = pBar1->Swapping();
	}while(nKey != VK_ENTER && nKey!=VK_ESC &&
		nKey!=VK_MOUSE_SCREEN_OUT && nKey!=VK_ALT_F4);

     //获得需执行的函数
	pFc = pBar1->GetFc();
     //"弹出菜单"不再需要,将其从内存中删除。
	DELETE(pBar1);
     //若注册的回调函数合法且需要执行,则运行它
	if( nKey == VK_ENTER && pFc != NULL)
	{
		pFc(pCurObj);
	}
    //返回
	return;
}

void far ChangeSlider(CSliderCtrl* pSliderCtrl)
{
	long dwMin ,dwMax, dwPos;
	pSliderCtrl->GetRange(&dwMin, &dwMax);
	dwPos = pSliderCtrl->GetPos();
}

//主窗口的定时回调函数
void  far OnTime_MainFrame(CObject* pCurObj)
{
   //显示日期和时间
//	::DisplaySystemDateAndTime(pCurObj);
}


//主窗口的窗口显示回调函数
void  far Draw_MainFrame(CObject *pObject)
{
	CWindow* pWindow = (CWindow *)pObject;


	char buf[256];
	int nLengthEx = 22;
	int nWidthEx = 0;

	strcpy(buf,"B69.5f,15.0f,12.5f,End");
	if( GetMaxX() + 1 == 800)
	{
		strcpy(buf,"B75.5f,12.0f,10.0f,End");
		nWidthEx = 1;
	}
	else if( GetMaxX() + 1 == 1024)
	{
		strcpy(buf,"B81.2f,9.4f,7.6f,End");
		nWidthEx = 1;
	}
	else if( GetMaxX() + 1 == 1280)
	{
		strcpy(buf,"B81.2f,9.4f,7.6f,End");

	}
	::ShowState(0,GetMaxY() + 1 - 24,GetMaxX() + 1 + 2,24,LIGHTGRAY,4,buf,TRUE);

	::sprintf(buf,"%s",::AfxGetSystemString(0));
	::ChPrintf(90 + 3 + ((16+6) * 4) + 3,22+(GetMaxY()+1-65)+nLengthEx,BLACK,LIGHTGRAY,1,0,buf);//"需帮助,请按Ctrl+H ;激活菜单ALT+F");

	::DisplayIcon(pWindow->m_ScreenRect.right -16 - 3 - 6 + nWidthEx,
		pWindow->m_ScreenRect.bottom - (16 + 3 + 1 + 8),
		"Bmp\\Books14.Ico",
		1, TRUE, FALSE);

}
//桌面用户功能函数
void far DesktopFun1(CObject* pCurObj) {AfxMessageBox("调试","你单击了DesktopFun1",MB_OK) ;}
void far DesktopFun2(CObject* pCurObj) {AfxMessageBox("调试","你单击了DesktopFun2",MB_OK) ;}
void far DesktopFun3(CObject* pCurObj) {AfxMessageBox("调试","你单击了DesktopFun3",MB_OK) ;}
void far DesktopFun4(CObject* pCurObj) {AfxMessageBox("调试","你单击了DesktopFun4",MB_OK) ;}
void far DesktopFun5(CObject* pCurObj) {AfxMessageBox("调试","你单击了DesktopFun5",MB_OK) ;}
void far DesktopFun6(CObject* pCurObj) {AfxMessageBox("调试","你单击了DesktopFun6",MB_OK) ;}
//工具条用户功能函数
void far ToolsFun1(CObject* pCurObj) {AfxMessageBox("调试","你单击了ToolsFun1",MB_OK) ;}
void far ToolsFun2(CObject* pCurObj) {AfxMessageBox("调试","你单击了ToolsFun2",MB_OK) ;}
void far ToolsFun3(CObject* pCurObj) {AfxMessageBox("调试","你单击了ToolsFun3",MB_OK) ;}


BOOL	far InitFrameWindow()
{
    //建立窗口实例
	pAfxWindow = new CWindow;
    //建立窗口
	pAfxWindow->CreateWindow(0-3,0-30,GetMaxX() + 1 + 10,GetMaxY() + 1 + 40,::AfxGetSystemString(0));
    //设置OnDraw回调函数
	pAfxWindow->SetDrawFc(Draw_MainFrame);
    //设置窗口背景色
	pAfxWindow->SetBackColor(CYAN);
    //设置无须保留窗口桌面(因它是永远最底的窗口)
	pAfxWindow->SetSaveScreen(FALSE);
    //将窗口置成不可显示
	pAfxWindow->SetVisible(FALSE);
    //设置帮助回调函数
	pAfxWindow->SetHelpFc(NULL);
    //设置定时器回调函数为"OnTime_MainFrame"函数
	pAfxWindow->SetTimeFc(OnTime_MainFrame);
    //设置窗口显示回调函数为"Draw_MainFrame"函数
    pAfxWindow->SetDrawFc(Draw_MainFrame);
    //设置附加键盘回调函数
	pAfxWindow->SetKeyboardFc(NULL);

    //分配一个关闭按钮
	CCloseButton *pCloseButton = new CCloseButton(pAfxWindow);
    //"关闭按钮"与" CloseSystemDialog"函数关联。
	pCloseButton->SetFc((void (*)(CObject*))CloseSystemDialog);
    
    //建立一个桌面类
	CDesktop *pDesktop = new CDesktop(pAfxWindow);
    //桌面的尺寸
	pDesktop->CreateObject(0,19 + 5, 460, 450,NULL);
    //桌面上的"某图标"没有被"选中"时,文字显示的颜色
	pDesktop->SetForeColor(BLACK);//LIGHTBLUE);
    //桌面上的"某图标"被"选中"时,文字显示的颜色
	pDesktop->SetLightColor(BLUE);//LIGHTBLUE);
    //往桌面加入一个图标,图标文件是"Bmp\BookS01.Ico",文字是"我的电脑",单击时调用函数DesktopFun1
    pDesktop->AddLink("Bmp\\BookS01.Ico","我的电脑",DesktopFun1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -