News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

detect WM_COMMAND in Child Window

Started by RHL, April 20, 2012, 02:35:37 AM

Previous topic - Next topic

RHL

hey nice code's, thanks u for share it

jj2007

Quote from: MichaelW on April 21, 2012, 05:05:00 AM
I didn't type all than in, I copied from windows.inc, edited out a few non-WM lines, and used a 12-line FreeBASIC program to convert it to an asm source.

How did you squeeze that in 12 lines? I need at least 15...

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   Open "O", #1, "Wm_X.txt"
   Recall "\Masm32\include\Windows.inc", L$()
   For_ n=0 To eax-1
      Let esi=L$(n)
      push Instr_(esi, "WM_")
      dec Instr_(esi, "equ", 5)
      pop ecx
      jecxz @F
      Let esi=Trim$(Mid$(esi, ecx, edx-ecx))
      Print #1, Tb$, "CASE ", esi, CrLf$, Tb$, Tb$, Chr$("printf", 40, 34), esi, Chr$("\n", 34, 41), CrLf$
@@:   Next
   Exit
end start


MichaelW

It was actually 11 lines without the sleep statement.

dim as string ln
open "wm.txt" for input as 1
open "wm.asm" for output as 2
print #2, space(4);"SWITCH wm"
do while not eof(1)
    line input #1,ln
    ln = left(ln,instr(ln, " "))
    print #2, space(8);"CASE ";ln
    print #2, space(12);"printf(";chr(34);ln;"\n";chr(34);")"
loop
print #2, space(4);"ENDSW"
sleep
eschew obfuscation

jj2007

Nice :U
I can do it in 12 lines, but you would still win because I don't print the Switch and Endsw :(

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   Open "O", #1, "Wm_X.txt"
   Recall "\Masm32\include\Windows.inc", L$()
   For_ n=0 To eax-1
      mov ecx, Instr_(L$(n), "WM_")
      jecxz @F
      Let esi=Trim$(Mid$(L$(n), ecx, Instr_(L$(n), "equ", 5)-ecx))
      Print #1, Tb$, "CASE ", esi, CrLf$, Tb$, Tb$, Chr$("printf", 40, 34), esi, Chr$("\n", 34, 41), CrLf$
@@:   Next
   Exit
end start

MichaelW

Actually, by separating the statements with a colon I can do it in one line :bg
eschew obfuscation

jj2007

I noticed that :bg
However, mine checks the whole windows.inc for matches; but still, I can never win because of the include, Init, Exit, end start overhead :(
I haven't looked at FreeBasic for a while, it looks good, syntax-wise.