Select color

With the common dialog you can select a color. Color := CommonDialogControl.Color; This works fine if the variable ‘Color’ is type:Variant, otherwise i get an error ‘This type is not supported by C/Side…’ I want to use it in currform.UPDATEFORECOLOR(Color); Therefore ‘Color’ must be an Integer. Can this be done? Regards, Willy

Uhm - I’m not quite sure what You are trying to do. But let me try this: I got the following on my Item List Form:


<No.>
OnFormat(VAR Text : Text[260];)
If Blocked then
  CurrForm."No.".UPDATEFORECOLOR(12632256);

This will grey out the No. Field on the form, if the Item is blocked. As You see, the number is rather high, where i think black is 0. I useally pick a color of the - thing, and then read the number from the properties. You want You color to be different based on a option-field - ie. Costing Method: The I would do it like this;


OnAfterGetCurrRecord()
case "Costing Method" Of :
  "Costing Method"::FIFO :
    Color := 123;
  "Costing Method"::Standard :
    Color := 12632256;
  ...
  else
    color := 0
end;

---

OnFormat(VAR Text : Text[260];)
CurrForm."No.".UPDATEFORECOLOR(Color);

Or am I completly not understanding what You are doing? /Henrik Edited by - hhelgesen on 2001 Aug 10 21:26:03

Henrik, Thank you for your reply, but that is not what i’m looking for. What i want is a possibility for the end-user to select a color. In your examples its the developer who selects the colors. Willy Edited by - wex on 2001 Aug 11 00:05:23

WHY in the world do You want them to change the color ??? I acturally beleve the 0 would be the default Windows color. However, You can do the same: Add a Variable as Option Color : Option <Black,Red,Yellow,Green,…> CreateAFunction called SetColor. You need to call that at OnOpenForm and OnAfterValidate of the Optionbox. But bacicly the same code, as I described before. /# Henrik(NO d)

Why do we want these kind of things? Well, basicaly we only do this on friday-afternoons at gadget-hour. Besides that, one of our employees is almost color-blind and we want to surprise him with this option (hope he doesn’t read this). Your last solution will work, but will not have the variety of colors the common dialog gives you. Willy

What’s problem? ‘Variant’ data type? Create your own small OCX (VB, Delphi) to select color and convert it into true ‘Integer’. Connect OCX to Navision you have fun! Business Applications Programmer Sertified Navision Developer SIA “Sintegra” Latvia

quote:


Originally posted by wex: Why do we want these kind of things? Well, basicaly we only do this on friday-afternoons at gadget-hour. Willy


999999999 Colour combinations how many do you need? try this on one of your text boxes! say “Item List” Description OnFormat(VAR Text : Text[260]:wink: RANDOMIZE; CurrForm.Description.UPDATEFORECOLOR(RANDOM(999999999)); If you add the code, then you can have different lines with random colours! Different colours evey time you open the form or move the record pointer on every line that should help his eyes!! Hmmmm! Gadget Hour? You have a spare hour every week? Maybe you could design something usefull to pick our lottery numbers in Navision five lines six numbers! RANDOMIZE; FOR Line := 1 to 5 do For Row := 1 to 6 do LottoNo[Line,Row]:=RANDOM(48)); Whats the chance of a duplicate in a line? Edited by - David Cox on 2001 Aug 12 22:48:48

I have done this before. Do the following: 1. Create a field of option type. Then set the options to Red, Green, Blue, Cyan, Magneta, Yellow, White,Gray,Black. 2. Add another field of integer type. 3. Add the following code: CASE “Reply Color” OF “Reply Color”::Red : “Reply RGB Value” := 255; “Reply Color”::Green : “Reply RGB Value” := 65280; “Reply Color”::Blue : “Reply RGB Value” := 16711680; “Reply Color”::Cyan : “Reply RGB Value” := 16776960; “Reply Color”::Magenta : “Reply RGB Value” := 16711935; “Reply Color”::Yellow : “Reply RGB Value” := 65535; “Reply Color”::White : “Reply RGB Value” := 16777215; “Reply Color”::Gray : “Reply RGB Value” := 8421504; “Reply Color”::Black : “Reply RGB Value” := 0; END; After that you simply need to use the value of “Reply RGB Value” in the OnFormat property where appropriate. Hope this helps. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117

Hello all, I apreciate your help. You came up with some alternatives. Thats great, thats the way you normaly want members to react. However in this case i’m only interested in a way to use the common dialog, store the returned value and use it in an UPDATEFORECOLOR. Just see it as a chalenge. (After all Navision adopted the MS common dialog, see codeunit 412 ‘Common Dialog Management’) Willy

Just for those who wonder about the calculation of the “funny” color values (e.g Blue = 16711680) The calculation formula for colors reads Red + Green * 256 + Blue * 256 * 256 Thus Black := 0; Red := 256; Green := 255 * 256; Blue := 255 * 256 * 256; or combinations like Aqua = 0 + 255 * 256 +255 * 256 * 256 White = 255 + (255256) + (255256*256) ------- With best regards from Switzerland Marcus Fabian