How does one get the text in textbox control that is in a SDK program?
Need to retrieve and write to file, so DDT program can use.
Thanks,
Brent
Need to retrieve and write to file, so DDT program can use.
Thanks,
Brent
CASE %WM_COMMAND '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SELECT CASE LOWRD(wParam) CASE %IDC_EDIT_1 SELECT CASE HIWRD(wParam) CASE %EN_UPDATE,%EN_CHANGE,%EN_VSCROLL GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL STRPTR(NoFlickText),1024 'GetWindowText %idc_edit_1, BYVAL STRPTR(NoFlickText), 1024 'force background drawing updates... InvalidateRect GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL 0, 1 END SELECT END SELECT
CASE %WM_COMMAND '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SELECT CASE LOWRD(wParam) CASE %IDC_EDIT_1 SELECT CASE HIWRD(wParam) CASE %EN_UPDATE,%EN_CHANGE,%EN_VSCROLL xx=STRPTR(stxt) ' gets string buffer address NoFlicktext=stxt [email protected] ' Updates stxt address in memory GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL STRPTR(stxt),1024 'force background drawing updates... InvalidateRect GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL 0, 1 END SELECT END SELECT
NoFlickText = STRING$ (SendMessage _ (lparam, %WM_GETTEXTLENGTH, %NULL, %NULL) + 1, $NUL)
GLOBAL NoFlickText AS ASCIIZ*%MAX_PATH GLOBAL stxt as ASCIIZ*%MAX_PATH GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYREF NoFlickText,1024
SetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYREF stxt
GetDlgItemText hWnd, %IDC_EDIT_1, NoFlickText, [B]sizeof(NoFlickText)[/B]
SetWindowPos hCtrl, %HWND_TOPMOST, 0, 0, 0, 0, %SWP_NOSIZE or %SWP_NOMOVE
' found on forums, since roughly handled FUNCTION AFontMake(BYVAL sFontName AS STRING, BYVAL nPointSize AS LONG, BYVAL bIsBold AS LONG, BYVAL bIsItalic AS LONG, BYVAL bIsUnderline AS LONG ) AS LONG LOCAL hDC AS LONG, CyPixels AS LONG hDC = GetDC(%HWND_DESKTOP) CyPixels = GetDeviceCaps(hDC, %LOGPIXELSY) ReleaseDC %HWND_DESKTOP, hDC nPointSize = (nPointSize * CyPixels) \ 72 FUNCTION = CreateFont(0 - nPointSize, 0, 0, 0, IIF&(bIsBold, %FW_BOLD, %FW_NORMAL), bIsItalic, bIsUnderline, 0, _ %ANSI_CHARSET, %OUT_TT_PRECIS, %CLIP_DEFAULT_PRECIS, _ %DEFAULT_QUALITY, %FF_DONTCARE, BYCOPY sFontName) END FUNCTION
CASE %WM_CREATE STATIC DKWhfont1 AS LONG DKWhfont1 = Afontmake ("Courier New", 14, 1, 0, 0) sendmessage getdlgitem(hWnd,%LL2) , %WM_SETFONT, DKWhfont2, 0 CASE WM_DESTROY Deleteobject DKWhfont1
'------------------------------------------------------------------------------ ' ' Instead of creating a %NULL_BRUSH, I created a pattern brush by using a chunk ' of bitmap from where the edit control is going to be shown. This is assuming, ' the bitmap is of actual size, and edit control has no border or H/V Scrollbars. ' '------------------------------------------------------------------------------ #COMPILE EXE #INCLUDE "Win32API.inc" %IDC_EDIT_1 = 1000 GLOBAL hbmp AS DWORD GLOBAL hMemBmp AS DWORD GLOBAL hBmpDC AS DWORD GLOBAL NoFlickText AS STRING '========================MakeFont FUNCTION=================================================== ' For Comments textbox text, Script MS Bold, Italic FUNCTION MakeFontI(BYVAL SYSFont AS STRING, BYVAL PointSize AS LONG) AS LONG LOCAL hDC AS LONG LOCAL CyPixels AS LONG '/ 72 0,0,8,%fw_normal, 0, 0, 0, hDC = GetDC(%HWND_DESKTOP) CyPixels = GetDeviceCaps(hDC, %LOGPIXELSY) ReleaseDC %HWND_DESKTOP, hDC 'point 8 is default for power basic PointSize =-MulDiv(PointSize, CyPixels, 72) FUNCTION = CreateFont(PointSize, 0, 0, 0, %FW_NORMAL, 1, 0, 0, _ 'italic, underline, strikeout %ANSI_CHARSET, %OUT_TT_PRECIS, %CLIP_DEFAULT_PRECIS, _ 'was %FW_NORMAL %DEFAULT_QUALITY, %FF_DONTCARE, BYCOPY SYSFont) END FUNCTION 'FW_NORMAL, 0, 0, 1, LINE THROUGH MIDDLE OF TEXT '------------------------------------------------------------------------------ ' '------------------------------------------------------------------------------ FUNCTION CaptureBitmapSnippet(BYVAL hWnd AS DWORD,BYVAL hBitmap AS DWORD, BYVAL rc AS RECT ) AS DWORD LOCAL hDC AS DWORD LOCAL hBMDC AS DWORD hDC = GetDC(hWnd) hBMDC = CreateCompatibleDC(hDC) SelectObject hBMDC, hBitmap BitBlt hDC,0,0,rc.nleft,rc.ntop, hBMDC, rc.nright,rc.nbottom, %SRCCOPY FUNCTION = hBitmap ReleaseDC hWnd, hDC DeleteDC hBMDC END FUNCTION '------------------------------------------------------------------------------ ' '------------------------------------------------------------------------------ FUNCTION WINMAIN (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, _ BYVAL lpCmdLine AS ASCIIZ PTR, BYVAL iCmdShow AS LONG) AS LONG LOCAL Msg AS tagMsg LOCAL wce AS WndClassEx LOCAL szAppName AS ASCIIZ * 80 LOCAL hWnd AS DWORD LOCAL hCtl AS DWORD szAppName = "HelloWin" wce.cbSize = SIZEOF(wce) wce.STYLE = %CS_HREDRAW OR %CS_VREDRAW wce.lpfnWndProc = CODEPTR(WndProc) wce.cbClsExtra = 0 wce.cbWndExtra = 0 wce.hInstance = hInstance wce.hIcon = 0 wce.hCursor = LoadCursor(%NULL, BYVAL %IDC_ARROW) wce.hbrBackground = GetStockObject(%WHITE_BRUSH) '%NULL wce.lpszMenuName = %NULL wce.lpszClassName = VARPTR(szAppName) wce.hIconSm = LoadIcon(hInstance, BYVAL %IDI_APPLICATION) RegisterClassEx wce ' Create a window using the registered class hWnd = CreateWindow(szAppName, _ ' window class name "Edit text Program", _ ' window caption %WS_OVERLAPPEDWINDOW, _ ' window style 250, _ ' initial x position 100, _ ' initial y position 500, _ ' initial x size 420, _ ' initial y size %NULL, _ ' parent window handle %NULL, _ ' window menu handle hInstance, _ ' program instance handle BYVAL %NULL) ' creation parameters IF hWnd = 0 THEN ' exit on failure MSGBOX "Unable to create window" EXIT FUNCTION END IF ' Display the window on the screen ShowWindow hWnd, iCmdShow UpdateWindow hWnd DO WHILE GetMessage(Msg, %NULL, 0, 0) TranslateMessage Msg DispatchMessage Msg LOOP CALL SAVEEDIT '' File to open in "FLICKERJULES" to get edited text '? "NoFlickText, ready to close= "+NoFlickText ''NoFlickText=stxt 'OPEN "C:\Program Files\MyDiaryWin\NoFlicker.csv" FOR OUTPUT AS #1 ' WRITE #1, NoFlickText 'CLOSE #1 FUNCTION = msg.wParam END FUNCTION '------------------------------------------------------------------------------ ' '------------------------------------------------------------------------------ FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _ BYVAL wParam AS DWORD, BYVAL lParam AS LONG) EXPORT AS LONG LOCAL hDC AS DWORD LOCAL pPaint AS PAINTSTRUCT LOCAL tRect AS RECT LOCAL ptnmhdr AS NMHDR PTR LOCAL hInst AS DWORD,hImage AS DWORD, hCtl AS DWORD LOCAL wStyle AS DWORD,wStyleEx AS DWORD LOCAL szCaption AS ASCIIZ*255 LOCAL rc AS RECT LOCAL stxt AS STRING LOCAL Lb AS LOGBRUSH 'DUPLICATE NAME LOCAL lf AS LOGFONT STATIC hBrush AS DWORD STATIC pt AS POINTAPI STATIC hFont11 AS LONG 'STATIC hBrush1 AS DWORD '--- DIM xx AS ASCIIZ PTR SELECT CASE wMsg '--- CASE %WM_INITDIALOG ' For text in a pop up dialog - NOT NEEDED FOR LOADPICTURETEXT 'hFont11 = MakeFontI("MS Script Bold", 12) '("Script", 12) 'GetObject hFont11, SIZEOF(lf), BYVAL VARPTR(lf) 'lf.lfWeight = %FW_BOLD 'lb.lbStyle = %NULL_BRUSH 'hBrush = CreatePatternBrush( hMemBmp ) 'hBrush1 = CreateSolidBrush(GetSysColor(%COLOR_3DFACE)) 'SendMessage GetDlgItem(hwnd, %IDC_EDIT_1), %WM_SETFONT, hFont11, 0 ' 1000 CASE %WM_CREATE ' File to open is "FLICKERJULES" to get text to edit OPEN "C:\Program Files\MyDiaryWin\NoFlicker.csv" FOR INPUT AS #1 WHILE ISFALSE EOF (1) INPUT #1, NoFlickText WEND CLOSE #1 '========================================================================= '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '---LOAD BITMAP FROM FILE...652 X 362 PIXELS STATIC bmpfile AS ASCIIZ*255 'bmpfile = "C:\PROGRAM FILES\MYDIARYWIN\BITMAPS\TESTJULES.bmp" + CHR$(0) bmpfile = "C:\PROGRAM FILES\MYDIARYWIN\BITMAPS\TAN254FRAM1.bmp" + CHR$(0) '"jetstream.bmp" + CHR$ (0) ' convert string to ASCIIZ hBmp = LoadImage(0, bmpfile, %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE) STATIC bm AS BITMAP GetObject hBmp, SIZEOF(bm), BYVAL VARPTR(bm) pt.x = bm.bmWidth: pt.y = bm.bmHeight '--resize window to fit actual size <todo: add border and caption offset> MoveWindow hWnd, 100,10,pt.x,pt.y,1 '---CAPTURE AREA WHERE THE CONTROL WILL BE POSITIONED... 'CALL SetRect(rc,500,220,220,100)'area to capture 'CALL SetRect(rc,207,105,305,209)'area to capture CALL SetRect(rc,12,12,630,340)'area to capture 53,61,305,209 hMemBmp = CaptureBitmapSnippet( hWnd, hBmp, BYVAL rc ) 'returns a snippet hBrush = CreatePatternBrush( hMemBmp ) '--- ' Position where it would be in DiaryBook.exe and size in pixels SetWindowPos hWnd, %HWND_TOP, 260, 166, 652, 402, 0 'width & height in pixels %SWP_NOMOVE OR %SWP_NOSIZE 'SetWindowPos hCtrl, %HWND_TOPMOST, 0, 0, 0, 0, %SWP_NOSIZE or %SWP_NOMOVE '652,402 '---add an edit control... hInst = GetModuleHandle(BYVAL %NULL) szCaption = "" 'CALL SetRect(rc,500,220,220,100) CALL SetRect(rc,12,12,630,340)'same size as area to capture wStyle = %WS_CHILD OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _ %WS_VISIBLE OR %ES_LEFT OR %ES_AUTOVSCROLL OR _ %ES_MULTILINE OR %ES_WANTRETURN 'OR %WS_VSCROLL wStyleEx = 0 '%WS_EX_CLIENTEDGE hCtl = CreateWindowEx(wStyleEx, "EDIT", szCaption,wStyle, _ rc.nLeft,rc.nTop,rc.nRight,rc.nBottom, _ hWnd, %IDC_EDIT_1, hInst, BYVAL %NULL) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '' File to open is "FLICKERJULES" to get text to edit 'OPEN "C:\Program Files\MyDiaryWin\NoFlicker.csv" FOR INPUT AS #99 ' WHILE ISFALSE EOF (99) ' INPUT #99, NoFlickText ' WEND ' CLOSE #99 'IF NoFlickText <> "" THEN stxt=TRIM$(NoFlickText) 'trim$(NoFlickText) 'END IF '? "stxt = "+stxt 'stxt = "This is your Mission Impossible! " & $CRLF & _ ' " ## Scroll down to read more ## " & $CRLF & _ ' "If you accept this mission, you" & $CRLF & _ ' "will need your supernatural papers." & $CRLF & _ ' "You can locate them in your back" & $CRLF & _ ' "pocket on the right side of your" & $CRLF & _ ' "flight suit." & $CRLF & _ ' "This computer will self destruct in " & $CRLF & _ ' "10 seconds... " '? "stxt= "+stxt SetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL STRPTR(stxt) 'SetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), stxt 'BYVAL STRPTR(stxt) CALL SetFocus(GetDlgItem(hWnd,%IDC_EDIT_1)) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'SetTimer hWnd,555, 500, BYVAL %NULL '--- CASE %WM_TIMER 'KillTimer hWnd, 555 'stxt = "This is your Mission Impossible! " & $CRLF & _ ' " ## Scroll down to read more ## " & $CRLF & _ ' "If you accept this mission, you" & $CRLF & _ ' "will need your supernatural papers." & $CRLF & _ ' "You can locate them in your back" & $CRLF & _ ' "pocket on the right side of your" & $CRLF & _ ' "flight suit." & $CRLF & _ ' "This computer will self destruct in " & $CRLF & _ ' "10 seconds... " 'SetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL STRPTR(stxt) 'CALL SetFocus(GetDlgItem(hWnd,%IDC_EDIT_1)) 'FUNCTION =1 :EXIT FUNCTION '--- CASE %WM_PAINT hDC = BeginPaint(hWnd, pPaint) 'dummy paint cycle EndPaint hWnd, pPaint FUNCTION = 1 :EXIT FUNCTION '--- CASE %WM_ERASEBKGND '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hBmpDC = CreateCompatibleDC(wParam) SelectObject hBmpDC, hBmp BitBlt wParam, 0, 0, pt.x, pt.y, hBmpDC, 0, 0, %SRCCOPY DeleteDC hBmpDC FUNCTION = 1 :EXIT FUNCTION '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'CASE %WM_CTLCOLORSTATIC 'changes font color in Labels ' SELECT CASE GetDlgCtrlID(LPARAM) ' ' textboxe - COLOR BROWN ' CASE %IDC_EDIT_1 '1000 ' SelectObject wPARAM, hFont11 ' SetBkMode wParam, %TRANSPARENT ' SetTextColor WPARAM, RGB(64,0,0) ' FUNCTION = hFont11: exit FUNCTION ' END SELECT '--- CASE %WM_CTLCOLOREDIT '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SetTextColor wParam, RGB(64,0,0) SelectObject wParam, hBrush SetBkMode wParam,%TRANSPARENT FUNCTION = hBrush :EXIT FUNCTION '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '--- CASE %WM_COMMAND '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SELECT CASE LOWRD(wParam) CASE %IDC_EDIT_1 SELECT CASE HIWRD(wParam) CASE %EN_UPDATE,%EN_CHANGE,%EN_VSCROLL xx=STRPTR(stxt) ' gets string buffer address NoFlicktext=TRIM$(stxt) [email protected] ' Updates stxt address in memory 'GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL STRPTR(stxt),1024 ' GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYREF (stxt),%MAX_PATH '1024 'GetWindowText %idc_edit_1, byref stxt, %MAX_PATH GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL STRPTR(NoFlickText), 1024 '%MAX_PATH '1024 '' Kev try this - did not return added text? ''GetDlgItemText hWnd, %IDC_EDIT_1, NoFlickText, SIZEOF(NoFlickText) ' GetWindowText GetDlgItem(hWnd,%IDC_EDIT_1), BYREF NoFlickText,1024 '%MAX_PATH '1024 'GetWindowText %idc_edit_1, byval strptr(NoFlickText), 1024 'force background drawing updates... InvalidateRect GetDlgItem(hWnd,%IDC_EDIT_1), BYVAL 0, 1 END SELECT END SELECT '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '--- CASE %WM_DESTROY PostQuitMessage 0 :EXIT FUNCTION '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DeleteObject hBrush DeleteObject hBmp DeleteOBject hMemBmp 'DeleteObject hBrush1 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END SELECT FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam) END FUNCTION SUB SAVEEDIT ? "NoFlickText= "+NoFlickText ' File to open in "FLICKERJULES" to save edited text and return to program 'IF NoFlickText <> "" THEN OPEN "C:\Program Files\MyDiaryWin\NoFlicker.csv" FOR OUTPUT AS #1 WRITE #1, NoFlickText CLOSE #1 'END IF END SUB
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment