八宝书库 > 文学其他电子书 > VC语言6.0程序设计从入门到精通 >

第38部分

VC语言6.0程序设计从入门到精通-第38部分

小说: VC语言6.0程序设计从入门到精通 字数: 每页4000字

按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!




                                                                                                          第 6 章    文本和字体类  



               strAboutMenu。LoadString(IDS_ABOUTBOX);  



               if (!strAboutMenu。IsEmpty())  



               {  



                      pSysMenu…》AppendMenu(MF_SEPARATOR);  



                      pSysMenu…》AppendMenu(MF_STRING; IDM_ABOUTBOX; strAboutMenu);  



               }  



       }  



       // Set the icon for this dialog。    The framework does this automatically  



       //    when the application’s main window is not a dialog  



       SetIcon(m_hIcon; TRUE);                            // Set big icon  



       SetIcon(m_hIcon; FALSE);                    // Set small icon  



         



       // TODO: Add extra initialization here  



       TIMER=SetTimer(ID_TIMER1;150;NULL);  



       return TRUE;    // return TRUE    unless you set the focus to a control  



}  



  



void CGundongDlg::OnSysmand(UINT nID; LPARAM lParam)  



{  



       if ((nID & 0xFFF0) == IDM_ABOUTBOX)  



       {  



               CAboutDlg dlgAbout;  



               dlgAbout。DoModal();  



       }  



       else  



       {  



               CDialog::OnSysmand(nID; lParam);  



       }  



}  



// If you add a minimize button to your dialog; you will need the code below  



//    to draw the icon。    For MFC applications using the document/view model;  



//    this is automatically done for you by the framework。  



void CGundongDlg::OnPaint()    



{  



       if (IsIconic())  



       {  



               CPaintDC dc(this); // device context for painting  



               SendMessage(WM_ICONERASEBKGND; (WPARAM) dc。GetSafeHdc(); 0);  



               // Center icon in client rectangle  



               int cxIcon = GetSystemMetrics(SM_CXICON);  



                                                                                                                               ·155 ·  


…………………………………………………………Page 165……………………………………………………………

Visual C++ 6。0 程序设计从入门到精通  



                      int cyIcon = GetSystemMetrics(SM_CYICON);  



                      CRect rect;  



                      GetClientRect(&rect);  



                      int x = (rect。Width() cxIcon + 1) / 2;  



                      int y = (rect。Height() cyIcon + 1) / 2;  



         



                      // Draw the icon  



                      dc。DrawIcon(x; y; m_hIcon);  



              }  



              else  



              {        



                      CPaintDC dc(this); // device context for painting  



                      dc。SetTextColor(RGB (180;240;210));      



                      dc。SetBkMode(TRANSPARENT); //设置背景为透明!  



                      CRect rect;  



                      rect。left=150;  



                      rect。right=350;  



                      rect。top=10;  



                      rect。bottom=40;  



                      dc。Rectangle(&rect);  



                      dc。FillRect(▭&m_brush1);  



                      rect。left=10;  



                      rect。right=135;  



                      rect。top=40;  



                      rect。bottom=200;  



                      dc。Rectangle(&rect);  



                      dc。FillRect(▭&m_brush1);  



                      dc。TextOut(WidthX;15;m_str);  



                       dc。TextOut(15;Heighty;m_str);  



              //      CDialog::OnPaint();  



              }  



       }  



       // The system calls this to obtain the cursor to display while the user drags  



       //    the minimized window。  



       HCURSOR CGundongDlg::OnQueryDragIcon()  



        {  



              return (HCURSOR) m_hIcon;  



       }  



       void CGundongDlg::OnTimer(UINT nIDEvent)    



        {  



 ·156 ·  


…………………………………………………………Page 166……………………………………………………………

                                                                                                  第 6 章    文本和字体类  



       // TODO: Add your message handler code here and/or call default  



        DrawV();  



        DrawH();  



       CDialog::OnTimer(nIDEvent);  



}  



void CGundongDlg::DrawV()    //竖直方向滚动函数  



{  



        CRect rect;                          //每次重画区域大小  



       rect。left=10;  



       rect。right=m_str。GetLength()+rect。left+120;  



       CFont * font=GetFont();  



       LOGFONT logFont;  



       font…》GetLogFont(&logFont);  



       rect。top=Heighty;  



       rect。bottom=rect。top+logFont。lfHeight+40;  



       InvalidateRect(&rect);  



       Heighty+=logFont。lfHeight+18;              //每步向下移动距离  



       if(Heighty》=maxHeight) Heighty=15;    // 回到起始位置  



       UpdateWindow();  



}  



void CGundongDlg::DrawH()      //水平向滚动函数  



{      



        CRect rect;                            //每次重画区域大小  



       rect。top=15;  



        CFont * font=GetFont();  



       LOGFONT logFont;  



       font…》GetLogFont(&logFont);  



       rect。bottom=rect。top+logFont。lfHeight+80;  



       rect。left=WidthX…m_str。GetLength()…10;  



       rect。right=rect。left+m_str。GetLength()+150;  



       InvalidateRect(&rect);  



       if(WidthXSelectObject(&m_font);  



              pDC…》SetBkMode(TRANSPARENT);  



              int cx = 100; cy = 100;              //文本输出位置  



              CString sTemp = m_sText;  



              cx += 3;  



              cy += 3;  



              pDC…》SetTextColor(GetSysColor(COLOR_3DDKSHADOW)); // 以下先输出突出的 3D 文本  



              pDC…》TextOut(cx+2;cy…2;sTemp);  



              pDC…》TextOut(cx+2;cy+2;sTemp);  



              pDC…》SetTextColor(GetSysColor(COLOR_3DHILIGHT));  



  



              pDC…》TextOut(cx+1;cy…2;sTemp);  



              pDC…》TextOut(cx…2;cy+1;sTemp);  



              pDC…》TextOut(cx…2;cy…2;sTemp);  



              pDC…》SetTextColor(GetSysColor(COLOR_3DSHADOW));  



  



              pDC…》TextOut(cx…1;cy+1;sTemp);  



              pDC…》TextOut(cx+1;cy

返回目录 上一页 下一页 回到顶部 0 0

你可能喜欢的