Hi, I'm sure there's a win32api expert out there who can fix the bug in my code. Simply stated, when the user highlights (selects) a portion of text in a TEXTBOX, then clicks a button, I want to be able to isolate the highlighted text. I know it's GetSel(), but I can't figure out the exact implementation. Here's what I got so far....
Thanks, Christopher
Thanks, Christopher
Code:
#COMPILER PBWIN #INCLUDE "Win32api.inc" CALLBACK FUNCTION GetSelButton() DIM lResult AS DWORD DIM x AS DWORD PTR DIM y AS DWORD PTR DIM FullText AS STRING CONTROL GET TEXT CBHNDL, 500 TO FullText lResult = SendMessage(500, %EM_GETSEL, x, y) MSGBOX "selected text is: " + MID$(FullText, @x, @x - @y) END FUNCTION CALLBACK FUNCTION ExitButton() DIALOG END CBHNDL, 0 END FUNCTION FUNCTION PBMAIN () AS LONG DIM hDlg AS DWORD DIM lResult AS DWORD DIALOG NEW PIXELS,0,"GetSel() example",,,200,150,0,0 TO hDlg CONTROL ADD TEXTBOX,hDlg,500,"",30,30,150,50,0 CONTROL ADD BUTTON,hDlg,501,"Exit",150,110,40,20,0 CALL ExitButton CONTROL ADD BUTTON,hDlg,502,"Show Selected Text",20,110,120,20,0 CALL GetSelButton DIALOG SHOW MODAL hDlg END FUNCTION
Comment