How can I successfully enhance the QEditor plugin skeleton?

Started by simonst, August 28, 2008, 02:08:49 PM

Previous topic - Next topic

simonst

Hello,
I need some help, because I am not an experienced dll-creator ;)
How can I use successfully the basic function emulation macros for enhancing the code in the documented interface for
Quick Editor plugins?
Here is a short screenshot and a brief error description:

;;;;;;

QePlugIn proc hInst:DWORD,hMain:DWORD,hEd:DWORD,hTool:DWORD,hStat:DWORD

;     hInst    =   instance handle
;     hMain    =   main window handle
;     hEd      =   rich edit control handle
;     hTool    =   toolbar handle
;     hStat    =   status bar handle

    LOCAL hMem:DWORD
    LOCAL Cr:CHARRANGE

    szText plugin,"Quick Editor Plugin"

    invoke SendMessage,hEd,EM_EXGETSEL,0,ADDR Cr    ; get selection

  ; -------------------------------------------------
  ; compare CHARRANGE to see if any text is selected
  ; -------------------------------------------------
    mov eax, Cr.cpMin
    cmp Cr.cpMax, eax
    jne @F

    szText noSelection,"Sorry, no text is selected"
    invoke MessageBox,hEd,ADDR noSelection,ADDR plugin,MB_OK
    jmp Bye

  @@:
  ; -------------------------
  ; get selected text length
  ; -------------------------
    mov eax, Cr.cpMin
    mov edx, Cr.cpMax
    sub edx, eax

  ; -----------------------
  ; allocate string memory
  ; -----------------------
    stralloc edx
    mov hMem, eax

    invoke SendMessage,hEd,EM_GETSELTEXT,0,hMem

==> mov hMem, rev$(hMem)
==> This procduces the the error message: "ERROR A2006:  undefined symbol : szRev  rev$(1): Macro Called From ..."
 
                                         
invoke MessageBox,hEd,hMem,ADDR plugin,MB_OK


;;;;;;;


I have additionally included "macros.asm" and "masm32.lib". Did I made something wrong concerning the memory allocation?

Greetings, Stefan Simon

hutch--

Stefan,

Tell me a little more about what you want to do with the plugin. Its an old format QE plugin which works fine, it gets the handles for most of the windows used in QE which allows you to write code to perform tasks that QE does not do.

The code is to get selected text in the editor so you can work on it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

simonst

Thank You for Your quick reply.
I want to do simply some tests with the plugin. I am not experienced in creating DLL's , but I want to understand
QE's plugin interface and I hope that I can enhance it a few by using the basic function emulation macros, especially those
for strings.
I have studied the new useful plugin examples in version 10, written in the new scripting language. There, the
reversion of the selected text was already achieved with

"mov ptxt, rev$(ptxt)"    (ptxt is a LOCAL: DWORD in the QEinterface proc)

But it seems not so easy to convert this code into the old QE plugin format; masm throws an error message which reports
"szRev" as an undefined symbol. I remember, "szRev" is the real function call in the macro itself. I have checked the files that
I have included and I have checked the memory management. But I did not found the error yet.
I would be thankful for Your further help.
Kind Regards,
Stefan Simon

hutch--

Stefan,

Here is a small example of a text plugin. It gets the selected text, writes to allocated memory, modifies it then writes it back to QE. It then selects the changed text again.

You have to do a bit of work to get the text into a bufer but once that is done you can use the basic style string functions in the normal manner.

Note that this simple example allocates a buffer the size of the selection so you can make the text shorter but not longer. If you need to make the text longer later, the method of calculating the buffer size will need to be changed.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

simonst

Hello,
Thank You very much!!!
This zip-file is a big help for me. I also want to thank for your quick reply.
I have tested it, it works fine. Now I have understood the memory management.
Now I can use the technique in your zip-file as a template for further tests and expermiments with
the dll interface of QE. I am really impressed about QE and it's features.
Best regards,
Stefan Simon