News:

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

How to chose an API call?

Started by Roger, September 21, 2008, 11:47:31 PM

Previous topic - Next topic

jj2007

Quote from: Roger on October 03, 2008, 01:38:08 PM
My WM_SIZE handler may not paint the edit box  but it does a lot more than sizing it.
It sizes the edit box. All the other actions are being done by other messages that you don't (and don't need to) capture. Please activate the WM_SIZE handler, and nothing else. You need two small changes:

TestStg1   db " 1 Test string 1 ", 0Dh, 0Ah, "Next Line", 0

                mov hwndEdit,eax
      invoke SetFocus, eax
      invoke SendMessage, hwndEdit, WM_SETTEXT, 0, addr TestStg1
      invoke SendMessage, hwndEdit, EM_SETSEL, 0ffffh, 0ffffh


Roger

Quote from: jj2007 on October 03, 2008, 02:29:07 PM
[ All the other actions are being done by other messages that you don't (and don't need to) capture. Please activate the WM_SIZE handler, and nothing else.
But I do need to do them.

TestStg! is only a test. The project will have several strings which will be selected at runtime so they cannot be in the WM_CREATE handler but need to be in the WM_PAINT handler - unless someone knows a better place for them.

I had this in the WM_PAINT handler

                invoke SetBkColor,hdc,0ffFFh
                invoke TextOut,hdc,300,0,ADDR TestStg1,SIZEOF TestStg1


I need WM_CHAR to capture keystrokes for parsing and sending elsewhere apart from the display.


Quote
TestStg1   db " 1 Test string 1 ", 0Dh, 0Ah, "Next Line", 0
Isn't Windows fussy! and it still doesn't work for DrawText


Regards Roger

jj2007

Quote from: Roger on October 03, 2008, 04:42:35 PM
Isn't Windows fussy! and it still doesn't work for DrawText

Indeed! DrawText will break lines but does not accept manual CrLfs. TextOut is the only solution afaik. I have worked a lot with these functions but under Win 3.1, so I don't dare to give advice...

PBrennick

It is easier (and more reliable) to process keystrokes directly in the message loop using the WM_KEYUP and/or WM_KEYDOWN messages as follows:


    .if msg.message == WM_KEYUP
      invoke  GetAsyncKeyState, VK_CONTROL
      rol     eax, 16
      cmp     ax, 1111111111111111b
      jne     ProcessMessage
      .if msg.wParam == 46h             ; Ctrl + F
        invoke  SendMessage, hWnd, WM_COMMAND, IDM_FIND, 0
        jmp     StartLoop
    .elseif ...


For me, Control keys process betterin the WM_KEYUP area and Funtion keys process better in the WM_KEYDOWN area. Some will say it does not matter, just do what works for you.

Do this instead of using WM_CHAR. WM_CHAR has problems with certain key combinations and will not handle a CRLF pair at all. It is beyond the scope of the message's capabilities.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website