Support Forums > WinFBX - Windows Framework for FreeBASIC
WM_Create treeview size
jermy:
Maybe a stupid question, but how do I get my treeview the same size as the tab control
Only in WM_SIZE the format is correct again, from WM_CREATE I cannot get desired format ( same size as the tab control )
I can of course send a WM_SIZE message with sendmessage
--- Code: ---FUNCTION TabPage1_WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
SELECT CASE uMsg
CASE WM_CREATE
' // Get a pointer to the TabPage class
DIM pTabPage AS CTabPage PTR = AfxCTabPagePtr(GetParent(hwnd), 0)
' // Add controls to the first page
pTabPage->AddControl( "TreeView", hwnd, IDC_TREEVIEW, "", 0, 0, 100 , 100 )
Case WM_SIZE ' this works
DIM pWindow AS CWindow PTR = AfxCWindowPtr(hwnd)
IF pWindow THEN pWindow->MoveWindow GetDlgItem(hwnd, IDC_TREEVIEW), 0, 0, pWindow->ClientWidth, pWindow->ClientHeight, CTRUE
--- End code ---
?
José Roca:
In the WM_CREATE message, the size of the page is not know because it has not been resized yet.
Instead, add the control after the tab page has been fully created and resized:
--- Code: ---' // Create the first tab page
DIM pTabPage1 AS CTabPage PTR = NEW CTabPage
pTabPage1->InsertPage(hTab, 0, "Tab 1", -1, @TabPage1_WndProc)
pTabPage1->AddControl( "TreeView", pTabPage1->hWindow, IDC_TREEVIEW, "", 0, 0, pTabPage1->ClientWidth , pTabPage1->ClientHeight )
--- End code ---
jermy:
Ok tnx
I moved the creation code for the treeview to winmain, now i want to fill the treeview this is also not possible from WM_CREATE Tabpage?
the code does not fill the treeview
--- Code: ---
FUNCTION TabPage1_WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
SELECT CASE uMsg
CASE WM_CREATE
DIM hTreeView AS HWND = GetDlgItem(hwnd, IDC_TREEVIEW)
' // Add items to the TreeView
DIM AS HTREEITEM hRoot, hNode, hItem
' // Create the root node
hRoot = TreeView_AddRootItem(hTreeView, "All accounts")
' // Create a node
hNode = TreeView_AppendItem(hTreeView, hRoot, "A")
--- End code ---
I did some testing the listview window handel is not yet created?
José Roca:
After moving the creation code to WinMain, the TreeView control has not yet been created when you receive the WM_CREATE message. Mode the code after pTabPage1->AddControl.
José Roca:
If you want to create the TreeView and the filling code in WM_CREATE, create the TreeView with any size, or even 0, and then resize it in WM_SIZE.
Navigation
[0] Message Index
[#] Next page
Go to full version