Hi All,
I was working on a new addin when it struck me that rather than hand coding the opening and closing code plus comments for macros I could do a quick re-write of the AddProc addin to do this for me. As it turned out it wasn't as quick as I anticipated - it took me most of the day - nevertheless here it is.

To get the 2 addins to add menu listings in Winasm without unnecessarily deleting/adding separators required updating the code for adding a menu item in AddProc. Going through the AddProc code again today gave me a good excuse to tweak a few things too. Hence the zip contains AddMacro version 1.0.0.1 and AddProc version 1.0.0.3.

Any comments would be much appreciated.
Thanks,
andrew_k
Posted on 2003-09-18 05:53:47 by andrew_k
Hi,

I really like this. Two comments:

1)This is the description of your AddIn:

The Add Macro addin enables users to quickly add code for a new procedure to their source files.

2)If user selects "Top Of File" set your selection to the first char of the CodeHi control after the new macro is inserted and then

Send this message

Invoke SendMessage,hCodeHi,CHM_VCENTER,0,0 (it scrolls to the top - not to the center - in contrary to what the name says!)

Regards,

akyprian
Posted on 2003-09-18 13:18:32 by akyprian
Hi Akyprian,
I thought I had gone through and removed every reference to the word "Procedure" but somehow managed to miss that one, my apologies. I also noticed this morning that moving the arguments up and down when they aren't of type 'REQ' and 'VARARG' results in their types disappearing. This is now fixed.

Using Invoke SendMessage,hCodeHi,CHM_VCENTER,0,0 unfortunately had no effect. The result is scrolling as before, that is the window scrolls almost to the top(?). Any ideas?

New upload at top.
Posted on 2003-09-18 14:52:53 by andrew_k
Hi,

Do you set the selection to the first char of the CodeHi control after the new macro is inserted ?

Regards,

akyprian
Posted on 2003-09-19 00:12:48 by akyprian
Hi Akyprian,
Here's the code I used:

Invoke lstrlen, offset szMacroCode
Invoke SendMessage, hCWnd, EM_SETSEL, eax, eax
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0

But the end result is no different than before(?). I also tried the following just to be sure:

Invoke lstrlen, offset szMacroCode
mov ecx, eax
dec eax
Invoke SendMessage, hCWnd, EM_SETSEL, eax, ecx
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0
Posted on 2003-09-19 16:06:19 by andrew_k

Hi Akyprian,
Here's the code I used:

Invoke lstrlen, offset szMacroCode
Invoke SendMessage, hCWnd, EM_SETSEL, eax, eax
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0



Did you see what I had in bold in my previous post ?

You have to use this:

Invoke lstrlen, offset szMacroCode
Invoke SendMessage, hCWnd, EM_SETSEL, eax, eax <--Why EAX, EAX here?Invoke SendMessage, hCWnd, EM_REPLACESEL, TRUE, offset szMacroCode
Invoke SendMessage, hCWnd, EM_SETSEL, ?, ? <---Look here: It means go select again since the selection has changed.
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0

Regards,

akyprian
Posted on 2003-09-19 17:54:48 by akyprian
Hi Akyprian,
The code I posted didn't include the code used to insert the text generated by AddMacro. It was simply the code used to scroll the window to the top. The call to lstrlen was to get the length of the inserted text string:

Invoke lstrlen, offset szMacroCode

The return from this is in eax and will include in the count newline characters so that:

Invoke SendMessage, hCWnd, EM_SETSEL, eax, eax

actually selects a position after the inserted code. Finally comes:
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0

This unfortunately didn't give us the result we wanted. However I got a bit of spare time this morning and had a play around. I discovered all we needed to do was this:

Invoke SendMessage, hCWnd, EM_SETSEL, 0, 0
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0

Now the addin scrolls to the top of the window as we wanted. I was unable to edit my original post so here is the new version:
Posted on 2003-09-19 19:45:38 by andrew_k

I discovered all we needed to do was this:

Invoke SendMessage, hCWnd, EM_SETSEL, 0, 0
Invoke SendMessage, hCWnd, CHM_VCENTER, 0, 0


This is what I was trying to explain. You set the selection to what you want and CHM_VCENTER just scrolls so that the selection is at the first visible line.

Regards,

akyprian
Posted on 2003-09-20 01:32:22 by akyprian