Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-18
12
Medium Priority
?
796 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 332 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:
Ephraim Wangoya earned 668 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:Ephraim Wangoya
ID: 35172859

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

Assisted Solution

by:Ephraim Wangoya
Ephraim Wangoya earned 668 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

721 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