Provoni wrote:What I don't understand is that it seems to be so complicated to change the color of something.
What I don't understand is that a BASIC dialects floods the beginner with useless and confusing warnings. Oh well...
Provoni wrote:My program is 64-bit only I cannot your code to work jj2007.
Strangely enough, googling
SetWindowLongPtr freebasic puts my old
Simple example: Subclassing of an edit control thread on top. So I managed to convert it to 64-bit mode, which saves you the effort of trying to build it in 32-bit. Here it is:
Code: Select all
'==============================================================================
' Datagrid.bas
' Editable grid of Editboxes
' Created on July 11, 2016
' Latest change on November 17, 2018 by JJ
'==============================================================================
#Include "\AllBasics\FreeBasic\WinGUI\WinGUI.bi"
Dim shared As any ptr opMain
Dim shared As HWND Window_Main, Edit_Data(20, 10), Button_GetData, ThisCell, hBrush
Dim As Integer i, j, k
Dim As MSG msg
Function WndProc(hWnd as HWND, uMsg as long, wParam as WPARAM, lParam as LPARAM) as integer
Dim As Integer i, j, k
if uMsg=WM_COMMAND then
if lParam=Button_GetData Then
For i = 0 To 20
For j = 0 To 10
Print EditBox_GetText(Edit_Data(i, j))
Next
Next
else
ThisCell = lParam
print "click or type, value=";EditBox_GetText(ThisCell)
endif
elseif uMsg=WM_CTLCOLOREDIT then
if lParam=ThisCell then
print "*"
SetTextColor(wParam, &HFFFFFF) ' OK
SetBkMode(wParam, TRANSPARENT) ' needed to make brush work
' SetBkColor(wParam, &HFFFF00) ' no effect with transparent mode
return hBrush 'GetSysColorBrush(COLOR_INFOBK) ' OK
endif
endif
return CallWindowProc(opMain, hwnd, uMsg, wParam, lParam)
end function
'Create the window with a data grid:
Window_Main = Window_New(700, 100, 500, 500, "Editable Datagrid")
For i = 0 To 20
For j = 0 To 10
k+=1
Edit_Data(i, j) = EditBox_New(j * 40, i * 20, 40, 20, "abc",ES_CENTER, Window_Main)
EditBox_SetText(Edit_Data(i, j),str(k))
Next
Next
hBrush=CreateSolidBrush(&H0000E0) ' dark red
opMain=SetWindowLongPtr(Window_Main, GWLP_WNDPROC, @WndProc)
Button_GetData = Button_New(350, 430, 100, 20, "GetData",, Window_Main)
'Main:
Do
WaitEvent(Window_Main, msg)
Loop Until Window_Event_Close(Window_Main, msg)
End
Is there a way to detect a click on a certain edit control or do I write code that calculates at which edit control the mouse cursor is?
Yes. See above,
if uMsg=WM_COMMAND