PlanetSquires Forums
Support Forums => WinFBX - Windows Framework for FreeBASIC => Topic started by: jermy on February 17, 2021, 02:47:35 PM
-
why i get error 265 when i try to subclass with pWindow.AddControl ?
error 265: Symbol not a CLASS, ENUM, TYPE or UNION type, before '.' in 'pWindow.AddControl(_'
Sub CreateControlEx(Byval hwnd As HWND)
DIM pWindow AS CWindow PTR = AfxCWindowOwnerPtr(hwnd)
' IF pWindow THEN pWindow->AddControl("Button", hwnd, IDCANCEL, "&Close", 250, 150, 75, 23) 'works fine
pWindow.AddControl(_
"Button", _
hwnd , _
IDCANCEL, _
"Click me", _
100, _
100, _
120, _
100, _
-1, _
-1, _
0, _
CAST(SUBCLASSPROC, @ButtonProc), _
IDCANCEL, _
CAST(DWORD_PTR, @pWindow))
' works fine
' Dim hCtle As HWND
' ID = ID + 1
' hCtle = CreateWindow("BUTTON", "Button2", BS_TEXT or WS_CHILD or WS_VISIBLE, 100, 100, 120, 100, hWnd, Cast(HMENU,ID), hInstance, NULL)
' SetWindowSubclass(hCtle, @ButtonProc, id, 0)
End Sub
-
oh hell, i already found it
DIM pWindow AS CWindow PTR = AfxCWindowOwnerPtr(hwnd)
IF pWindow THEN pWindow-> AddControl(_
"Button", _
hwnd , _
IDCANCEL, _
"Click me", _
100, _
100, _
120, _
100, _
-1, _
-1, _
0, _
CAST(SUBCLASSPROC, @ButtonProc), _
IDCANCEL, _
CAST(DWORD_PTR, @pWindow))
The dot notation is only used for variables, not pointers. With a pointer we need to use the "->" symbol.
-
If you declare pWindow as CWindow PTR you have to use the -> syntax (pWindow->AddControl) , not the dotted syntax (pWindow.AddControl). Also you have to use CAST(DWORD_PTR, pWindow) instead of CAST(DWORD_PTR, @pWindow).
-
Thanx José
how do I get the button's hwnd back?
DIM pWindow AS CWindow PTR = AfxCWindowOwnerPtr(hwnd)
ID = ID + 1
pWindow-> AddControl("Button", hwnd , ID, "Click me", 100, 100, 120, 100, -1, -1, 0, CAST(SUBCLASSPROC, @ButtonProc), ID, CAST(DWORD_PTR, pWindow))
-
The best I can think of
? GetDlgItem( hwnd, ID)
-
<hwnd of the control> = GetDlgItem(<hwnd of the form>, <identifier of the control>)
See: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdlgitem