Solved

DevExpress Bars 5 to 6 - BarByName is gone, BarByComponentName not functioning properly. Help?

Posted on 2011-03-18
12
782 Views
Last Modified: 2012-05-11
I use the method to introduce new elements to the bar during run time, when I say BarByComponent name, I mean that I need to invoke the name of the bar into a variable so I can call it whenever I want it, however I suspect this is not the case.

Issue: Instead of introducing the new element, a blank space is introduced instead, when clicked upon it generates an access violation error.

Example of my code:

var
  BarX: TdxBar;
begin
BarX := mainBar.BarByComponentName('barMenuList');
...

Thank you.
0
Comment
Question by:John86a
  • 5
  • 4
  • 3
12 Comments
 
LVL 32

Expert Comment

by:ewangoya
ID: 35169272

Your question is not very clear
However yo need to test the validity of the BarX
Assuming MainBar is type TdxBarManager

var
  BarX: TdxBar;
begin
  BarX := MainBar.BarByComponentName('barMenuList');
  if Assigned(BarX) then
  begin
      //do your stuff  
0
 

Author Comment

by:John86a
ID: 35171533
I was using that correctly, but after studying mad except logins I found out the reason for the error..

exception class   : EAccessViolation
exception message : Access violation at address 0064BEA0 in module 'RF8.exe'. Read of address 000000A0.

Main ($9c8):
0064bea0 +00000 RF8.exe      dxBar              32483   +0 TdxBar.GetItemLinks
006497b5 +00005 RF8.exe      dxBar              32483   +0 TdxBar.GetControl

At this exact point inside dxBar.pas:

function TdxBarItemControl.GetItem: TdxBarItem
begin
 Result := GetItemByLink(FItemLink)
end;
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35171574
Would you test following code please and show what's the result:
var
  BarX : TdxBar;
  Found : Boolean;
  i : integer;
begin
  Found := False;
  for i := 0 to MainBar.Bars.Count-1 do
    begin
      if MainBar.Bars[i].Name = 'barMenuList' then
        begin
          Found := True;
          //BarX := MainBar.Bars[i];
          break;
        end;
    end;

  if Found then
    Showmessage('barMenuList found')
  else
    Showmessage('barMenuList not found')
end;

Open in new window

0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 166 total points
ID: 35171608
Just noticed something, doesn't "BarX" require to be created first before used?
Something like this:
var
  BarX: TdxBar;
begin
  BarX := TdxBar.Create(MainBar);
  BarX := MainBar.BarByComponentName('barMenuList');
  //...
  BarX.Free;
end;

Open in new window

0
 
LVL 32

Accepted Solution

by:
ewangoya earned 334 total points
ID: 35171619
@jimmyX
What is that?
How can you create an object that you are searching for?
That is plain wrong.
0
 

Author Comment

by:John86a
ID: 35171650
That's not the origin of the error, this is:

try
 dxbarManager.LockUpdate := true;
 DeleteMenus;
 RecreateMenus(mainBar);
 Finally
 try
 dxBarManager.LockUpdate := False;
 Except
 end;
end;
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35171789
@ ewangoya
What to say man, over 12 hours looking at the screen, my brain is fried.
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 35172859

@jimmyX
I know the feeling, happens to all of us one time or another
0
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 334 total points
ID: 35173318

What is the code in DeleteMenus.
Before destroying an item in your DeleteMenus procedure, change its visible property to false Control.Visible := False

try
 dxbarManager.LockUpdate := true;
  try
    try
      DeleteMenus;
      RecreateMenus(mainBar);
    except
      //why are you hiding the exception
    end;
 Finally
   dxBarManager.LockUpdate := False;
 end;

  //try updating the mainBar
  mainBar.Update;  //or refresh
end;
0
 

Author Comment

by:John86a
ID: 35173613
Update or refresh does not exist. Do you have msn? I have separated its and bits of the parts where debugger accused the error. I do not wish to post it here.
0
 

Author Comment

by:John86a
ID: 35173616
I'll accept your msn as a solution, and then we can go on from there.
0
 

Author Closing Comment

by:John86a
ID: 35180401
Issue unresolved, going to be doing some debugging to get to the bottom of it. Might post another question later.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This article will show, step by step, how to integrate R code into a R Sweave document
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question