Solved

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

Posted on 2011-03-18
12
776 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
Comment Utility

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
Comment Utility
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
Comment Utility
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
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 166 total points
Comment Utility
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
Comment Utility
@jimmyX
What is that?
How can you create an object that you are searching for?
That is plain wrong.
0
 

Author Comment

by:John86a
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 24

Expert Comment

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

Expert Comment

by:ewangoya
Comment Utility

@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
Comment Utility

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
Comment Utility
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
Comment Utility
I'll accept your msn as a solution, and then we can go on from there.
0
 

Author Closing Comment

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now