;I post optimized version of comctrls.asm
;The original you can find in MASM32\EXAMPLE1.
;I send it before discussion of programming teqs involved begins.
;So you can have opotunity to compare it to the origginal and figure out for
;yourself what and why has been changed.
;I have a big problem commenting my own code, it takes days and hours for me 
;to comment complitly what was written in seconds and minutes.
;So it here is expirienced asm programmers who can compare two sources and
;comment what optimizations was done in good English, it would be very appreciated.
;At least part of it. The rest I'll try to do with my limmited abilities.
;The programs for optimization are choosen not because they are bad written.
;And not because I want to show how ,for example, you may quicker create toolbars.
;It's not about Win32 programming, it's about asm32 programming.
;Tecniques used here may be used for very different tasks in Win32 asm.
;As to Win32 asm programming specific topics here are lots of great teachers without
;me. But level of average asm. knowedge alarming. That's why I dicided to spend a little
;time to discuss some very basics of asm programming.
;About material choosen for it I must clearufy:
;1. 1st type is std procs they are by nature good field to discuss coding and
;you'll have as advantage optimized std libs which is very important part of any language.
;2. 2nd type demo programs.
;It's good to use them for 3 reasons.
;- They are deliberatly written the way can be easily understood. So it doesn't trap you for
;much time to figure out what the programm is doing and you can concentrate on optimizations.
;- They are specialy not optimized, 'cause their perpose is not to create optimal programm but
;give you clear first time impression of how some task can be solved. So they always have
;a big room for optimization, and this is not because stupidity of the author but merely because
;of their type - they are supposed to be written that way for clearity.
;In opposite - stdlibs must be optimized as much as possible.
;So you have two kinds of matirial
;- Most optimized by nature (stdlibs)
;- And LEAST optimized by nature (demo programs)
;Here is the code: 




.586
.model flat,stdcall
option casemap:none
include C:\masm32\include\windows.inc
include C:\masm32\include\user32.inc
include C:\masm32\include\kernel32.inc
include C:\masm32\include\comctl32.inc
includelib kernel32.lib
includelib user32.lib
includelib comctl32.lib
;##############################
;Local macros
szText MACRO Name, Text:VARARG
 LOCAL lbl
  jmp lbl
    Name db Text,0
  lbl:
ENDM
m2m MACRO M1, M2
 push M2
 pop   M1
ENDM

return MACRO arg
 mov eax,arg
 ret
ENDM
;================
;Local prototypes
;================

WinMain PROTO
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY     PROTO :DWORD,:DWORD
Paint_Proc PROTO :DWORD,:DWORD

.data
TheText db "Please Confirm Exit",0
szDisplayName db "Comctl32 Demo",0
hInstance	           equ 400000h
ClassName        db 1,0

tbSelect db "You have selected",0
TheMsg db "Assembler,Pure and Simple",0

tb50 db "New File",0
tb51 db "Open File",0
tb52 db "Save File",0
tb53 db "Cut",0
tb54 db "Copy",0
tb55 db "Paste",0
tb56 db "Undo",0
tb57 db "Search",0
tb58 db "Replace",0
tb59 db "Print",0

ALIGN 4
msgtbl dd offset tb50
            dd offset tb51
            dd offset tb52
            dd offset tb53
            dd offset tb54
            dd offset tb55
            dd offset tb56
            dd offset tb57
            dd offset tb58
            dd offset tb59


wc WNDCLASSEX 
tbb  TBBUTTON <0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0>

; mov tbb.iBitmap,0
; mov tbb.idCommand,0
; mov tbb.fsState, TBSTATE_ENABLED
; mov tbb.fsStyle, TBSTYLE_SEP
; mov tbb.dwData,0
; mov tbb.iString,0

.data?

hWnd 	           dd ?
hStatus	           dd ?
hToolBar
Posted on 2001-04-02 15:15:00 by The Svin