| |
|
|
|
Source wurde am 15.07.2007 aus der MMJ-Quellcodesammlung (Dietmar Horn) in die Babyklappe auf XProfan.Com abgelegt:
RichEdit: Cursor abfragen
Stefan Schnell
-Begin----------------------------------------------------------- ------
-Header-Dateien------------------------------------------------------
$H Windows.ph
$H RichEdit.ph
$H Structs.ph
$H Messages.ph
-Strukturen----------------------------------------------------------
Declare CharRange#
Struct CharRange = ~CHARRANGE
Dim CharRange#, CharRange
-Globale Variablen---------------------------------------------------
Declare Ende&, hButton&, hWin&, hRtf&
-Funktion GetCursorPosX (Spalte)-------------------------------------
Proc GetCursorPosX
SendMessage(hRtf&, ~EM_EXGETSEL, 0, CharRange#)
Return Int(CharRange#.cpMax& - (SendMessage(hRtf&,
~EM_LINEINDEX, SendMessage(hRtf&, ~EM_EXLINEFROMCHAR, 0,
CharRange#.cpMin&), 0)) + 1)
EndProc
-Funktion GetCursorPosY (Zeile)--------------------------------------
Proc GetCursorPosY
SendMessage(hRtf&, ~EM_EXGETSEL, 0, CharRange#)
Return Int(SendMessage(hRtf&, ~EM_EXLINEFROMCHAR, 0,
CharRange#.cpMin&) + 1)
EndProc
-Main----------------------------------------------------------------
-GUI---------------------------------------------------------------
hWin& = @Create(Window, %hWnd, Test, 100, 100, 320, 270)
If hWin&
hRtf& = @Create(RichEdit, hWin&, Kein Text, 5, 5, 300, 200)
hButton& = @Create(Button, hWin&, Cursor-Position ermitteln,
5, 210, 300, 24)
EndIf
-Ereignisschleife--------------------------------------------------
Clear Ende&
Repeat
WaitInput
If %Key = 2
Ende& = 1
ElseIf @Clicked(hButton&)
@MessageBox(Zeile: + @Str$(GetCursorPosY()) + @Chr$(13) +
@Chr$(10) + Spalte: + @Str$(GetCursorPosX()),
XY-Position, ~MB_OK)
EndIf
Until Ende&
Dispose CharRange#
-End-------------------------------------------------------------------
End
|
|
|
| |
|
|