工大在线

标题: 计算机编程小组诚邀高手加盟!! [打印本页]

作者: liu19880426    时间: 2008-5-27 21:42
标题: 计算机编程小组诚邀高手加盟!!
你是否对计算机感兴趣,
是否希望在将来的某一天成为一个高手?
你是否觉得大学的生活让你很迷茫,是否感觉所学无用武之地?
.......

现在,机会来了,我们有意成立一个计算机编程小组,诚邀有共同兴趣同学加入!!

我们计划成立后参加计算机学院于帆老师研究项目!

他将耐心的辅导我们,共同探讨有关编程方面的问题,参与于帆老师的部分研究课题!

如有意者,请联系本人,联系方式:13468726217
QQ:470975146,宿舍:4-612

作者: liu19880426    时间: 2008-5-27 21:43
希望大家积极响应~~

尽快成立!!
作者: woainbadc    时间: 2008-5-27 21:45
我们班的强人啊 我来  了 么事叫我 有一天我会跟你们一样的
作者: liu19880426    时间: 2008-5-27 21:49
哈哈,你就加油哈.....

我们会等你的~~
作者: woainbadc    时间: 2008-5-27 21:50
来来么 都编起来C++我的专长 来我教你们
作者: woainbadc    时间: 2008-5-27 22:06
给我上来 有我在你就下不去 上上
作者: woainbadc    时间: 2008-5-27 22:20
没人看 啊 郁闷了 杂回事啊 没人喜欢编程?  郁闷了
作者: lichao_2007    时间: 2008-5-27 22:21
呵呵~恭喜获奖的同学了哈~
作者: liu19880426    时间: 2008-5-27 22:31
诚心感动我哈,会有的,要坚持哈~~
作者: liu19880426    时间: 2008-5-27 22:32
以后跟你混C++了,有前途啊
作者: woainbadc    时间: 2008-5-27 22:41
呵呵 我是吹的我P都不懂 但是只是暂时的 相信自己相信伙伴
作者: zsd100    时间: 2008-5-27 23:12
加油啊......
作者: liu19880426    时间: 2008-5-27 23:17
谢谢支持啦~

还要大家支持我们!
作者: woainbadc    时间: 2008-5-28 16:15
大家都来参加啊  快来撒
作者: liu19880426    时间: 2008-5-28 16:46
就是啊,要不你来哈!!
作者: liu19880426    时间: 2008-5-28 22:19
大家快来啊.........
作者: liu19880426    时间: 2008-5-28 22:45
不限学院...................
作者: jianning    时间: 2008-5-28 23:43
不是高手能来吗?java
作者: wyt323    时间: 2008-5-29 17:41
既然小组成立了,没有题目可不好玩哦,我来给大家出个小题目,抛砖引玉:
从串“我在编程兴趣小组等你!”中找到串“编程兴趣小组”所处的位置,不限编程语言,我用C++给大家一个例子,大家用自己的方法实现哦
作者: wyt323    时间: 2008-5-29 17:42
#include <string.h>
#include <stdio.h>

char str[] =    "编程兴趣小组";
char string[] = "我在编程兴趣小组等你!";


void main( void )
{
   char *pdest;
   int  result;
   printf( "我找到你了:\n\t%s\n", str);
   
   pdest = strstr( string, str );
   result = pdest - string + 1;
   if( pdest != NULL )
      printf( "%s 在 %s  的第 %d\n\n", str, string,result );
   else
      printf( "%s 没有发现\n", str );
}
// Output
我找到你了:
   编程兴趣小组
   编程兴趣小组 在 我在编程兴趣小组等你!  的第 3
作者: woainbadc    时间: 2008-5-29 17:52
只要是喜欢编程的 都行
作者: liu19880426    时间: 2008-5-29 18:01
(*^__^*) 嘻嘻……
作者: jianning    时间: 2008-5-30 01:25
标题: JAVA
public class App {
        static String str1="我在编程兴趣小组等你!";
        static String str2="编程兴趣小组";
        public static void foundWord(){
                for(int i=0;i<str1.length();i++){
                        str1.charAt(i);
                char str3=str1.charAt(i);
                        if(str3==str2.charAt(1)){
                        System.out.println(str2+":       从"+i+"位置开始到"+(i+str2.length()-1)+"结束");
                                }
                        }
                }
        public static void main(String[] args) {
                // TODO Auto-generated method stub
                foundWord();
        }

}

运行结果  
编程兴趣小组:       从3位置开始到8结束
作者: zsd100    时间: 2008-5-30 01:28
那人的例子可是纯C风格啊.......
作者: wyt323    时间: 2008-5-30 11:31
没想到这里还有同样喜欢柯南的,俺可是每集必看哦
作者: sakyamun    时间: 2008-5-30 11:34
怎么就这么几个人一直说话啊
作者: wyt323    时间: 2008-5-30 17:44
23楼的写的不错,不过在JAVA里还有更简单的方法哦,用String的IndexOf函数可以省去for 循环哦
作者: jianning    时间: 2008-5-30 18:50
标题: 谢谢指正
public class CApp {
       
        static String str1="我在编程兴趣小组等你!";
        static String str2="编程兴趣小组";
        public static void foundWord(){
                int number  =str1.indexOf(str2.codePointAt(1));
                        System.out.print(str2+":是从"+number+"开始的");
        }
  public static void main(String[] args) {
        foundWord();

        }
  }


输出结果: 编程兴趣小组:是从3开始的
作者: 疯人院里一青年    时间: 2008-5-30 19:05
20楼的程序是纯C程序啊。要用C++就应该string类型和find()函数才算C++吧。
作者: wyt323    时间: 2008-5-30 19:07
不是指正,是互相学习,共同进步哦
作者: wyt323    时间: 2008-5-30 19:09
谢谢,赞同31楼的说法
作者: 疯人院里一青年    时间: 2008-5-30 19:45
呵呵,不好意思。

我没有指正您的意思,只是想告诉各位看官,那不是C++,C++不是"C with classes"。他们解决这类基础问题的方式是不同的,如果用C++来解决这个问题代码就应该看上去像C++。

随便写一个,现在没有编译器,没有运行,不敢肯定对不对。
#include <string>
#include <iostream>
using namespace std;
int main()
{                     
        cout<<"位置:"<<(int(string("我在编程兴趣小组等你!").find("编程兴趣小组"))>>1)+1<<" 为0表示未找到";
                      return 0;
}
作者: liu19880426    时间: 2008-5-30 23:41
(*^__^*) 嘻嘻……,你还真搞笑呢~
作者: wyt323    时间: 2008-5-31 10:15
疯人院里一青年:
你可能有点误会,我上一帖是对jianning说的,放在这里的东西就是让大家来拍砖头的,而且要狠狠的拍哦。要不然就没意识了
作者: wyt323    时间: 2008-5-31 10:52
感谢疯人院里的一青年和24楼的灰原
本人确实已经将C语言和C++混为一谈了,因该说已经忘记C语言的存在了。

#include "stdafx.h"
#include <locale>
#include <iostream>
#include "atlstr.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
        CString strSource="我在编程兴趣小组等你!",strFind="编程兴趣小组",strShow;
        int nIndex=strSource.Find(strFind);
        strShow.Format("我找到你了\r\n    %s\r\n    %s 在 %s 的第 %d",strFind,strFind,strSource,nIndex/2+1);
        cout<<strShow.GetBuffer();
        return 0;
}
运行结果:

我找到你了
    编程兴趣小组
    编程兴趣小组 在 我在编程兴趣小组等你!的第 3
作者: dixnuits    时间: 2008-5-31 20:06
.NET类库把这些东西都写了
用C#写了个

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "我在编程兴趣小组等你!", fnd = "编程兴趣小组";
            Console.WriteLine("在第{0}个位置找到字符串.", str.IndexOf(fnd)+1);
            Console.ReadKey();
        }
    }
}
作者: 郑方    时间: 2008-5-31 20:58
原帖由 liu19880426 于 2008-5-27 21:42 发表
你是否对计算机感兴趣,
是否希望在将来的某一天成为一个高手?
你是否觉得大学的生活让你很迷茫,是否感觉所学无用武之地?
.......

现在,机会来了,我们有意成立一个计算机编程小组,诚邀有共同兴趣同学加 ...

我报名邀有共同兴趣邀有共同兴趣
作者: liu19880426    时间: 2008-6-3 15:52
什么意思哦?


......


不是很懂~
作者: wyt323    时间: 2008-6-3 15:57
大家的代码写的都不错,非常感谢!只是拍砖头的人不多哦,现在给大家一段有问题的C语言的代码,希望大家多多拍砖
作者: wyt323    时间: 2008-6-3 16:18
代码实现的功能:要实现将十六进制字符串,转换成相应的字符串,例如:将字符串"0031003200330034"转换成字符串"1234",也就是说,第一个字符串表示的是UNICODE形式的十六进制的编码串;注释:1的UNICODE形式的十六进制的编码为0031


                WCHAR wszTempText[100],wszText[100];
                ::memset(wszText,0x00,sizeof(wszText));
                ::wcscpy(wszText,buf);
                memset(wszTempText, 0x00, sizeof(wszTempText));
                (void)wcscpy(wszTempText, wszText);
                memset(wszText, 0x00, sizeof(wszText));
                int nCount=wcslen(wszTempText)/4;
                WCHAR  chTemp[4];
                for(int i=0;i<nCount;i++)
                {
                        ::memset(chTemp,0x00,sizeof(chTemp));
                        for(int j=0;j<4;j++)
                        {
                                chTemp[j]=wszTempText[i*4+j];
                        }
                        wchar_t lTemp = (wchar_t)::_tcstol(chTemp, 0, 16);
                        wszText=lTemp;
                }
                wszText[nCount]='\0';

代码是有问题的,问题在哪请大家找出来?
喜欢JAVA,C#,C++的朋友可以根据要求写出自己的东东来。

[ 本帖最后由 wyt323 于 2008-6-3 16:19 编辑 ]
作者: wyt323    时间: 2008-6-3 16:33
建议坛主建一个编程技术谈论的领地,在哪里大家互不相识讨论起来会无所顾忌,畅所欲言。可以把自己平时遇到的问题,或者什么想法都发到论坛里,大家共同讨论解决。
仅是建议本人初来乍到,对这里的规矩不懂,如有冒犯,还请海涵

[ 本帖最后由 wyt323 于 2008-6-4 11:07 编辑 ]
作者: jianning    时间: 2008-6-3 22:09
第一个字符串表示的是UNICODE形式的十六进制的编码串
不是很明白?
作者: wyt323    时间: 2008-6-4 10:32
比如说字符‘1’,他的UNICODE十六进制串是"0031";字符‘a’,他的UNICODE十六进制串是"0061";字符‘中’,他的UNICODE十六进制串是"4E2D";字符串"编程兴趣小组"的UNICODE十六进制串是"7F167A0B51748DA35C0F7EC4";
要实现的功能就是将串"7F167A0B51748DA35C0F7EC4"转换成串"编程兴趣小组"
作者: wyt323    时间: 2008-6-4 13:52
提示:JAVA和C#里Convert 里找方法
作者: jianning    时间: 2008-6-4 19:38
标题: 测试一下了:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Testing {

        static String str="0031003200330034";
        public static void change(){
                BufferedReader inputReader = new BufferedReader(new InputStreamReader(
                                System.in));
                String input = null;
                try {
                        System.out.println("请输入16进制字符串:");
                        input = inputReader.readLine();
                        StringBuffer sbuf=new StringBuffer();
                        StringBuffer sbuf2=new StringBuffer();
                        for (int m = 0; m < input.length(); m++) {
                                char ch = input.charAt(m);
                                sbuf.append(ch);
                                char chch=(char)(Integer.parseInt(sbuf.toString(), 16));
                               
                                if ((m+1) % 4 == 0) {
                                        sbuf2.append(chch);
                    sbuf.delete(0,4);
                                }
                        }
                       
                        System.out.println(sbuf2.toString());
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

        }
        public static void main(String[] args) {
               
                change();
                // TODO Auto-generated method stub

        }

}

输入:0031003200330034
输出:1234
输入:7F167A0B51748DA35C0F7EC4
输出:编程兴趣小组
作者: wyt323    时间: 2008-6-5 09:46
你的代码写的相当漂亮,能够实现功能,非常感谢!
但是 char chch=(char)(Integer.parseInt(sbuf.toString(), 16));
放在  if ((m+1) % 4 == 0) {下面的话,好像更加合理,你觉得呢?
作者: dixnuits    时间: 2008-6-5 21:46
原帖由 wyt323 于 2008-6-4 13:52 发表
提示:JAVA和C#里Convert 里找方法

Convert里找不到方法,我菜鸟

只能用自己的方法写了一下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace ConsoleApplication2
{
    class Program
    {
        static string UnicodeToString(string srcstr)
        {
            string ret = "";
            string src = srcstr;
            int len = srcstr.Length / 4;

            for (int i = 0; i <= len - 1; i++)
            {
                string str = "";
                str = src.Substring(0,4);
                src = src.Substring(4);
                byte[] bytes = new byte[2];
                bytes[1] = byte.Parse(int.Parse(str.Substring(0, 2), NumberStyles.HexNumber).ToString());
                bytes[0] = byte.Parse(int.Parse(str.Substring(2, 2), NumberStyles.HexNumber).ToString());
                ret += Encoding.Unicode.GetString(bytes);
            }
            return ret;
        }

        static void Main(string[] args)
        {
            Console.WriteLine("请输入Unicode字符串:");
            string str = Console.ReadLine();
            Console.WriteLine("转化结果为:{0}", UnicodeToString(str));
            Console.ReadKey();
        }
    }
}
作者: wyt323    时间: 2008-6-6 15:11
呵呵,菜鸟是我吧,不该提示的地方瞎提示,结果造成误导

[ 本帖最后由 wyt323 于 2008-6-6 15:36 编辑 ]
作者: wyt323    时间: 2008-6-6 15:44
在parse的时候没有必要两位两位的parse,再对数组进行GetString()  , 可以直接这么搞  : ret+=((char)int.Parse(str, System.Globalization.NumberStyles.HexNumber)).ToString();
作者: wyt323    时间: 2008-6-6 15:53
其实本人什么也不懂,表现的这么嚣张怎么没有人拍砖头啊,郁闷

[ 本帖最后由 wyt323 于 2008-6-6 16:18 编辑 ]
作者: wyt323    时间: 2008-6-6 15:54
在parse的时候没有必要两位两位的parse,再对数组进行GetString()  , 可以直接这么搞  : ret+=((char)int.Parse(str, System.Globalization.NumberStyles.HexNumber)).ToString();
作者: wyt323    时间: 2008-6-6 15:56
Convert里的方法跟int.parse相似:(char)Convert.ToInt16(str, 16);
作者: dixnuits    时间: 2008-6-6 18:08
Encoding.Unicode.GetString( );

参数必须是byte型数组.
作者: tianyajian1982    时间: 2008-6-9 19:44
标题: 中国移动淘宝网代充话费 充50只需 49.60元 充100仅需99元
中国移动淘宝网代充话费 充50只需 49.60元 充100仅需99元
建议通过淘宝网
陕西移动手机话费优惠充值进行中http://auction1.taobao.com/auction/item_detail-0db2-dfa4ef8eac53d96a671c2468dc19ed6f.jhtml了解详情,
支付宝是网上流行的快捷、方便、安全的交易方式,强烈建议通过支付宝交易。
话费充值本来就利薄,也没有多大的降价空间,本人做这个也不是为了挣钱,纯粹为了赢取好评和信誉度,以便在网络中赢得认可。
望大家多多支持,谢谢!
作者: woainbadc    时间: 2008-6-9 19:46
这楼层很高 但是我的楼层上60+了 建明+u
作者: wyt323    时间: 2008-6-10 11:55
原帖由 dixnuits 于 2008-6-6 18:08 发表
Encoding.Unicode.GetString( );

参数必须是byte型数组.


没错,用Encoding.Unicode.GetString( );确实如此,但是parse以后,直接char强转就搞定了,没有必要用Encoding.Unicode.GetString( );
嘻嘻,并不是你的编码有问题,也不是方法不好,只是觉得不够简洁,呵呵;
作者: liu19880426    时间: 2008-6-10 12:20
好,要+u!!


你也继续哈!
作者: wyt323    时间: 2008-6-10 14:16
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace ConsoleApplication2
{
    class Program
    {
        static string UnicodeToString(string srcstr)
        {
            string ret = "";
            string src = srcstr;
            int len = srcstr.Length / 4;

            for (int i = 0; i <= len - 1; i++)
            {
                string str = "";
                str = src.Substring(0,4);
                src = src.Substring(4);
                if(有非法字符)
                {
                   continue;
                }
                else
                {
                   ret+=((char)int.Parse(str, System.Globalization.NumberStyles.HexNumber)).ToString();       
                }
               
            }
            return ret;
        }

        static void Main(string[] args)
        {
            Console.WriteLine("请输入Unicode字符串:");
            string str = Console.ReadLine();
            Console.WriteLine("转化结果为:{0}", UnicodeToString(str));
            Console.ReadKey();
        }
    }
}
作者: liu19880426    时间: 2008-6-10 14:19
有意向的留下联系方式哦!
作者: liu19880426    时间: 2008-6-10 14:20
有意向的留下联系方式哦!
作者: liu19880426    时间: 2008-6-10 14:20
有意向的留下联系方式哦!
作者: wyt323    时间: 2008-6-10 14:25
看来搞C或者C++的对这些问题不屑一顾,那好吧,我自己来,我给出的C代码,最主要的错误就是没有结尾符,得出的大多数时间是乱码
作者: wyt323    时间: 2008-6-11 16:20
C++里可以这么实现:
CString UnicodeHexToUnicode(CString strSource)
{
        CString strtemp,strReturn;
        int nCount=strSource.GetLength()/4;
        for(int i=0;i<nCount;i++)
        {
                strtemp=strSource.Mid(i*4,4);
                wchar_t lTemp = (wchar_t)::_tcstol(strtemp.GetBuffer(), 0, 16);
                strReturn+=lTemp;
        }
        return strReturn;
}
作者: liu19880426    时间: 2008-6-11 16:36
C的代码呢??????
作者: liu19880426    时间: 2008-6-11 16:36
建高楼哈,大家努力支持!
作者: woainbadc    时间: 2008-6-11 16:45
我服你了  这楼层比我的还高 你牛了
作者: wyt323    时间: 2008-6-11 16:46
C里可以这么实现:
void UnicodeHexToUnicode(WCHAR wszText [])
{
        WCHAR * pwszTempText=new WCHAR[wcslen(wszText)+1];
        memset(pwszTempText, 0x00, sizeof(pwszTempText));
        (void)wcscpy(pwszTempText, wszText);
        memset(wszText, 0x00, sizeof(wszText));
        int nCount=wcslen(pwszTempText)/4;
        WCHAR  chTemp[5];
        for(int i=0;i<nCount;i++)
        {
                ::memset(chTemp,0x00,sizeof(chTemp));
                ::memcpy(chTemp,pwszTempText+sizeof(WCHAR)*i,sizeof(WCHAR)*4);
                wchar_t lTemp = (wchar_t)::_tcstol(chTemp, 0, 16);
                wszText=lTemp;
        }
        wszText[nCount]='\0';
                delete [] pwszTempText;
}

[ 本帖最后由 wyt323 于 2008-6-11 16:50 编辑 ]
作者: wyt323    时间: 2008-6-11 17:13
巴嘎,上当,原来坛主只是为了建高楼
作者: wyt323    时间: 2008-6-11 18:40
原始C代码在40楼
作者: liu19880426    时间: 2008-6-11 20:36
兄弟,你这么说可真是冤枉我啦!!


绝对不是这个目的哈
·
作者: liu19880426    时间: 2008-6-11 20:37
兄弟,你这么说可真是冤枉我啦!!


绝对不是这个目的哈
·
作者: liu19880426    时间: 2008-6-11 20:38
这下可难办了,居然有人这样认为!


汗!
作者: wyt323    时间: 2008-6-12 10:13
这叫将军,你把弟兄们召集过来却不说明活动细则,所以将你一军,让你开口说话,呵呵,是不是有点卑鄙[s:28] [s:28]
作者: liu19880426    时间: 2008-6-12 10:49
打电话和我们联系!!!


上面不是留有电话号码么?
作者: wyt323    时间: 2008-6-14 10:44
哦,原来是这样啊,我明白了,如果今年能成为本校的一员,再去参加了,到时候不要因为我是刚入学的新生不肯接纳哦
作者: wyt323    时间: 2008-6-14 15:41
最后一题:让“西工大  体坛风云 编程兴趣小组诚邀有共同兴趣同学加入!”,有左下角出来,满满的移动到右上角,循环往复,移动的过程中字体逐渐变小,直至消失,不限语言和编程手法,也可以是flash或者SliverLight

[ 本帖最后由 wyt323 于 2008-6-16 10:24 编辑 ]
作者: wyt323    时间: 2008-6-14 16:09
这体的题目就叫做让编程兴趣小组活跃起来吧
作者: jianning    时间: 2008-6-16 01:40
你现在是在那个学校了?
上面那个试试能不能flash做了
作者: wyt323    时间: 2008-6-16 11:01
我现在所在学校,嘻嘻,怕被你们看扁了,保密哦。
作者: wyt323    时间: 2008-6-19 10:13
给大家写了一个C++的代码,供参考,VC++2005编译:
//ShowString.h
#pragma once

class ShowString
{
private:
        CStringList m_strlist;
        int m_nCount,m_nHeight,m_nCountLine;
        const static int m_csnDec;
        const static int m_csnMaxFont;
        const static int m_csnMinFont;
        POSITION m_Pos;
        bool m_bIsFull;

public:
        ShowString(void);
        ShowString(CString strshow[],int nCount);
        void Show(CDC * pdc,CRect rcShow);
private:
        void ShowText(CDC *pdc,int nleft,int nBottom,CString str,int nHeight,COLORREF col);
        int  GetFontHeight(int nIndex);
        int  GetLengthMoveRight(CRect rcShow);
        int  GetLeft(int nIndex,CRect rcShow);
        int  GetBottom(int nIndex);
        CString GetString();
public:
        ~ShowString(void);

};

//ShowString.cpp

#include "StdAfx.h"
#include "ShowString.h"

const  int ShowString::m_csnDec=2;
const  int ShowString::m_csnMaxFont=40;
const  int ShowString::m_csnMinFont=2;

ShowString::ShowString(void)
{
        m_strlist.RemoveAll();
        m_nCount=0;
        m_nHeight=0;
        m_nCountLine=0;
        m_Pos=NULL;
        m_bIsFull=false;
}
ShowString::ShowString(CString strshow[],int nCount)
{
        m_strlist.RemoveAll();
        for(int i=0;i<nCount;i++)
        {
                m_strlist.AddTail(strshow);
        }
        m_nCount=nCount;
        m_nHeight=0;
        m_nCountLine=0;
        m_Pos=NULL;
        m_bIsFull=false;
}

ShowString::~ShowString(void)
{
}

void ShowString::Show(CDC * pdc,CRect rcShow)
{
        int nBottom=0;
        if(m_nCount<=0)
        {
                return;
        }
        if(!m_bIsFull)
        {
                m_nCountLine++;
        }
        CDC dc/*MemDC*/;
        dc.CreateCompatibleDC(pdc);

        CBitmap bmp;
        bmp.CreateCompatibleBitmap(pdc, rcShow.Width(), rcShow.Height());
        CBitmap *bmpOld=dc.SelectObject(&bmp);

        for(int i=m_nCountLine;i>0;i--)
        {
                nBottom=GetBottom(i);
                if(nBottom>=rcShow.Height())
                {
                        m_bIsFull=true;
                }
                ShowText(&dc,GetLeft(i,rcShow),rcShow.Height()-nBottom,this->GetString(),this->GetFontHeight(i),RGB(255,255,0));
        }

        BOOL iff=pdc->BitBlt(0,0,rcShow.Width(),rcShow.Height(),&dc,0,0, SRCCOPY);
        //恢复老配置
        dc.SelectObject(bmpOld);
        dc.DeleteDC();
}
CString ShowString::GetString()
{
        CString str=_T("");
        if(m_Pos==NULL)
        {
                m_Pos=m_strlist.GetHeadPosition();
        }
        if(m_Pos!=NULL)
        {
                str=m_strlist.GetAt(m_Pos);
                m_strlist.GetNext(m_Pos);
        }
        return str;
}

//显示字符串
//str【in】要显示的字符串
void ShowString::ShowText(CDC *pdc,int nleft,int nBottom,CString str,int nHeight,COLORREF col)
{
        if((nHeight<=0)||(str==_T("")))
        {
                return;
        }
        COLORREF oldclor=pdc->SetTextColor(col);

        //创建字体
        CFont font;
        VERIFY(font.CreateFont(
                nHeight,                        // nHeight
                0,                         // nWidth
                0,                         // nEscapement
                0,                         // nOrientation
                FW_LIGHT,                 // nWeight
                FALSE,                     // bItalic
                FALSE,                     // bUnderline
                0,                         // cStrikeOut
                ANSI_CHARSET,              // nCharSet
                OUT_DEFAULT_PRECIS,        // nOutPrecision
                CLIP_DEFAULT_PRECIS,       // nClipPrecision
                DEFAULT_QUALITY,           // nQuality
                /*FF_DONTCARE|*//*DEFAULT_PITCH |*/ FF_SWISS,  // nPitchAndFamily
                _T("Arial")));          // lpszFacename
        //显示字符串TRANSPARENT
        pdc->SetBkMode(0);       
        //创建白色画笔
        CPen  whitePen,*Oldpen;
        BOOL b=whitePen.CreatePen(PS_SOLID,5,RGB(255,255,255));
        //将字符串居中显示
        //int n=str.GetLength();
        CFont * pfontOld=pdc->SelectObject(&font);
        //CString strTemp=_T("中");
        CSize sz=pdc->GetTextExtent(str);
        int nTop=nBottom+sz.cy;
        Oldpen=pdc->SelectObject(&whitePen);
        BOOL bc=pdc->ExtTextOut(nleft,nTop,ETO_CLIPPED,CRect(nleft,nTop,nleft+sz.cx,nTop+sz.cy),str,NULL);
        pdc->SelectObject(pfontOld);
        pdc->SelectObject(Oldpen);
        pdc->SetTextColor(oldclor);
        Oldpen=NULL;
        font.DeleteObject();
}

int  ShowString::GetFontHeight(int nIndex)
{
        int nHeight=m_csnMaxFont-nIndex*m_csnDec;
        if(nHeight<m_csnMinFont)
        {
                nHeight=0;
        }
        return (nHeight);
}
int  ShowString::GetLengthMoveRight(CRect rcShow)
{
        int nlineMax=(m_csnMaxFont-m_csnMinFont)/m_csnDec;
        if(nlineMax==0)
        {
                return 0;
        }
        return (rcShow.Width()/nlineMax);
}
int  ShowString::GetLeft(int nIndex,CRect rcShow)
{
        return (GetLengthMoveRight(rcShow)*nIndex);
}
int  ShowString::GetBottom(int nIndex)
{
        int nFontheight=GetFontHeight(nIndex);
        return ((m_csnMaxFont+nFontheight)*nIndex/2+nIndex*2-2);
}

//ShowDlg.h
// ShowDlg.h : header file
//

#pragma once
#include "ShowString.h"

// CShowDlg dialog
class CShowDlg : public CDialog
{
// Construction
public:
        CShowDlg(CWnd* pParent = NULL);        // standard constructor

// Dialog Data
        enum { IDD = IDD_SHOW_DIALOG };

        protected:
        virtual void DoDataExchange(CDataExchange* pDX);        // DDX/DDV support


// Implementation
protected:
        HICON m_hIcon;

        // Generated message map functions
        virtual BOOL OnInitDialog();
        afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
        afx_msg void OnPaint();
        afx_msg HCURSOR OnQueryDragIcon();
        DECLARE_MESSAGE_MAP()
private:
        ShowString * m_pshow;
        UINT_PTR m_timer;
private:
        afx_msg void OnTimer(UINT_PTR nIDEvent);
        afx_msg void OnClose();
        afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};

//ShowDlg.cpp
// ShowDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Show.h"
#include "ShowDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
        CAboutDlg();

// Dialog Data
        enum { IDD = IDD_ABOUTBOX };

        protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
        DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CShowDlg dialog




CShowDlg::CShowDlg(CWnd* pParent /*=NULL*/)
        : CDialog(CShowDlg::IDD, pParent)
{
        m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
        m_timer=2;
        CString str[]={_T("西工大"),_T("体坛风云"),_T("编程兴趣小组"),_T("诚邀有共同兴趣同学加入!!")};
        m_pshow=new ShowString(str,4);
}

void CShowDlg::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CShowDlg, CDialog)
        ON_WM_SYSCOMMAND()
        ON_WM_PAINT()
        ON_WM_QUERYDRAGICON()
        //}}AFX_MSG_MAP
        ON_WM_TIMER()
        ON_WM_CLOSE()
        ON_WM_ERASEBKGND()
END_MESSAGE_MAP()


// CShowDlg message handlers

BOOL CShowDlg::OnInitDialog()
{
        CDialog::OnInitDialog();

        // Add "About..." menu item to system menu.

        // IDM_ABOUTBOX must be in the system command range.
        ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
        ASSERT(IDM_ABOUTBOX < 0xF000);

        CMenu* pSysMenu = GetSystemMenu(FALSE);
        if (pSysMenu != NULL)
        {
                CString strAboutMenu;
                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
        this->SetTimer(m_timer,100,NULL);

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

void CShowDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
        if ((nID & 0xFFF0) == IDM_ABOUTBOX)
        {
                CAboutDlg dlgAbout;
                dlgAbout.DoModal();
        }
        else
        {
                CDialog::OnSysCommand(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 CShowDlg::OnPaint()
{
        CPaintDC dc(this); // device context for painting

        if (IsIconic())
        {
                SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

                // Center icon in client rectangle
                int cxIcon = GetSystemMetrics(SM_CXICON);
                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
        {
                CRect rc;
                this->GetClientRect(rc);
                m_pshow->Show(&dc,rc);
                CDialog::OnPaint();
        }
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CShowDlg::OnQueryDragIcon()
{
        return static_cast<HCURSOR>(m_hIcon);
}


void CShowDlg::OnTimer(UINT_PTR nIDEvent)
{
        // TODO: Add your message handler code here and/or call default
        if(m_timer==nIDEvent)
        {
                this->Invalidate();
        }

        CDialog::OnTimer(nIDEvent);
}

void CShowDlg::OnClose()
{
        // TODO: Add your message handler code here and/or call default
        delete m_pshow;
        m_pshow=NULL;

        CDialog::OnClose();
}

BOOL CShowDlg::OnEraseBkgnd(CDC* pDC)
{
        // TODO: Add your message handler code here and/or call default
        return FALSE;

        //return CDialog::OnEraseBkgnd(pDC);
}
作者: 夜色温柔    时间: 2008-6-23 09:11
为何wyt323兄弟总是在用那些个开发工具提供的扩展语言呢~    我觉得既然还是学生  应该多研究下语言本身所拥有的东西和语言所提供的思维方式  我以前也总是陶醉于那些别人封装好的东西  认为既然我可以用一个库里的方法又何必了解它到底是咋作的~   现在发现 人家看过STL设计方面的书的写起复用代码来就是比我猛  BUG就是比我写的东西少   虽然都是C++CLI    但是明显象我这类大学没有深入研究过语言的人对那些新模型的理解就要慢很多  我现在正在看《泛型编程与STL》确实收益不少  没办法  程序员就是得不断的学习   

我觉得wyt323兄弟的前途无可限量   祝你成功^_^
作者: wyt323    时间: 2008-6-23 09:49
兄台指的可是ExtTextOut函数,这个本来可以用TextOut的,但是考虑到在Mobile和Wince系统上没有这个函数,只有ExtTextOut函数,为了使这个类在微软的所有的系统平台上能够无缝移植,所以改用了ExTextOut
作者: wyt323    时间: 2008-6-23 12:06
我理解错兄台的意识了。兄台说的对极了,语法确实很玄妙,达到不同的境界,就会有不同的理解,我们确实应该在语法上好好下功夫
作者: wyt323    时间: 2008-6-23 18:25
javascript+html实现:

<script language=javascript>
var conut=0;
    function fun()
    {
        conut++;
        if(conut>20)
        {
        conut=0;
        }
        xg.style.left=50*conut;
        xg.style.top=600-30*conut;
        xg.style.fontSize=60-3*conut;
        tt.style.left=50*conut-50;
        tt.style.top=600-30*conut+60;
        tt.style.fontSize=60-3*conut+3;
        xz.style.left=50*conut-100;
        xz.style.top=600-30*conut+120;
        xz.style.fontSize=60-3*conut+6;
        hy.style.left=50*conut-150;
        hy.style.top=600-30*conut+180;
        hy.style.fontSize=60-3*conut+9;
        setTimeout("fun()",1000);
    }
</script>
<body  onload=fun()>

<DIV id=xg style="position:absolute;fontsize:50">西工大</DIV><BR>
<DIV id=tt style="position:absolute;fontsize:50">体坛风云</DIV><BR>
<DIV id=xz style="position:absolute;fontsize:50">编程兴趣小组</DIV><BR>
<DIV id=hy style="position:absolute;fontsize:50">诚邀有共同兴趣同学加入!!</DIV><BR>
</body>
作者: wyt323    时间: 2008-6-23 18:34
比较拙略,没有考虑随字体的减小,应将行间的距离比例减小,还望有兴趣的朋友更正
作者: wyt323    时间: 2008-6-23 19:05
月色温柔,感觉你想在职程序员,能否给说说,公司里最需要程序员具备什么样的知识,
我们现在还生活在学校的象牙塔里,很迷茫,不知道该学些啥,不懂得啥有用啥没有用,谢谢
作者: piluge    时间: 2008-6-25 19:05
你们愿意参加IBM的2008数据库大赛吗?我的邮箱是ciw_wuwei@ciw.com.cn
作者: wyt323    时间: 2008-6-25 20:05
呵呵,已经报名了
作者: luwei42768    时间: 2008-6-27 09:27
标题: 如何加入
如何加入这个小组
作者: wyt323    时间: 2008-6-27 14:10
给坛主打电话13468726217
作者: qiaokelinan    时间: 2008-7-1 12:15
于帆 那是软硬通吃啊 很强一个银
作者: cyclxoath    时间: 2008-8-16 11:04
标题: 不错
灌          水
作者: cyclxoath    时间: 2008-8-16 11:04
标题: 再灌点
其实我觉得编程没有那么难的。。。太难的就不是一个人能编的。。。
作者: cyclxoath    时间: 2008-8-16 11:05
标题: 哈哈
大家说我说的有道理吧。呵呵
作者: lijunfeng    时间: 2008-8-18 15:37
标题: 提供各种集成电路 电子元器件 IC
本公司提供各种电子元器件 集成电路 光纤收发器温湿度传感器  压力传感器  存储器放大器等等,  如果各位朋友有需求的话可以个和我联系 电话029-85210902  传真 029-85396318   QQ  421912784   MSN kim19830226@hotmail.com   欢迎各位惠顾谢谢
作者: maomy    时间: 2008-8-20 12:05
[s:31] 哈哈
作者: 76180289    时间: 2008-8-21 09:17
我要加入~!~!~!
作者: 76180289    时间: 2008-8-21 09:17
上面还有广告~!~
作者: 76180289    时间: 2008-8-21 09:17
嘿嘿~!~!~!谢谢~!~!
作者: lipengtao_1985    时间: 2008-8-21 10:21
标题: 出售适用于我校的路由器
型号fs05   价格40   联系电话13991309534




欢迎光临 工大在线 (http://ruolanmy.hk1.ifreeurl.com/) Powered by Discuz! X2.5