473,804 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help on PainBox Component(Canva s) and binary tree

15 New Member
Hello to all
I need to merge my code with the PaintBox component.
the question is:
i have a form with edit box where you put the number (data) of the node you want to insert ant it comes to the paintbox in optical version it creates
a rectangle like this
PaintBox1->Canvas->Rectangle(node widthx1,nodehei gthy1,nodewidth x2,nodeheigthy2 );
and i want every time i press the insert button a rectangle to be created
i am to the point that i can create only the first node on 1st and 2nd level then nothing!!!!!
the code for inserting the node is:
Expand|Select|Wrap|Line Numbers
  1. void tree::insert_node(PTR *pt,int x)
  2. {
  3.     PTR t;
  4.     t=*pt;
  5.     int pclh,pclw;
  6.     int nodeheigthy1=0,nodeheigthy2=0,prevnodeheigthy1,prevnodeheigthy2;
  7.     int nodewidth,nodewidthx1,nodewidthx2;
  8.     bool type=0;
  9.     pclh=Form1->PaintBox1->ClientHeight;
  10.     pclw=Form1->PaintBox1->ClientWidth;
  11.     Form1->Edit4->Text=pclh;
  12.     Form1->Edit5->Text=pclw;
  13.     nodewidth=pclw/2;
  14.     nodeheigthy1=nodeheigthy1+10;
  15.     nodeheigthy2=nodeheigthy2+50;
  16.     nodewidthx1=nodewidth+20;
  17.     nodewidthx2=nodewidth-20;
  18. if (t==NULL)
  19.     {
  20. t=new treenode;
  21.         t->data=x;
  22.         t->left=NULL;
  23.         t->right=NULL;
  24.         Form1->PaintBox1->Canvas->Rectangle(nodewidthx1,nodeheigthy1,nodewidthx2,nodeheigthy2);
  25.     }
  26.     else
  27.         if (x<t->data)
  28.         {
  29.             nodewidthx1=nodewidthx1-40;
  30.             nodeheigthy1=nodeheigthy1+80;
  31.             nodewidthx2=nodewidthx2-40;
  32.             nodeheigthy2=nodeheigthy2+80;
  33.             insert_node(&(t->left),x);
  34.             Form1->PaintBox1->Canvas->Rectangle(nodewidthx1,nodeheigthy1,nodewidthx2,nodeheigthy2);
  35.         }
  36.     else
  37.     {
  38.         nodewidthx1=nodewidthx1+40;
  39.         nodeheigthy1=nodeheigthy1+80;
  40.         nodewidthx2=nodewidthx2+40;
  41.         nodeheigthy2=nodeheigthy2+80;
  42.         insert_node(&(t->right),x);
  43.         Form1->PaintBox1->Canvas->Rectangle(nodewidthx1,nodeheigthy1,nodewidthx2,nodeheigthy2);
  44.     }
  45.         *pt=t;
  46. }
  47.  
if anyone knows plaese help i have stuck for two weeks
it is for my exam.
the result i want to achive is to have a graphical aperriance of the tree in the
PaintBox. i anyone want me to sent the whole project pm me.
Sorry i don t know how to add tags and for my english.
thanks in advance.
Nov 19 '07 #1
1 1615
DemonFox
15 New Member
NO ONE???????????? ????
please help
Nov 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
6424
by: Joseph | last post by:
hi 1) i plan on having an awt canvas component (to draw graphs) on a JFrame with other swing components..will this be okay? i've read that swing and awt aren't compatible.. 2)Also, if i have a function which simply loops infinately that is part of a form, what happens when a form event (eg button click) occurs? will the event handler be executed simulatanesouly with the loop? or does the event excecute first and then the loop is...
3
1633
by: cody | last post by:
Is there any built in functionality in the .NET framework to get the binary represention in form of string from a given integer? I can do 1344.ToString("x2") to get hexadecimal output but I need binary. I know this can be simply programmed with a few lines of code but I just want to know. -- cody
4
2408
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a hierarchy of algebraic matrices with the addition operation. Thus, I want to have a virtual base class class Matr;
4
9024
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working, even the removal, I just don't know how to keep track of the parent, so that I can set its child to the child of the node to be removed. IE - if I had C / \ B D
15
5106
by: Foodbank | last post by:
Hi all, I'm trying to do a binary search and collect some stats from a text file in order to compare the processing times of this program (binary searching) versus an old program using linked lists. I'm totally new to binary searches by the way. Can anyone help me with the commented sections below? Much of the code such as functions and printfs has already been completed. Any help is greatly appreciated. Thanks,
1
4682
by: satan | last post by:
I need to write the definition of the method leavesCount that takes as a parameter a reference of the root node of a binary tree and returns the numbers of leaves in the binary tree. This what i get so far public class BinaryTree { //Definition of the node protected class BinaryTreeNode { DataElement info;
5
1804
by: --== Alain ==-- | last post by:
Hi, Several months ago i've asked some information about the best way how to have some particular columns (progress bar, checkbox, images, color picker,...) in a ListView component. It seems that ListView is a complex component and a lot of people advise to build a custom component but not from ListVIew itself. Some use a datagrid component as base component, some build a component
1
2604
by: Michael | last post by:
I have a solution for this, but it feels wrong. If anyone could offer a better one, I'm all ears. (Or technically, eyes.) Basically, I have a bunch of classes. For concreteness, one is a Matrix class, but that's only one example, so please don't get too hung up on it. I need to output and input these classes. I'd like a nice, pretty, human readable output, something like: 1 2 3
1
1377
by: ranadhirnag | last post by:
In the afterphase of the RESPONSE_RENDER of our phaselistener,we parse the component tree to collect some event-specific data. This data needs to be rendered/dispatched along with the requested page . A javascript parser on the client will ectract this data to perform certain actions on the components. How can this data be sent back along with the document? Can a phaselistener modify the component tree to add a hidden field? Any...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.