Serialize a ListBox

I have a dialog-based utility with several controls and a 
listbox.  I have been able to successfully serialize all 
of the controls except the listbox.  I ran it in debug 
with the .IsSerializable function and it returned false.
Why is the listbox the only control on the dialog that is 
not serializable?  What am I missing?

Thanks in advance for your help.

Kevin
0
anonymous (74722)
11/2/2003 8:57:31 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
1213 Views

Similar Articles

[PageSpeed] 38

"Kevin" <anonymous@discussions.microsoft.com> wrote in message
news:034401c3a183$ee9a4060$a101280a@phx.gbl...
> I have a dialog-based utility with several controls and a
> listbox.  I have been able to successfully serialize all
> of the controls except the listbox.  I ran it in debug
> with the .IsSerializable function and it returned false.
> Why is the listbox the only control on the dialog that is
> not serializable?  What am I missing?

That's strange, Kevin. I don't see a DECLARE_SERIAL for any of the MFC
control classes, and in a quick test on a CListCtrl, CStatic, CEdit,
CButton, and a CSliderCtrl, the call to IsSerializable returns FALSE. What
controls do you have on your dialog that do support this?
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
11/2/2003 10:02:23 PM
>-----Original Message-----
>"Kevin" <anonymous@discussions.microsoft.com> wrote in 
message
>news:034401c3a183$ee9a4060$a101280a@phx.gbl...
>> I have a dialog-based utility with several controls and 
a
>> listbox.  I have been able to successfully serialize all
>> of the controls except the listbox.  I ran it in debug
>> with the .IsSerializable function and it returned false.
>> Why is the listbox the only control on the dialog that 
is
>> not serializable?  What am I missing?
>
>That's strange, Kevin. I don't see a DECLARE_SERIAL for 
any of the MFC
>control classes, and in a quick test on a CListCtrl, 
CStatic, CEdit,
>CButton, and a CSliderCtrl, the call to IsSerializable 
returns FALSE. What
>controls do you have on your dialog that do support this?
>-- 
>Jeff Partch [VC++ MVP]
>
Thanks for the reply Jeff.  I am able to save and load the 
settings from my radio buttons, an edit box and a "buddy" 
box attached to a spin control (number of copies to 
print), but the entries in my listbox will not save.
My list box is a CListBox type (not CLIstCtrl or 
CListView), if that makes any difference.  I don't get any 
complaints from the compiler or linker when I use this 
code:  m_List.Serialize(ar);

0
anonymous (74722)
11/2/2003 11:56:33 PM
"Kevin" <anonymous@discussions.microsoft.com> wrote in message
news:033101c3a19c$f1b818d0$a501280a@phx.gbl...
>
> >-----Original Message-----
> >"Kevin" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:034401c3a183$ee9a4060$a101280a@phx.gbl...
> >> I have a dialog-based utility with several controls and
> a
> >> listbox.  I have been able to successfully serialize all
> >> of the controls except the listbox.  I ran it in debug
> >> with the .IsSerializable function and it returned false.
> >> Why is the listbox the only control on the dialog that
> is
> >> not serializable?  What am I missing?
> >
> >That's strange, Kevin. I don't see a DECLARE_SERIAL for
> any of the MFC
> >control classes, and in a quick test on a CListCtrl,
> CStatic, CEdit,
> >CButton, and a CSliderCtrl, the call to IsSerializable
> returns FALSE. What
> >controls do you have on your dialog that do support this?
> >-- 
> >Jeff Partch [VC++ MVP]
> >
> Thanks for the reply Jeff.  I am able to save and load the
> settings from my radio buttons, an edit box and a "buddy"
> box attached to a spin control (number of copies to
> print), but the entries in my listbox will not save.
> My list box is a CListBox type (not CLIstCtrl or
> CListView), if that makes any difference.  I don't get any
> complaints from the compiler or linker when I use this
> code:  m_List.Serialize(ar);

Well all CObject derived classes inherit the default implementation of
Serialize, so the compiler won't complain. In fact, that's where I end up
for every control class on which I call it: CObject::Serialize. This is its
implementation...

    _AFX_INLINE void CObject::Serialize(CArchive&)
    { /* CObject does not serialize anything by default */ }

....so I'm not sure how you're getting any satisfaction at all from this,
Kevin. :(

-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
11/3/2003 1:14:51 AM
>-----Original Message-----
>"Kevin" <anonymous@discussions.microsoft.com> wrote in 
message
>news:033101c3a19c$f1b818d0$a501280a@phx.gbl...
>>
>> >-----Original Message-----
>> >"Kevin" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:034401c3a183$ee9a4060$a101280a@phx.gbl...
>> >> I have a dialog-based utility with several controls 
and
>> a
>> >> listbox.  I have been able to successfully serialize 
all
>> >> of the controls except the listbox.  I ran it in 
debug
>> >> with the .IsSerializable function and it returned 
false.
>> >> Why is the listbox the only control on the dialog 
that
>> is
>> >> not serializable?  What am I missing?
>> >
>> >That's strange, Kevin. I don't see a DECLARE_SERIAL for
>> any of the MFC
>> >control classes, and in a quick test on a CListCtrl,
>> CStatic, CEdit,
>> >CButton, and a CSliderCtrl, the call to IsSerializable
>> returns FALSE. What
>> >controls do you have on your dialog that do support 
this?
>> >-- 
>> >Jeff Partch [VC++ MVP]
>> >
>> Thanks for the reply Jeff.  I am able to save and load 
the
>> settings from my radio buttons, an edit box and 
a "buddy"
>> box attached to a spin control (number of copies to
>> print), but the entries in my listbox will not save.
>> My list box is a CListBox type (not CLIstCtrl or
>> CListView), if that makes any difference.  I don't get 
any
>> complaints from the compiler or linker when I use this
>> code:  m_List.Serialize(ar);
>
>Well all CObject derived classes inherit the default 
implementation of
>Serialize, so the compiler won't complain. In fact, 
that's where I end up
>for every control class on which I call it: 
CObject::Serialize. This is its
>implementation...
>
>    _AFX_INLINE void CObject::Serialize(CArchive&)
>    { /* CObject does not serialize anything by default 
*/ }
>
>....so I'm not sure how you're getting any satisfaction 
at all from this,
>Kevin. :(
>
>-- 
>Jeff Partch [VC++ MVP]
>

So, I guess the only option is to spin through the listbox 
and save its contents to a CString Array.  Then serialize 
that?

Or...
Make a separate class for the listbox and make it 
serializable?

What would you recommend?
0
anonymous (74722)
11/3/2003 1:25:10 AM
"Kevin" <anonymous@discussions.microsoft.com> wrote in message
news:060901c3a1a9$52ca23f0$a101280a@phx.gbl...
> So, I guess the only option is to spin through the listbox
> and save its contents to a CString Array.  Then serialize
> that?
>
> Or...
> Make a separate class for the listbox and make it
> serializable?
>
> What would you recommend?

Well, the CStringArray thing seems pretty straight forward, and I might be
inclined to use it even in the implementation of the latter.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
11/3/2003 2:34:50 AM
I would think that overriding the Serialize function for the CObject class in your derived
listbox and doing what you just described would do exactly what you want.
					joe

On Sun, 2 Nov 2003 17:25:10 -0800, "Kevin" <anonymous@discussions.microsoft.com> wrote:

>
>>-----Original Message-----
>>"Kevin" <anonymous@discussions.microsoft.com> wrote in 
>message
>>news:033101c3a19c$f1b818d0$a501280a@phx.gbl...
>>>
>>> >-----Original Message-----
>>> >"Kevin" <anonymous@discussions.microsoft.com> wrote in
>>> message
>>> >news:034401c3a183$ee9a4060$a101280a@phx.gbl...
>>> >> I have a dialog-based utility with several controls 
>and
>>> a
>>> >> listbox.  I have been able to successfully serialize 
>all
>>> >> of the controls except the listbox.  I ran it in 
>debug
>>> >> with the .IsSerializable function and it returned 
>false.
>>> >> Why is the listbox the only control on the dialog 
>that
>>> is
>>> >> not serializable?  What am I missing?
>>> >
>>> >That's strange, Kevin. I don't see a DECLARE_SERIAL for
>>> any of the MFC
>>> >control classes, and in a quick test on a CListCtrl,
>>> CStatic, CEdit,
>>> >CButton, and a CSliderCtrl, the call to IsSerializable
>>> returns FALSE. What
>>> >controls do you have on your dialog that do support 
>this?
>>> >-- 
>>> >Jeff Partch [VC++ MVP]
>>> >
>>> Thanks for the reply Jeff.  I am able to save and load 
>the
>>> settings from my radio buttons, an edit box and 
>a "buddy"
>>> box attached to a spin control (number of copies to
>>> print), but the entries in my listbox will not save.
>>> My list box is a CListBox type (not CLIstCtrl or
>>> CListView), if that makes any difference.  I don't get 
>any
>>> complaints from the compiler or linker when I use this
>>> code:  m_List.Serialize(ar);
>>
>>Well all CObject derived classes inherit the default 
>implementation of
>>Serialize, so the compiler won't complain. In fact, 
>that's where I end up
>>for every control class on which I call it: 
>CObject::Serialize. This is its
>>implementation...
>>
>>    _AFX_INLINE void CObject::Serialize(CArchive&)
>>    { /* CObject does not serialize anything by default 
>*/ }
>>
>>....so I'm not sure how you're getting any satisfaction 
>at all from this,
>>Kevin. :(
>>
>>-- 
>>Jeff Partch [VC++ MVP]
>>
>
>So, I guess the only option is to spin through the listbox 
>and save its contents to a CString Array.  Then serialize 
>that?
>
>Or...
>Make a separate class for the listbox and make it 
>serializable?
>
>What would you recommend?

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
11/3/2003 3:35:41 AM
Reply:

Similar Artilces:

Serialization: Two Scenarios
I apologize for the length of this post, but this particular problem takes a bit of explanation. I have a set of hierarchically-related classes that I want to serialize on demand at runtime. There are two scenarios for serialization: the first is what I refer to as a "reduced" values set, where I will serialize only a selected few properties from each class in order to reduce the wire size of the xml. The second scenario is a "full" values set, where all public properties of each object in the hierarchy will be serialized as part of a runtime configuration request. Thi...

Is there any way to get BIOS serial number without using WMI in VC++/C++?
Is there any way to get BIOS serial number without using WMI in VC++/C+ +? I am able to get BIOS serial number using WMI classes. I want to know the way by which we can get BIOS serial number without using WMI Classes in VC++/C++? Thanks in Advance. Why do you need it? Note that if you are trying to "roll your own" copy protection, these efforts are largely futile, and can be defeated in minutes. If you want copy protection, look into commercial packages or shareware packages. Trying to invent your own is largely a waste of time. Why is using WMI bad when it is a specified int...

Serial item in a Kit
Hi, It seems that it's a limitation in RMS that you can't add a serial item in a kit. Is there an available add-in for this? Or anybody already did a customization for this? Tnx. \Franco fmanuel@gisimplement.com Try to use Assembly instead Afshin Alikhani - [ afshin@retailrealm.co.uk ] CEO - Retail Realm = = = = = = = = = = = "Joseph Franco Manuel" <JosephFrancoManuel@discussions.microsoft.com> wrote in message news:24BB204B-79DF-4D64-AD69-A957730FAED4@microsoft.com... > > Hi, > > It seems that it's a limitation in RMS that you can't add...

Serializing object to XML
Below is some code we have for converting our objects to XML. Both convert the XML just fine, but I have a question about a small differnance. The first block of code outputs the ?xm tag with utf-16, the second block outputs it with utf-8. Why do they generate the header differnt? And why would IE complain about the utf-16 file with the following error: Switch from current encoding to specified encoding not supported. Thanks Wayne string fileName = @"C:\Temp.xml"; StreamWriter sr = File.CreateText(fileName); XmlSerializer serializer = new XmlSerializer(typeof(USERINSPECT...

Track a part was used in what serial #
Hi anyone can help me. I know how to track the specific parts we used in a product if we know the serial #. The other way round, How can we track the what serial numbers contain a special part number. For example, if we product 100 serial number tracking unit by using 300-0000 part when we build the picking list. later, how could we know which product using this 300-0000 part? Thank you very much! -- Lucy ...

XML Serialization and custom collections
I am getting XML from a dataset that has been populated via a storedprocedure no schemas have been applied nor any relationships. But the correct table names have been given to match the table(s) equivalent business object(s). I have a custom collection that implements ICollection and IEnumerable. Here is the collection: Imports ERP.BusinessObjects Imports ERP.BusinessObjects.Helpdesk Imports ICTObjects.Collections Imports System.Xml.Serialization Namespace Collections <Serializable()> _ Public Class BusinessObjectCollection : Implements ICollection, IEnumerable ...

Serial Device comms application architecture
Hi guys, I have been tasked with writing a small application that interfaces with a serial device. I have managed to create my communication wrapper which basically handles all the comms between the application and the device. So, it has a 'Connect' method, a 'Send' and a 'Recieve'. It runs in a thread which basically does a 'While(_connected) ReadLine', and passes any incoming messages to a message handler within the object. That seems to work well - except for when I close the app! The ReadLine() is blocking, so the thread stays alive, even though t...

last added line always visible in listbox
Hello I add new lines to listbox using AddString(); I want that last added line to listbox was visible when I put many many new lines. Now I always see top of list even I add many lines. Is some simple way to do this ? "tio" <tomjey@wp.pl> wrote in message news:1155909533.593851.160030@m73g2000cwd.googlegroups.com... > Hello > I add new lines to listbox using AddString(); > I want that last added line to listbox was visible when I put many many > new lines. > Now I always see top of list even I add many lines. > Is some simple way to do this ? > Maybe a...

pricing and serial numbers
We have hundreds of item numbers with thousands of serial numbers associated with them. Is there a way to attach pricing to the serial number (or lot number). We don't want to have to create a new item number for essentially the same item just because the price is different. how do these items go to your inventory? are you making them or buying them? if these are make items then the cost should come from MO cost(materials,labor,overhead) when they're buy items should come from Receiving cost. -- Microsoft Dynamics GP MVP http://ddelprado.blogspot.com "wendileigh"...

SOP-POP and Serialized Items
I have been using Great Plains for a few years, but have not spent much time in the Purchasing module. I have an Item master that is marked for Serial tracking. This Item Master that is marked for serial tracking is purchased from VENDORA. I have a customer that wants to purchase this Serialized Item. Lets call the Item SOFTWAREABC. So I enter the order in sales Transaction Entry for CUSTOMERA and enter Item SOFTWAREABC. I want to use the AutoPO button in Sales Transaction Entry to purchase SOFTWAREABC from VENDORA and it looks like I can not do this unless I mark the item in the sales...

Dongle Serial Number
Can anyone help me on determining the serial number of storeops and hq dongles, other than the physical label? Is there an available open DLL that I can refered to? Thank you very much to all. You should be able to log into the POS and press 'CTRL'+'SHIFT'+'F1' and it should show you the 'S/N' which is the dongle number. You can also log into the RMS Manager and click 'Help' and 'About'. If all else fails use the administrator to connect to the database and run the following query: 'select serialnumber from configuration' Casey...

Serialized inventory issue
I have one sku that is set to 'none' for tracking, however, the item class is set up for tracking. I'm not fully sure how this happened, as almost all of our inventory is set up for serial tracking. My issue is that I do not know where to update this to allow tracking of this sku, as the box is shaded out? Any information is greatly appreciated. Chad On Oct 12, 2:12=A0pm, Chad <council...@gmail.com> wrote: > I have one sku that is set to 'none' for tracking, however, the item > class is set up for tracking. =A0I'm not fully sure how this happened, > a...

Updating a query criteria from a listbox
Hi, I've written a query that is dependent on a date selected from a listbox the result from the listbox is linked to the querie as follows: [forms]![Main Menu]![Date_Select] This works great when I clickthe button that loads the subform that uses the results from this querie... However when I select a different date in the listbox and click again the new date is not being passed down to the querie. I've tried everything I know and it just doesn't want to work... The listbox is linked to a table containing all the dates to be displayed - if that makes any difference. Any h...

BUG in VC++6.0???: Multi-Port Serial Communications Card Problem
I have an 8 port serial communications card in a WindowsNT system installed as COM3, COM4, ... COM10. I can use any of the eight ports using the WindowsNT hyperterminal utility I am using Visual C++ 6.0 with MFC and attempting to open different ports with the following statement m_commhandle = CreateFile((LPCTSTR)m_port, GENERIC_READ|GENERIC_WRITE,0, NULL, OPEN_EXISTING, 0,NULL) This statement works for all of the ports EXCEPT COM10. GetLastError() returns a 2 (ERROR_FILE_NOT_FOUND). In DEBUG, m_port contains "COM10", but the CreateFile(...) still fails. Hyperterminal is not runni...

40 Column thermal Receipt Reprint does not show serial numbers
How do I get the serial number to reprint on a reprinted receipt? The serial number shows up on the original receipt but not on a reprint. Thanks ...

Get HD serial number using API
Is there any way to get the HD serial number (or any other data to identify the hard disc) using API from VBA?Thanks in advance for your answers.Regards.Jose Nu´┐ŻezMontevideo ...

Gray out listbox items at the runtime
Hi, I have created a GUI in VC++ 6.0 using MFC. It contains a listbox with many items which are going to be mapped to some strings by user. I want to disable(gray out) the item whenever it has been mapped. I have searched the newsgroups and understand I need to create an owner drawn listbox , but I don't know how to draw different color for each individual item , also have no idea on graying out one particular item at the runtime. Could anybody can help me with some sample code to do the similar works? Thanks, Eileen "eileen" <eileenlxh@yahoo.com> wrote in message n...

Listbox #2
Hello! Need a little help please. Question, how do I terminate/close the listbox after the user made one selection? My code filling up a the listbox and calling a Userform1 Thank's ahead for any pointers. Sub slist() i = 1 For Each ws In Worksheets UserForm1.ListBox1.AddItem (Worksheets(i).Name) i = i + 1 Next ws UserForm1.Show End Sub Userform1 code:---------------------------------------- Private Sub ListBox1_Click() Sheets(UserForm1.ListBox1.Value).Select End Sub ...

listbox question 01-26-08
Hi, I noticed that you actually don't pick a value when you scroll through a listbox. You have to place the cursor in the field itself and then go to another object to really pick the value... I find this rather confusing. Is there a way to pick a value from a listbox by scrolling? Thanks JP Not with the normal listbox properties. You must click on an item in the listbox in order to select it. If you wanted to "select" the item by scrolling to the desired row, and then have the "top" row in the display be picked, you'd need to write programming that detects w...

Listbox Font Size
I have a listbox open on my worksheet. The listbox is from the Forms toolbar. How do I change the font size in this list box? I know how to do this if I use the listbox from the Controlbox toolbar but in this case I find it easier to use the listbox from the Forms Toolbar >>How do I change the font size in this list box? Unfortunately there is no way to do this as far as I know. -- Jim Rech Excel MVP ...

How to serialize a metafile pict?
If I get a metafile pict from somewhere, perhaps the clipboard, how can I save it in a MFC CArchive Object? ...

Listbox size changes when opening Excel
I use an imbedded ActiveX listbox in an Excel document. If the document "Zoom Magnification" is set to something less than 100%, then whenever I open the Excel document, the size of the listbox gets smaller. For example, if the "Zoom Magnification" for the Excel document is set to 75%, and the list box has a width of 1 inch and a height of 2 inches, then the next time I open the document, the listbox automatically resizes to a width of 0.75 inches and a height of 1.5 inches, and I have to go into "Design" mode to change the listbox size back to what I w...

RS232 / Hyperterminal / serial communications
hi! does the hyperterminal program delivered with windows use overlapped or non overlapped serial communications? thanks, philipp ...

Calculate height of listbox?
Is there a forumla to calculate the needed height of a listbox in order to contain a given number of lines of a given point size? Not without a bunch of GDI API work. The AutoSizeTextBox solution on my site shows you how. A far simpler solution, that is almost as accurate would be to use code/logic like: Assumes ListBox control named lbHeight Assumes TestBox control named Text11 Assumes CommandButton named CmdSize Enter a desired number of rows value in Text11 and then click on the CommandButton. Private Sub cmdSize_Click() On Error GoTo Err_cmdSize_Click Dim x As Integer ' conv...

Enforce unique serial numbers
This feature will not allow you to select the same voucher twice, but you can manually enter the same code twice. This I truley believe is a glitch. -- Thank You,; Vince ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Comm...