VB6: console get mouse position reading input buffer events -
can me writing code in vb6 reads input buffer events console window? important part mouse cursor position in cells , rows.
i making program in vb6 uses console main gui (or should cui) , can't find example in vb code uses 'input buffer events'.
this example code want it's in c++ , i'm using vb6: https://msdn.microsoft.com/en-us/library/ms685035(v=vs.85).aspx
i have lot of trouble converting code because don't know c++. here other links gave me idea of how start:
- http://www.developer.com/net/vb/article.php/10926_1538861_6/writing-console-mode-applications-in-visual-basic.htm
- https://msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx
- http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/
- http://blogs.msdn.com/b/oldnewthing/archive/2013/05/06/10416225.aspx
- http://microsoft.public.vb.winapi.narkive.com/avyxhxug/readconsoleinput-and-input-record
- http://www.pinvoke.net/default.aspx/kernel32/readconsoleinput.html
here module, have:
private const enable_mouse_input = &h10 private const enable_window_input = &h8 private const enable_extended_flags = &h80 private const std_input_handle = -10& private const std_output_handle = -11& private const mouse_moved = &h1 private type coord x integer y integer end type private type small_rect left integer top integer right integer bottom integer end type type input_record ieventtype integer abdata(0 15) byte end type private type console_screen_buffer_info dwsize coord dwcursorposition coord wattributes integer srwindow small_rect dwmaximumwindowsize coord end type type key_event_record lkeydown long irepeatcount integer ivirtualkeycode integer ivirtualscancode integer ichar integer lcontrolkeystate long end type type mouse_event_record cdmouseposition coord lbuttonstate long lcontrolkeystate long leventflags long end type type focus_event_record lsetfocus long end type private declare sub sleep lib "kernel32" (byval dwmilliseconds long) private declare sub copymemory lib "kernel32" alias "rtlmovememory" (pdestination any, psource any, byval lbytecount long) private declare function allocconsole lib "kernel32" () long private declare function freeconsole lib "kernel32" () long private declare function getstdhandle lib "kernel32" (byval nstdhandle long) long private declare function setconsolemode lib "kernel32" (byval hconsoleoutput long, dwmode long) long private declare function readconsoleinput lib "kernel32" alias "readconsoleinputa" (byval hconsoleinput long, lpbuffer any, byval nlength long, lpnumberofeventsread long) long '################################################################################################## private sub main() allocconsole dim hconsolein long dim hconsoleout long dim ir input_record dim mer mouse_event_record dim ret long hconsolein = getstdhandle(std_input_handle) hconsoleout = getstdhandle(std_output_handle) call setconsolemode(hconsoleout, enable_window_input or enable_mouse_input or enable_extended_flags) dim x long dim y long readconsoleinput hconsolein, mer, 1, ret select case ir.ieventtype case mouse_event call copymemory(mer, ir.abdata(0), len(mer)) x = mer.cdmouseposition.x y = mer.cdmouseposition.y if msgbox(x & "|" & y, vbokcancel) = vbcancel exit end select loop freeconsole end sub
can please me? kind regards!
Comments
Post a Comment