News:

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

[solved]help on notepad like program

Started by gxm, May 12, 2008, 07:32:17 AM

Previous topic - Next topic

gxm

1>develop-enviroment:
   win2003 server;masm32v9;Pspad Editor;
2>question:
    i>After i open the Find or Replace dialog,the dialog will hang up.[not hang out^_^]
    ii>i cannot use Key-Accelerators.[solved]
3> I modified this post by zipping the code.And the newest code here:
     
     


[attachment deleted by admin]

jj2007

Assembles over here, and I can see the menus, but they have no effect, so I cannot test the replace dialog.
Suggestion: use a debugging macro like sns ("show me a number and a string"), or go for Olly

.data?
snsFlag   dd ?
snsBuf   dd 5 dup (?)

sns MACRO macnum:REQ, macstr:=<Debug>
   .if snsFlag!=IDCANCEL
      pushad
      invoke dwtoa, macnum, addr snsBuf
      invoke MessageBox, 0, addr snsBuf, reparg(macstr), MB_OKCANCEL
      mov snsFlag, eax
      popad
   .endif
ENDM


gxm

I used Olly,and it turns out that
I> the LoadAccelerators and TranslateAccelerator works well,But i cannot get it work well.
    the Key-Accelerator doese not work.

II>the FindText and ReplaceText function return right,but it does not work well too.

please remove the [color=red] [/color]then the Find Dialog should take effects.

However,the Replace Dialog cannot take effect at the time.But could u take a look on the Find Dialog.
And after add this two lines to the _Replace proc.
 
mov stFR.lpstrFindWhat,offset szFindWhat
mov stFR.wFindWhatLen,80

the Replace Dialog will turn out,so as the problem
;=====
Anyway,thank you.

Tedd

A few clues (I'm afraid it doesn't solve all your problems, but it's a start :P)

ICO_MAIN = 100
IDA_MAIN = 100
IDM_MAIN = 100

each resource should have its own identifier!
if you say "load resource 100" -- which one gets loaded??

you need to actually dispatch the message, even if it's an accelerator
.while TRUE
    invoke GetMessage,addr @stMsg,hWinMain,0,0
    .break .if eax==0
    ;invoke IsDialogMessage,hFindText,addr @stMsg
    ;.if eax==0
        invoke TranslateAccelerator,hWinMain,hAccTable,addr @stMsg
        .if eax==0
            invoke TranslateMessage,addr @stMsg
        .endif
        invoke DispatchMessage,addr @stMsg
    ;.endif
.endw


try adding the following into _WndProc to solve your focus problems
.elseif uMsg==WM_SETFOCUS
    invoke SetFocus,hEdit



P.S. zip your code up and attach it, rather than posting it (make it easier for others to help you) :wink
No snowflake in an avalanche feels responsible.

gxm

1>Finally I have solved the Key-Accelerator problem,actually I recalled that i had made the same mistake the other day.-_-
    according to MSDN:[TranslateAccelerator]
   To differentiate the message that this function sends from messages sent by menus or controls, the high-order word of the   wParam   parameter of the WM_COMMAND or WM_SYSCOMMAND message contains the value 1.
   So in the _WndProc I modify the code as follows
 
  .if uMsg==WM_COMMAND
  mov eax,wParam
  and eax,0000FFFFh
 

2>Then,we can see that
    Upstairs is wrong.
    i>the Accelerator and Menu and Icon Identifier can be the same,just becuase they aren't the same type resource.
    ii>we donot need to Dispatch the Message,because the TranslateAccelerator will not return until  Processed[send the WM_COMMAND to hWinMain] .

3>Anyway Thanks for your advice,and i will zip the code next time. :green
   

gxm

After testing for 3 days,I finally failed to Figure out why the Find Dialog hang-up.
I have checked the code[_Find] and the code is even the same as in my another program.
But this one failed and the other one works well.
;====
Hope somebody can help me.Thx.
and newest code here

[attachment deleted by admin]

jj2007

I tried my luck but no clue, sorry. What strikes me, though, is the way the main window reacts:
- If you do not do anything with the find dialog, the main window reacts fine and closes with one click on the X.
- If you try typing something into the find dialog, the main window reacts only after a few clicks, as if messages got eaten.
Good luck  :thumbu

gxm

To jj2007 thx.
But in my computer,the find-dialog box cannot be close by click on the X.
==
And i find one interesting thing that
If i add one MessageBox in the _FindProc as follows:

_Find proc
 
  invoke RtlZeroMemory,offset stFR,sizeof FINDREPLACE
 
  mov stFR.lStructSize,sizeof FINDREPLACE
  push hWinMain
  pop stFR.hwndOwner
  mov stFR.Flags,FR_DOWN
  mov stFR.lpstrFindWhat,offset szBuffer
  mov stFR.wFindWhatLen,sizeof szBuffer
  invoke FindText,offset stFR
  mov hFindText,eax
  invoke MessageBox,0,0,0,0
  ret
_Find endp


the Find Dialog would work well before i close the MessageBox. :dazzled:

jj2007

Quote from: gxm on May 16, 2008, 02:09:09 AM
To jj2007 thx.
But in my computer,the find-dialog box cannot be close by click on the X.

I meant the main dialog, which remains operational (find is modeless), but seems to swallow some messages meant for the find dialog.

neo85

Quote from: gxm on May 15, 2008, 02:10:46 PM
After testing for 3 days,I finally failed to Figure out why the Find Dialog hang-up.
I have checked the code[_Find] and the code is even the same as in my another program.
But this one failed and the other one works well.
;====
Hope somebody can help me.Thx.
and newest code here

Hi gxm,
I'm studying your source code and try to debug it, and I'm glad to tell you that now I know what's your problem  :U

The FindText API function will create the modeless "find dialog", this means that the function will return immediately to your source code, and remember that
messages to modeless dialog come through your program's message queue, so don't pass the main window's handle to function GetMessage, instead pass the NULL value so that your messages pump will processl messages of any window that belongs to the calling thread.

Quoteinvoke GetMessage,addr @stMsg,hWinMain,0,0

should be replaced by

Quoteinvoke GetMessage,addr @stMsg,NULL,0,0

Regards,

PS: sorry for my poor English skill

gxm

To jj2007:sorry,i misread your reply
;====
To Neo85:really thx.i have made a silly mistake,er...I should not...

jj2007

My contribution ("modeless") was very small but nonetheless this was true teamwork :U
Thanks, I learnt again something very useful.

gxm