首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > 汇编语言 >

win32汇编GDI有关问题

2012-03-09 
win32汇编GDI问题我想知道 为什么 下面的代码只能出黑白格子图而不能出彩色的。请帮我分析,我不只想看到

win32汇编GDI问题
我想知道 "为什么 "下面的代码只能出黑白格子图而不能出彩色的。请帮我分析,我不只想看到被说该写些什么,谢谢。
代码改动较多,所以下面代码有很多没用的变量,请别介意。

.386
.model   flat,   stdcall
option   casemap:none
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
;Include
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
includewindows.inc
includeuser32.inc
includekernel32.inc
includecomctl32.inc
includecomdlg32.inc
includeshell32.inc
includegdi32.inc

includelibuser32.lib
includelibkernel32.lib
includelibcomctl32.lib
includelibcomdlg32.lib
includelibshell32.lib
includelibgdi32.lib
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
;Equ   data
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >


;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
;data   segment
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
.data
hInstancedd?
hWinMaindd?


hBmpNCBackdd?;unClient   Background   bitmap
hDCNCBackdd?

hBmpBackdd?;clientBackground   bitmap
hDCBackdd?

szClassNamedb 'ShapeWindow ',0

;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
;code   segment
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

.code


;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
;main   program
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
_WinMainproc
local@stWndClass:WNDCLASSEX
local@stMsg:MSG

invokeGetModuleHandle,NULL
movhInstance,eax

invokeRtlZeroMemory,addr   @stWndClass,sizeof   WNDCLASSEX
invokeLoadCursor,0,IDC_ARROW;光标以后需要修改||||||||||||||||||||||||||||||||||||
mov@stWndClass.hCursor,eax


moveax,hInstance
mov@stWndClass.hInstance,eax
mov@stWndClass.cbSize,sizeof   WNDCLASSEX
mov@stWndClass.style,CS_HREDRAW   or   CS_VREDRAW   or   CS_DBLCLKS
mov@stWndClass.lpfnWndProc,offset   _WndMainProc
mov@stWndClass.cbClsExtra,0
mov@stWndClass.cbWndExtra,0
mov@stWndClass.hIcon,0;小图标以后需要修改||||||||||||||||||||||||||||||||||
mov@stWndClass.hbrBackground,COLOR_WINDOW   +   1
mov@stWndClass.lpszClassName,offset   szClassName
mov@stWndClass.lpszMenuName,0;以后追加菜单||||||||||||||||||||||||||||||||||||||||
invokeRegisterClassEx,addr   @stWndClass
;***************************************************
invokeCreateWindowEx,WS_EX_CLIENTEDGE,offset   szClassName,\
NULL,WS_OVERLAPPEDWINDOW,0,0,200,200,NULL,NULL,hInstance,NULL

invokeShowWindow,hWinMain,SW_SHOWNORMAL
invokeUpdateWindow,hWinMain
;***************   消息循环   *******************************************
.whileTRUE
invokeGetMessage,addr   @stMsg,NULL,0,0
.break.if   eax==   0
invokeTranslateMessage,addr   @stMsg
invokeDispatchMessage,addr   @stMsg
.endw

ret
_WinMainendp
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
_WndMainProcprocuses   ebx   edi   esi,   \
hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

local@stPs:PAINTSTRUCT
local@hDC:DWORD
local@hBrush:DWORD

moveax,uMsg
.ifeax   ==WM_CREATE
moveax,hWnd
movhWinMain,eax
call_Init
;********************************************************************
.elseifeax   ==   WM_PAINT
invokeBeginPaint,hWnd,addr   @stPs
mov@hDC,eax

invokeCreateHatchBrush,HS_DIAGCROSS,0B178AB66h
mov@hBrush,eax
invokeSelectObject,@hDC,@hBrush
invokeDeleteObject,eax
invokeFillRect,@hDC,addr   @stPs.rcPaint,@hBrush

invokeEndPaint,hWnd,addr   @stPs
;********************************************************************
.elseifeax   ==WM_CLOSE
call_Quit
;********************************************************************
.else
invokeDefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
;********************************************************************
xoreax,eax
ret

_WndMainProcendp

;********************************************************************
_Initproc
local@hDC:DWORD
local@stRect:RECT
local@hBrush:DWORD
local@hBitmapBack:DWORD

invokeInvalidateRect,hWinMain,NULL,-1

ret
_Initendp
;********************************************************************
_Quitproc
local@stWindow:RECT

;invokeDestroyMenu,hMenu
invokeDeleteDC,hDCBack
;invokeDeleteObject,hBmpBack
invokeDestroyWindow,hWinMain
invokePostQuitMessage,NULL

ret

_Quitendp
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
;program   begin
;> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >


start:
call_WinMain
invokeExitProcess,NULL

;***************************************************
endstart

[解决办法]
晕, csdn 的这个删除制表符的做法实在差劲. 可以的话, 楼主将制表符替换为空格再贴上来看看?
[解决办法]
invoke CreateHatchBrush, HS_DIAGCROSS, 0B178AB66h ;*
对于颜色值, 最高字节必须为 00, 即 00bbggrrh, 其中 bb/gg/rr 分别是 Blue/Green/Red 三元色的亮度分值

热点排行