Solved

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

Posted on 2011-03-18
12
787 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
Industry Leaders: 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 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:
Ephraim Wangoya 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: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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

751 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