The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: herge on October 27, 2008, 12:56:46 AM

Title: GetCursorPos
Post by: herge on October 27, 2008, 12:56:46 AM
 Hi All:

I am having trouble with this windows Api I am trying to
figure out the column position of a dos box.
we are getting values that do not change after
we write to the screen in a dos box.

CursorPos POINT <>
     org CursorPos
X dd 0
Y dd 0



   push ecx
   push edx
   invoke GetCursorPos,offset CursorPos
   mov ecx, X
   mov edx, Y
   pop edx



Regards herge
Title: Re: GetCursorPos
Post by: MichaelW on October 27, 2008, 02:28:47 AM
What is the "org CursorPos"?

I'm not sure what you are trying to do, but this is a quick demo of the GetCursorPos function, build as a console app.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      pt    POINT <>
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  @@:
    invoke GetCursorPos, ADDR pt

    ;----------------------------------------------------------------------
    ; Update the coordinates display only if at least one of them changes.
    ;----------------------------------------------------------------------

    .IF pt.x != esi || pt.y != edi

      ;---------------------------------------------
      ; The trailing tab character (9) advances the
      ; text cursor to the next tabstop position.
      ;---------------------------------------------

      print ustr$(pt.x),9

      ;----------------------------------------------------------------
      ; The spaces here overwrite any leftover characters from longer
      ; y-coordinate values, and the trailing carriage return character
      ; (13) with no line feed character (10) returns the text cursor
      ; to the start of the current line.
      ;----------------------------------------------------------------

      print ustr$(pt.y),"    ",13
      mov esi, pt.x
      mov edi, pt.y
    .ENDIF

    ;-------------------------------------------------
    ; Continue until the user presses the Escape key.
    ;-------------------------------------------------

    invoke GetAsyncKeyState, VK_ESCAPE
    test eax, eax
    jz @B

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start




Title: Re: GetCursorPos
Post by: herge on October 27, 2008, 07:51:54 AM
 Hi MichaelW:

Nice program. But I did have problems with
the @@ label. ie


C:\masm32\bin>\masm32\bin\ml /c /coff /Zi /Zd mi.asm 
Assembling: mi.asm
mi.asm(45) : error A2006: undefined symbol : @@


I wish @@ labels would always work but there don't.

Regards herge
Title: Re: GetCursorPos
Post by: jj2007 on October 27, 2008, 07:59:50 AM
Quote from: herge on October 27, 2008, 07:51:54 AM
Nice program. But I did have problems with
the @@ label. ie

No problems here. In any case, "Cursor" in Windows jargon means the mouse. It seems you are looking for the text column position, which is quite a different story. Search MSDN.
Title: Re: GetCursorPos
Post by: sinsi on October 27, 2008, 08:52:04 AM
Have a look at GetConsoleScreenBufferInfo