• Welcome to PlanetSquires Forums.
 

WM_Create treeview size

Started by jermy, February 24, 2021, 01:12:03 PM

Previous topic - Next topic

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

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

?

José Roca

#1
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:


' // 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 )


jermy

#2
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



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")



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.

jermy

#5
I have already tried that, he first runs WM_CREATE but does not automatically pass WM_SIZE  ( TabPage1_WndProc )
I can do this that works also


         sendMessage pTabPage1->hTabPage, WM_SIZE, 0 ,0

   FUNCTION = pWindow.DoEvents
END FUNCTION