troubleshooting Question

CToolBar derived Toolbar repositioning

Avatar of gpol
gpol asked on
System ProgrammingEditors IDEs
6 Comments1 Solution828 ViewsLast Modified:
The problem is to put floating CToolBars in same position than that was saved at program end.
A GetWindowRect is done for each ToolBar and the rectangle is saved to the Registry. These coords should be screen-coords. When running the program, it reads the saved rectangle, and, to use FloatControlBar, it converts the above rectangle to Client coords with ScreenToClient.
But floating ToolBars reposition at a wrong position, as shown in the attached pictures.
Code is the following:
WRITING: (B is the CToolBar derived object pointer)
RECT rcNormalPosition;
CWinApp* pApp = AfxGetApp();
B->GetWindowText(Nome,49); // name of the ToolBar
pApp->WriteProfileInt(Nome,"Left",  rcNormalPosition.left); // position
 pApp->WriteProfileInt(Nome,"Right", rcNormalPosition.right);
pApp->WriteProfileInt(Nome,"State", B->IsFloating());
READING AND POSITIONING: (Again B is the CToolBar object pointer)
RECT r; char Nome[50]; BOOL Floating;
CWinApp* pApp = AfxGetApp();
  if (Floating)
     CPoint pp;
     FloatControlBar(B,pp,AFX_IDW_DOCKBAR_TOP); // tried any Docking    
Thanks in advance
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros