Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Unable to cast Object Treeview.node


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-20-2008, 02:51 PM
Senior Member
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 101
Default Unable to cast Object Treeview.node

I've checked all the examples on the forum which included treeview, but all examples have the same issue (or appear to have it)

I'm writing an application where the user can select a file (just the path)
I tried to do this with FileOpen but that only allows me access to the memory card, Treeview was the next option, the examples on the forum all have the same problem , they give an error when I try to compile them:
"Unknown control type Use Control (Name,Type) instead"
Line XXX : Control(node).addnewnode (SubString(s,c,StrLength(s)-c))

changing this to Control(node,treeview).addnew....etc.
Seems to solve it in the EDI but when I run the compiled program I get the attached error..
(this is for the desktop version, the ppc version also has errors)

Any help is appreciated

Thanks
Attached Images
File Type: jpg error.jpg (13.5 KB, 10 views)
Reply With Quote
  #2 (permalink)  
Old 03-20-2008, 03:16 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,346
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

You are using the wrong type name I think

try changing to "node"

Control(node,node).addnew....etc.
Reply With Quote
  #3 (permalink)  
Old 03-20-2008, 03:37 PM
Senior Member
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 101
Default

Quote:
Originally Posted by agraham View Post
You are using the wrong type name I think

try changing to "node"

Control(node,node).addnew....etc.
Thanks agraham, but I also tried that, I got a similar error (attached)
I also tried Form, listbox and arraylist but no dice :-(
Attached Images
File Type: jpg error.jpg (14.2 KB, 3 views)
Reply With Quote
  #4 (permalink)  
Old 03-20-2008, 03:49 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,346
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I think you have probably incorrectly changed a treeview control reference. Treeviews and nodes are different types of object. Look at the Object list in the Project Explorer at the right. You need to use the type name given there after the object name.

For a Node object
Control(node,node).addnew....etc.

For a TreeView object
Control(treeview,treeview).addnew....etc.
Reply With Quote
  #5 (permalink)  
Old 03-20-2008, 04:20 PM
Senior Member
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 101
Default

Well thats the weird thing, i didn't change anything from the downloaded application, since i didn't know how to use treeview I downloaded an example
to see if i could figure out how it worked, but when i test the examples they give me errors, i'm trying to find out why so i can use treeview in my own application.

What happens if you try this example from Erel:
Treeview - different pics for nodes?
When I run it using the IDE I get the Controle(node) message...

Do you get the same one?
Otherwise it could be my instalations (Desktop & PPC)
Reply With Quote
  #6 (permalink)  
Old 03-20-2008, 04:43 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,346
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

It works for me with this modified code

Code:
Sub FindFolders (path, node) 'Finds all folders in a specific path
	WaitCursor(true)
	al1.clear
	DirSearch(al1,path)
	c = StrLength(path)
	For I =0 To al1.count - 1
		s=al1.item(i)
		Control(node, treeview).addnewnode (SubString(s,c,StrLength(s)-c))
	Next
	al1.Clear
	FileSearch(al1,path)
	For I =0 To al1.count - 1
		s=al1.item(i)
		node2.Value = Control(node,treeview).addnewnode (SubString(s,c,StrLength(s)-c))
		node2.ImageIndex = 2
		node2.SelectedImageIndex = 2
	Next
	Control(node,treeview).expandall
	WaitCursor(false)
End Sub
Line 40 errored as "invalid parameter" so I change"expand" to "expandall".

The code is misleading in that the parameter named node is actually a TreeView object! I needed three Control(node, treeview) edits.
Reply With Quote
  #7 (permalink)  
Old 03-20-2008, 06:11 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 577
Default

Hi guys,

the reason for is error is the "optimized compilation".

During debug in the IDE or without "optimized compilation" basic4ppc casts the objects treeview and node as needed. So the example was always right up to version 5.8.

To speed up the executables with "optimized compilation" () the programmer now has always to declare the right type (treeview or node), even you have to code some routines twice...


specci48
Reply With Quote
  #8 (permalink)  
Old 03-20-2008, 06:29 PM
Senior Member
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 101
Default

Well I replaced the sub with your version, the error doesn't show in the IDE,
but after i compile it I get the Treeview.Treeview and Treeview.node error again
Reply With Quote
  #9 (permalink)  
Old 03-20-2008, 06:31 PM
Senior Member
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 101
Default

Quote:
Originally Posted by specci48 View Post
Hi guys,

the reason for is error is the "optimized compilation".
Is there a way of "fixing" this or turning it off (just this time)?
Reply With Quote
  #10 (permalink)  
Old 03-20-2008, 06:48 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 577
Default

You can switch between the "old" and "optimized compilation" with menu File > Compile > Optimized Compilation.

If you do this you should only use one parameter in the control statement: control(node).


specci48
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
identifying a node in treeview BjornF Questions & Help Needed 3 05-29-2008 04:47 PM
Specified cast is not valid skipper Questions & Help Needed 7 03-12-2008 07:17 AM
Object Reference not set to an instance of an object monster9999 Questions & Help Needed 9 01-15-2008 09:56 PM
treeview color (node) tvrman Questions & Help Needed 2 08-04-2007 05:57 PM


All times are GMT. The time now is 03:43 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0