| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1272 人关注过本帖
标题:运行了一个例子 截图~~~ 但是没有效果
只看楼主 加入收藏
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
结帖率:96.55%
收藏
已结贴  问题点数:0 回复次数:16 
运行了一个例子 截图~~~ 但是没有效果
图片 不知道为什么上不来

[ 本帖最后由 诸葛修勤 于 2011-8-13 17:31 编辑 ]
搜索更多相关主题的帖子: 图片 
2011-08-13 17:28
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:0 
程序代码:
;MASMPlus 代码模板 - 普通的 Windows 程序代码
.386
.model flat, stdcall
option casemap:none
include windows.inc
include gdi32.inc
includelib gdi32.lib
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
ICO_MAIN equ 1000
.data?
hInstance    dd ?
hWin1    dd ?
hWin2    dd ?
.const
szText    db 'yu xun feng yi ding ke yi zuo dao geng hao', 0
szClassName1    db 'the first name', 0
szClassName2    db 'the second name', 0
szClassCaption    db 'title name...', 0
.code
ProcTimer    proc _hWnd, _uMsg, _wParam, _lParam
    local @hDc1, @hDc2
    local @stRect:RECT

    invoke GetDC, hWin1
    mov @hDc1, eax
    invoke GetDC, hWin2
    mov @hDc2, eax
    invoke GetClientRect, hWin1, addr @stRect
    invoke BitBlt, @hDc2, 0, 0, @stRect.right, @stRect.bottom,\
        @hDc1, 0, 0, SRCCOPY
    invoke ReleaseDC, hWin1, @hDc1
    invoke ReleaseDC, hWin2, @hDc2
    ret
ProcTimer    endp
WndProc_ proc uses esi edi edx, hWnd, uMsg, wParam, lParam
    local @stPs:PAINTSTRUCT
    local @stRect:RECT
    local @hDc

    mov eax, uMsg
    mov ecx, hWnd

    .if eax == WM_CLOSE
        invoke PostQuitMessage, NULL
        invoke DestroyWindow, hWnd

    .elseif eax == WM_PAINT && ecx == hWin1
        invoke BeginPaint, hWnd, addr @stPs
        mov @hDc, eax
        invoke GetClientRect, hWnd, addr @stRect
        invoke DrawText, @hDc, addr szText, -1, \
            addr @stRect,\
            DT_SINGLELINE or DT_CENTER or DT_VCENTER
        invoke EndPaint, hWnd, addr @stPs
   
    .else
        invoke DefWindowProc, hWnd, uMsg, wParam, lParam
        ret
    .endif
    xor eax, eax

    ret
WndProc_ endp
WinMain_    proc
    local @stWndClass:WNDCLASSEX
    local @stMsg:MSG
    local @hTimer

    invoke GetModuleHandle, NULL
    mov hInstance, eax
    invoke RtlZeroMemory, addr @stWndClass, sizeof WNDCLASSEX

    invoke LoadIcon, hInstance, ICO_MAIN
    mov @stWndClass.hIcon, eax
    invoke LoadCursor, hInstance, IDC_ARROW
    mov @stWndClass.hCursor, eax
    mov @stWndClass.cbSize, sizeof WNDCLASSEX
    mov @stWndClass.style, CS_VREDRAW or CS_HREDRAW
    push hInstance
    pop @stWndClass.hInstance
    mov @stWndClass.hbrBackground, COLOR_WINDOW+1
    mov @stWndClass.lpfnWndProc, offset WndProc_
    mov @stWndClass.lpszClassName, offset szClassName1
    invoke RegisterClassEx, addr @stWndClass

    invoke CreateWindowEx,WS_EX_CLIENTEDGE, offset szClassName1,\
        offset szClassCaption, WS_OVERLAPPEDWINDOW,\
        100, 100, 300, 300,\
        NULL, NULL, hInstance, NULL
    mov hWin1, eax
    invoke ShowWindow, hWin1, SW_SHOWNORMAL
    invoke UpdateWindow, hWin1

    mov @stWndClass.lpszClassName, offset szClassName2
    invoke RegisterClassEx, addr @stWndClass
    invoke CreateWindowEx, WS_EX_CLIENTEDGE, offset szClassName2,\
        offset szClassCaption, WS_OVERLAPPEDWINDOW,\
        450, 100, 300, 300,\
        NULL, NULL, hInstance, NULL
    mov hWin2, eax
    invoke ShowWindow, hWin2, SW_SHOWNORMAL
    invoke UpdateWindow, hWin1

    invoke SetTimer, NULL, NULL, 100, addr ProcTimer
    mov @hTimer, eax

    .while TRUE
        invoke GetMessage, addr @stMsg, 0, 0, 0
        .break .if eax == 0
        invoke TranslateMessage, addr @stMsg
        invoke DispatchMessage, addr @stMsg
    .endw

    invoke KillTimer, NULL, @hTimer

   
    ret
WinMain_    endp
Begin:
    invoke WinMain_
    invoke ExitProcess, NULL

    end Begin
2011-08-13 17:31
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:0 
是将一个窗口的 拷贝 到另外的一个窗口中  

但是 和 书上 演示的一点都不像   

谁有这个例子   可以运行下
2011-08-13 17:33
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:0 
程序代码:
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Sample code for < Win32ASM Programming 3rd Edition>
; by 罗云彬, http://www.
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; DcCopy.asm
; 测试设备环境的代码,将一个窗口 DC 对应的象素拷贝到另一个窗口中
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 使用 nmake 或下列命令进行编译和链接:
; ml /c /coff DcCopy.asm
; Link /subsystem:windows DcCopy.obj
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .386
        .model flat,stdcall
        option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include        windows.inc
include        gdi32.inc
includelib    gdi32.lib
include        user32.inc
includelib    user32.lib
include        kernel32.inc
includelib    kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ID_TIMER    equ    1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .data?
hInstance    dd        ?
hWin1        dd        ?
hWin2        dd        ?
        .const
szClass1    db    'SourceWindow',0
szClass2    db    'DestWindow',0
szCaption1    db    '请尝试用别的窗口覆盖本窗口!',0
szCaption2    db    '本窗口图像拷贝自另一窗口',0
szText        db    'Win32 Assembly, Simple and powerful !',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 定时器过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcTimer    proc    _hWnd,uMsg,_idEvent,_dwTime
        local    @hDc1,@hDc2
        local    @stRect:RECT
        invoke    GetDC,hWin1
        mov    @hDc1,eax
        invoke    GetDC,hWin2
        mov    @hDc2,eax
        invoke    GetClientRect,hWin1,addr @stRect
        invoke    BitBlt,@hDc2,0,0,@stRect.right,@stRect.bottom,\
            @hDc1,0,0,SRCCOPY
        invoke    ReleaseDC,hWin1,@hDc1
        invoke    ReleaseDC,hWin2,@hDc2
        ret
_ProcTimer    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcWinMain    proc    uses ebx edi esi,hWnd,uMsg,wParam,lParam
        local    @stPs:PAINTSTRUCT
        local    @stRect:RECT
        local    @hDc
        mov    eax,uMsg
        mov    ecx,hWnd
;********************************************************************
        .if    eax ==    WM_PAINT && ecx == hWin1
            invoke    BeginPaint,hWnd,addr @stPs
            mov    @hDc,eax
            invoke    GetClientRect,hWnd,addr @stRect
            invoke    DrawText,@hDc,addr szText,-1,\
                addr @stRect,\
                DT_SINGLELINE or DT_CENTER or DT_VCENTER
            invoke    EndPaint,hWnd,addr @stPs
;********************************************************************
        .elseif    eax ==    WM_CLOSE
            invoke    PostQuitMessage,NULL
            invoke    DestroyWindow,hWin1
            invoke    DestroyWindow,hWin2
;********************************************************************
        .else
            invoke    DefWindowProc,hWnd,uMsg,wParam,lParam
            ret
        .endif
;********************************************************************
        xor    eax,eax
        ret
_ProcWinMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain    proc
        local    @stWndClass:WNDCLASSEX
        local    @stMsg:MSG
        local    @hTimer
        invoke    GetModuleHandle,NULL
        mov    hInstance,eax
        invoke    RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
;********************************************************************
        invoke    LoadCursor,0,IDC_ARROW
        mov    @stWndClass.hCursor,eax
        push    hInstance
        pop    @stWndClass.hInstance
        mov    @stWndClass.cbSize,sizeof WNDCLASSEX
        mov    @stWndClass.style,CS_HREDRAW or CS_VREDRAW
        mov    @stWndClass.lpfnWndProc,offset _ProcWinMain
        mov    @stWndClass.hbrBackground,COLOR_WINDOW + 1
        mov    @stWndClass.lpszClassName,offset szClass1
        invoke    RegisterClassEx,addr @stWndClass
        invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClass1,offset szCaption1,\
            WS_OVERLAPPEDWINDOW,\
            450,100,300,300,\
            NULL,NULL,hInstance,NULL
        mov    hWin1,eax
        invoke    ShowWindow,hWin1,SW_SHOWNORMAL
        invoke    UpdateWindow,hWin1
;********************************************************************
        mov    @stWndClass.lpszClassName,offset szClass2
        invoke    RegisterClassEx,addr @stWndClass
        invoke    CreateWindowEx,WS_EX_CLIENTEDGE,offset szClass2,offset szCaption2,\
            WS_OVERLAPPEDWINDOW,\
            100,100,300,300,\
            NULL,NULL,hInstance,NULL
        mov    hWin2,eax
        invoke    ShowWindow,hWin2,SW_SHOWNORMAL
        invoke    UpdateWindow,hWin2
;********************************************************************
; 设置定时器
;********************************************************************
        invoke    SetTimer,NULL,NULL,100,addr _ProcTimer
        mov    @hTimer,eax
;********************************************************************
; 消息循环
;********************************************************************
        .while    TRUE
            invoke    GetMessage,addr @stMsg,NULL,0,0
            .break    .if eax    == 0
            invoke    TranslateMessage,addr @stMsg
            invoke    DispatchMessage,addr @stMsg
        .endw
;********************************************************************
; 清除定时器
;********************************************************************
        invoke    KillTimer,NULL,@hTimer
        ret
_WinMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
        call    _WinMain
        invoke    ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        end    start
2011-08-13 17:34
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:0 
在我这里没法上传附件   有人 知道 什么原因吗?

以前 xp的时候可以
2011-08-13 17:36
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:10 
跟浏览器有关系罢。。
2011-08-13 22:54
iamsky1981
Rank: 2
等 级:论坛游民
帖 子:20
专家分:76
注 册:2009-10-23
收藏
得分:0 
回复 5楼 诸葛修勤
xp可以,那你现在是在么系统下不行呢?
2011-08-14 07:08
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:0 
win7    没道理
2011-08-14 12:11
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:0 
看过 那个例子没    课本上的插图
2011-08-14 12:12
iamsky1981
Rank: 2
等 级:论坛游民
帖 子:20
专家分:76
注 册:2009-10-23
收藏
得分:10 
到朋友的WIN7上试了一下,确实没有在XP下的效果
在我看来原因在于WIN7有自己的一套SDK,如果在WIN7下运行程序,那就需要用WIN7对应的SDK吧,你现在用的SDK是适用于2K、XP的,也许原因在于此吧,当然不是说都无效,但是在图形绘制这方面应该是不一样了,呵呵,实在找不出其他原因了。
2011-08-14 13:19
快速回复:运行了一个例子 截图~~~ 但是没有效果
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021821 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved