Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2008, 02:50 AM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 617
Default Case statement - Ordinal Type Required?

Hi,

I have a PreviewMenu component from TMS Software that I am using. It is like the menu that is used in Office 2007.

I am trying to use a Case statement to select themes from the SubItems, like below:

[delphi]
procedure TMainForm.PrevMnuMenuItems6SubItems0Click(Sender: TObject);
begin
Case PrevMnu.MenuItems[6].SubItems of
0: begin
AdvFormStyler1.Style := tsOffice2003Blue;
end;
1: begin
AdvFormStyler1.Style := tsOffice2003Classic;
end;
end;
end;
[/delphi]

I am not sure how I should be doing the case statement for SubItems and I keep getting Ordinal Type Required error!

Can anyone help me see what I should be doing?

Many thanks

Nester261

"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #2  
Old 06-13-2008, 03:10 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 6,786
Default RE: Case statement - Ordinal Type Required?

I don't know the tms components (know them, but haven't used them), but normally the SubItems is most likely a class. The MenuItems class has most likely has a property called ItemIndex (name can differ). Just look at the properties for such one...

PrevMnu.MenuItems[6].ItemIndex

Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1
Reply With Quote
  #3  
Old 06-13-2008, 05:39 AM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 617
Default RE: Case statement - Ordinal Type Required?

Hi,

Thanks Norrit but no such property exists! I have tried with using .Tags it compiles ok but with no effect!

[delphi]
procedure TMainForm.PrevMnuMenuItems6SubItems0Click(Sender: TObject);
begin
case (sender as TAdvPreviewSubMenuItem).Tag of
0: begin
AdvFormStyler1.Style := tsOffice2003Blue;
end;
1: begin
AdvFormStyler1.Style := tsOffice2003Classic;
end;
2: begin
AdvFormStyler1.Style := tsOffice2003Olive;
end;
3: begin
AdvFormStyler1.Style := tsOffice2003Silver;
end;
4: begin
AdvFormStyler1.Style := tsOffice2007Luna;
end;
5: begin
AdvFormStyler1.Style := tsOffice2007Obsidian;
end;
6: begin
AdvFormStyler1.Style := tsOffice2007Silver;
end;
7: begin
AdvFormStyler1.Style := tsWhidbey;
end;
8: begin
AdvFormStyler1.Style := tsWindowsXP;
end;
end;
end;
[/delphi]

PS: I am using the Begin and ends because I will need to add more code in between the case contruct later on...

I will continue to hammer away at it!

Nester261

"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #4  
Old 06-13-2008, 06:13 AM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 617
Default RE: Case statement - Ordinal Type Required?

lol I cannot believe how stoopid I am!!

The code works using the .tags now because I only forgot to set the SubMenuItems.OnClick Events to the case statement!!!

I kept checking my code, rechecking and getting more and more stumped! Then it hit me! ;-)

Doh!!! Think I might have a coffee! lol

Many thanks

Nester261

"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:57 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.