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

📄 工程程序.htm

📁 界面构造
💻 HTM
字号:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body,td,p,th{font-size:14px;line-height:180%;}
input{font-size:12px;}
-->
</style>
<title></title>
<script language=javascript src="http://mimg.163.com/jsstyle/js/readletter.js"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" border=0>
<pre style="width:100%;white-space:normal;word-wrap:break-word">框架部分实现如下:
     设置程序皮肤:将AppFace.dll,BluePinna.urf,GtBase.urf,GtClassic.urf,AppFace.h拷贝到程序目录下,
然后加入下面内容
    CAppFace m_MainFace;//定义控件对象变量
InitInstance()程序入口添加下面换肤内容
    char path[256];
    GetModuleFileName(NULL,path,256) ;
    char * p = strrchr(path,'\\') ;
    if(p)     strcpy(p,&quot;\\GtBase.urf\0\0&quot;);
    m_MainFace.Start(path) ;
ExitInstance()程序退出清理工作:
    this-&gt;m_MainFace.Remove();

其他一些程序框架的处理:
监控系统要求能够开机自动运行程序,因为系统操作对象可能是一个对电脑所知无几的人
void CMainFrame::EnableAutoStart()//设置程序自动开机运行
{
    CString sPath;    
    int nPos;
    HKEY RegKey;
    GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
    sPath.ReleaseBuffer();
    nPos=sPath.ReverseFind('\\');
    sPath=sPath.Left(nPos);
    CString lpszFile=sPath+&quot;\\YbkDemo.exe&quot;;
    CFileFind fFind;
    BOOL bSuccess;
    bSuccess=fFind.FindFile(lpszFile);
    fFind.Close();
    if(bSuccess)
    {
        CString fullName;
        fullName=lpszFile;
        RegKey=NULL;
        RegOpenKey(HKEY_LOCAL_MACHINE,&quot;Software\\Microsoft\\Windows\\CurrentVersion\\Run&quot;,&amp;RegKey);
        RegSetValueEx(RegKey,&quot;彭水白云监控系统&quot;,0,REG_SZ,(const unsigned char*)(LPCTSTR)fullName,fullName.GetLength());
        this-&gt;UpdateData(FALSE);
    }
    else
    { 
        ::AfxMessageBox(&quot;没找到执行程序,自动运行失败&quot;);
        exit(0);
    }
}

void CMainFrame::SetStartMode()//设置显示器分辨率
{
    DEVMODE lpDevMode;
    lpDevMode.dmPelsHeight=768;
    lpDevMode.dmPelsWidth=1024;
    lpDevMode.dmDisplayFrequency=85;
    lpDevMode.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY;
    ChangeDisplaySettings(&amp;lpDevMode,0); 
    this-&gt;BringWindowToTop();
}

触发WM_NCLBUTTONDOWN,截获鼠标双击标题栏进行窗体的还原和最大化操作
void CMainFrame::OnNcLButtonDblClk(UINT nFlags, CPoint point) 
{
    // TODO: Add your message handler code here and/or call default
    if(nFlags != HTCAPTION) 
        CFrameWnd::OnLButtonDblClk(nFlags, point);
}

触发WM_SIZE和WM_SIZING消息,截获用户鼠标对窗体的大小修改操作
void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
    CFrameWnd::OnSize(nType, cx, cy);
    
    // TODO: Add your message handler code here
    if(this-&gt;GetSafeHwnd())
        MoveWindow(CRect(0,0,::GetSystemMetrics(SM_CXSCREEN),
        ::GetSystemMetrics(SM_CYSCREEN)),TRUE);    
}

void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) 
{
    CFrameWnd::OnSizing(fwSide, pRect);
    
    // TODO: Add your message handler code here
    if(this-&gt;GetSafeHwnd())
        MoveWindow(CRect(0,0,::GetSystemMetrics(SM_CXSCREEN),
        ::GetSystemMetrics(SM_CYSCREEN)),TRUE);    
}

//=================================
// 创建自定义工具条,这个方法来源于VCKBASE
//=================================
void CMainFrame::CreateToolBar()
{
    m_wndToolBar.CreateEx(this,TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
        | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);    
    
    //创建图形列表
    CImageList img;

    img.Create(IDB_COMMCOLD, 21, 0, RGB(255, 0, 255));
    m_wndToolBar.GetToolBarCtrl().SetImageList(&amp;img);
    img.Detach();

    img.Create(IDB_COMMHOT, 21, 0, RGB(255, 0, 255));
    m_wndToolBar.GetToolBarCtrl().SetHotImageList(&amp;img);
    img.Detach();

    //设置工具条按钮宽度最小、最大值
    m_wndToolBar.GetToolBarCtrl().SetButtonWidth(70, 100);
    m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

    m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
    m_wndToolBar.SetButtons(NULL, 8);//按钮个数 

    // 创建每个按钮
    CString str;
    str=&quot;主接线图&quot;;
    m_wndToolBar.SetButtonInfo(0, ID_ZHUJIEXIAN, TBSTYLE_BUTTON, 0);
    m_wndToolBar.SetButtonText(0, str);


    m_wndToolBar.SetButtonInfo(1, ID_JILIANG, TBSTYLE_BUTTON, 1);
    str=&quot;计量界面&quot;;
    m_wndToolBar.SetButtonText(1, str);


    m_wndToolBar.SetButtonInfo(2, ID_CELIANG, TBSTYLE_BUTTON, 2); 
    str=&quot;测量界面&quot;; 
    m_wndToolBar.SetButtonText(2, str);

    m_wndToolBar.SetButtonInfo(3, ID_SEEK_DINGZHI, TBSTYLE_BUTTON, 3);
    str=&quot;定值查询&quot;;
    m_wndToolBar.SetButtonText(3, str);

    m_wndToolBar.SetButtonInfo(4, ID_TIME_LINESEL, TBSTYLE_BUTTON, 4);
    str=&quot;实时曲线&quot;;
    m_wndToolBar.SetButtonText(4, str);

    m_wndToolBar.SetButtonInfo(5, ID_HIS_LINESEL, TBSTYLE_BUTTON, 5);
    str=&quot;历史曲线&quot;;
    m_wndToolBar.SetButtonText(5, str);

    m_wndToolBar.SetButtonInfo(6, ID_HELPTOPIC, TBSTYLE_BUTTON, 6);
    str=&quot;系统信息&quot;;
    m_wndToolBar.SetButtonText(6, str);

    m_wndToolBar.SetButtonInfo(7, ID_COMM_EXIT, TBSTYLE_BUTTON, 7);
    str=&quot;系统退出&quot;;
    m_wndToolBar.SetButtonText(7, str);

    CRect rectToolBar;
    //获取工具条按钮大小
    m_wndToolBar.GetItemRect(0, &amp;rectToolBar);
    //设置工具条的按钮大小和图标大小
    m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(21,22)); 
} 

下面是窗体创建函数
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;  

    //自己创建富有个性的工具条 
    CreateToolBar();    

    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
          sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0(&quot;Failed to create status bar\n&quot;);
        return -1;      // fail to create
    } 
    // TODO: Delete these three lines if you don't want the toolbar to
    //  be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&amp;m_wndToolBar);  

    this-&gt;m_wndStatusBar.SetPaneInfo(1,0,1,300);     

    EnableAutoStart();//设置程序自动开机运行
    SetStartMode();//设置显示器分辨率

    FindWindow(&quot;Shell_TrayWnd&quot;,NULL)-&gt;ShowWindow(SW_HIDE);//隐藏任务栏
    
    //获得窗口风格
    LONG style = ::GetWindowLong(m_hWnd,GWL_STYLE); 
    //设置新的风格 
    style &amp;=  ~(WS_MINIMIZEBOX);
    style &amp;=  ~(WS_MAXIMIZEBOX);
    ::SetWindowLong(m_hWnd,GWL_STYLE,style);

    //重化窗口边框
    CRect rc;
    GetWindowRect(&amp;rc);
    ::SetWindowPos(m_hWnd,HWND_NOTOPMOST,rc.left,rc.top,rc.Width(),rc.Height(),SWP_DRAWFRAME);

    return 0;
}

触发WM_CLOSE,进行程序退出时的清理工作,并加上退出的特效效果
void CMainFrame::OnClose() 
{
    // TODO: Add your message handler code here and/or call default
    CWindowAnima wa(this);
    wa.Scatter6(50,10); 
    FindWindow(&quot;Shell_TrayWnd&quot;,NULL)-&gt;ShowWindow(SW_SHOW);//隐藏任务栏
    CFrameWnd::OnClose();
}

触发VIEW的WM_PAINT消息,进行背景位图的显示
void CYbkDemoView::OnPaint() 
{
    CPaintDC dc(this); // device context for painting
    
    CRect rect;
    GetClientRect(&amp;rect); 
    HBITMAP hbitmap; 
    hbitmap=::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_MAIN)); 
    HDC hMenDC=::CreateCompatibleDC(NULL);
    SelectObject(hMenDC,hbitmap);
    ::StretchBlt(dc.m_hDC,0,0,1024,768,hMenDC,0,0,1024,768,SRCCOPY);
    ::DeleteDC(hMenDC);
    ::DeleteObject(hbitmap);
}

详细代码书写请看我作的示范工程,由于时间匆忙,中间有很多的语句表达可能不是很清楚,您可以在下面的留言中提出来或者,如果有什么问题的话青与我联系:13975102873@hnmcc.com</pre>
</body>
</html>
	
	<!-- CoreMail Version 2.5 Copyright (c) 2002-2005 www.mailtech.cn -->

⌨️ 快捷键说明

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