Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Variable number of TopWindows (Why can't I do a VectorMap of TopWindows?)
Variable number of TopWindows [message #47847] Mon, 10 April 2017 17:43 Go to next message
roger is currently offline  roger
Messages: 9
Registered: August 2016
Promising Member
I have a need for a variable number of TopWindows (to hold information persistently on the screen while I work in other window(s) of same app). I got this working for a single window (see "Separate Info Window, 7apr17), but when I try to extend this to a VectorMap of windows, e.g.,

VectorMap<int, SeparateInfoWindow> siws;

instead of

SeparateInfoWindow siw;

my compiler (Visual Studio 2012 C++) complains:
...\uppsrc\CtrlLib/StaticCtrl.h(17): error C2248: 'Upp::Ctrl::Ctrl' : cannot access private member declared in class 'Upp::Ctrl'
... This diagnostic occurred in the compiler generated function 'Upp::StaticText::StaticText(Upp::StaticText &)'
(when the SeparateInfoWindow contains a Label) and
...\uppsrc\CtrlLib/TextEdit.h(195): error C2248: 'Upp::Ctrl::Ctrl' : cannot access private member declared in class 'Upp::Ctrl'
... This diagnostic occurred in the compiler generated function 'Upp::TextCtrl::TextCtrl(Upp::CextCtrl &)'
(when the SeparateInfoWindow contains a DocEdit (which is derived from TextCtrl))
.

I am using Upp v. 5485, and I don't think there's anything wrong with the Upp StaticText or TextCtrl code.

I am guessing that VectorMap needs to know all the details of the values (SeparateInfoWindow, in this case) that it is mapping, cannot see their private parts, and therefore can't build the map.

I have tried instead to use pointers to SeparateInfoWindows and build a VectorMap of the pointers. I do my own allocation of space using new SeparateInfoWindow, and store the pointers in the VectorMap. The code compiles, but when it executes, when I retrieve one of the pointers from the VectorMap and try to change the text of either the Label or the DocEdit in that window, I get an access violation error. I am guessing that I am being foiled by some fundamental difference between the references returned by VectorMap.Add() and VectorMap.Get() and the pointer values stored in the VectorMap. I've tried things like:
(SeparateInfoWindow*)& psiw=vectorMap.Get(key); // this seems to sort of work
(*psiw).label.SetLabel("new text"); // throws Access Violation
(*psiw).docedit.Set("new text"); // throws Access Violation

How can I do a collection of a variable number of TopWindows? Do I have to have an explicit declaration (and name, in source code, at compile time) for each one (in order for the references to work)?

Re: Variable number of TopWindows [message #47875 is a reply to message #47847] Sat, 15 April 2017 11:48 Go to previous message
mirek is currently online  mirek
Messages: 11167
Registered: November 2005
Ultimate Member
Use ArrayMap instead.

I suggest reading:

http://www.ultimatepp.org/srcdoc$Core$Tutorial$en-us.html
Previous Topic: Separate Info Window
Next Topic: U++ playing nice with other applications
Goto Forum:
  


Current Time: Sat Nov 18 20:22:07 CET 2017

Total time taken to generate the page: 0.01091 seconds