News:

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

Works fine in most instances

Started by Magnum, November 13, 2010, 03:39:18 AM

Previous topic - Next topic

Magnum

This works when posting to boards and in Word.

It doesn't when inserting into Notepad.
I am curious as to why.



;clip.asm Use to "pre-fill the clipboard for later use
;
    include \masm32\include\masm32rt.inc

    .data
   
  hglb dd 0
  str1 db "Have a great day,",13, "                          Andy",13,13,"http://intouch.org/magazine/daily-devotional",0

;http://www.happynews.com/

    .code

start:

    ;------------------------------
    ; Place str1 on the clipboard.
    ;------------------------------

    invoke OpenClipboard,NULL
    .IF (eax)
      invoke EmptyClipboard
      invoke GlobalAlloc,GMEM_MOVEABLE,SIZEOF str1
      .IF (eax)
        mov hglb, eax
        invoke GlobalLock,hglb
          ;---------------------
          ; Pointer now in eax.
          ;---------------------
        invoke MemCopy,ADDR str1,eax,SIZEOF str1
        invoke GlobalUnlock,hglb
        invoke SetClipboardData,CF_TEXT,hglb
          ;--------------------------------------------
          ; System now owns object identified by hglb.
          ;--------------------------------------------
        .IF (eax == 0)
          print "SetClipboardData failed",13,10
        .ENDIF
      .ELSE
        print "GlobalAlloc failed",13,10
      .ENDIF
      invoke CloseClipboard
    .ELSE
      print "OpenClipboard failed",13,10
    .ENDIF

    exit
end start

Have a great day,
                         Andy

sinsi

I assume that it is supposed to be 4 lines and notepad makes it one?

13,10 is usual for ascii text -
13 is carriage return (CR), puts the cursor at the start of the line (x=0,y=y)
10 is line feed (LF), puts the cursor one line down (x=x,y=y+1)
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

QuoteI assume that it is supposed to be 4 lines and notepad makes it one?

and you only see the text in the last line (plus remnants, perhaps), as the previous text is overwritten   :P

sinsi

That is, of course, on a text screen. Notepad seems to ignore CR if there's no following LF so the message is concatenated.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

ah yes - that's right
it will display the ole box char where the CR is   :P

Magnum

Quote from: sinsi on November 13, 2010, 03:49:36 AM
I assume that it is supposed to be 4 lines and notepad makes it one?

13,10 is usual for ascii text -
13 is carriage return (CR), puts the cursor at the start of the line (x=0,y=y)
10 is line feed (LF), puts the cursor one line down (x=x,y=y+1)


Thanks, putting in the LF made it perfect.


str1 db 'Have a great day,',13,10, '                          Andy',13,10,13,10 ,\
  'http://intouch.org/magazine/daily-devotional',13,10,'http://www.happynews.com/'



Have a great day,
                          Andy

http://intouch.org/magazine/daily-devotional
http://www.happynews.com
Have a great day,
                         Andy