Sometimes,During development and test we often switch between different companies in our installation. To not mistaken us, so we always make changes in the correct one, we made this small change in the code. With different background-colours for each company, you never delete something importent by mistake. This example shows how it could be done.
Again we use the SysSetupFormRun class, but this time we look into the Run method. Add below code run method,now,all forms and reports will have the background colours you set for each specific company.
Remark by Jimmy on May 26th 2011
01) Add a int type field (QVS_RGBint - > set the allowedit is false and EDT is RGBint) on the CompanyInfo table.
02) A or B
A)Add string control (Control Name:customBackGroundColor ,AutoDeclaration : Yes,Width : 50,LookupButton:Always,limitTest : 0,ColorScheme:RGB,Label : "背景颜色")in Company Infomation Form design group.
A-1)overwrite Lookup method under the control.
void lookup() { super(); element.lookupOfColor(this); }
A-2)write a lookupOfColor method under the CompanyInfo Form method.
//Remark by Jimmy 2011-05-27 void lookupOfColor(FormStringControl formStringControl) { Counter r, g, b; container chosenColor; Binary customColors; CompanyInfo UpCompanyInfo; ; customColors = new Binary(64); [r, g, b] = WinAPI::RGBint2Con(formStringControl.backgroundColor()); chosenColor = WinAPI::chooseColor(element.hWnd(), r, g, b, customColors, true); if (chosenColor) { [r, g, b] = chosenColor; formStringControl.backgroundColor(WinAPI::RGB2int(r, g, b)); ttsbegin; UpCompanyInfo = CompanyInfo::find(true); if(UpCompanyInfo) { UpCompanyInfo.QVS_RGBint = WinAPI::RGB2int(r, g, b); UpCompanyInfo.update(); } ttscommit; element.design().backgroundColor(UpCompanyInfo.QVS_RGBint); CompanyInfo_ds.findRecord(UpCompanyInfo); CompanyInfo_ds.refresh(); CompanyInfo_ds.research(); } }
A-3)overwrite textChange method under the control.
public void textChange() { super(); this.text(''); }
A-4)overwrite run method under the the CompanyInfo Form method.
public void run() { ; super(); //Jimmy 2011-05-26 ++ customBackGroundColor.backgroundColor(CompanyInfo.QVS_RGBint); customBackGroundColor.foregroundColor(CompanyInfo.QVS_RGBint); //Jimmy 2011-05-26 -- }
B)the field added the Company Infomation Form and Create a Custom right-click the popup menu
code as below.
public void context() { PopupMenu PopupMenu ; Str filterValue; int selectedItemMenu; int filter, removeFilter,goToMainTable,MyAddmenu; ; PopupMenu = new PopupMenu(element.hWnd()); MyAddmenu = PopupMenu.insertItem("select color"); //filter = PopupMenu.insertItem("filter by field"); //removeFilter = PopupMenu.insertItem("remove filter/order"); //goToMainTable = PopupMenu.insertItem("go to the main table form"); selectedItemMenu = PopupMenu.draw(); filterValue = element.design().controlName("CompanyInfo_QVS_RGBint").valueStr(); switch (selectedItemMenu) { case filter : CompanyInfo_ds.filter(fieldnum(CompanyInfo,QVS_RGBint),filterValue); break; case removeFilter : CompanyInfo_ds.removeFilter(); break; case goToMainTable: this.jumpRef(); break; case MyAddmenu: this.Jimmy_selectionColor(); break; } }
private void Jimmy_selectionColor() { #DEFINE.COLORVALUE (64) int r, g, b; container chosenColor; Binary customColors = new Binary(#COLORVALUE); CCColor colorValue; CompanyInfo UpCompanyInfo; ; chosenColor = WinAPI::chooseColor(infolog.hWnd(), r, g, b, customColors, true); if (chosenColor) { [r, g, b] = chosenColor; colorValue = WinAPI::RGB2int(r, g, b); UpCompanyInfo = CompanyInfo::find(true); ttsbegin; if(UpCompanyInfo) { UpCompanyInfo.QVS_RGBint = colorValue; UpCompanyInfo.update(); } ttscommit; CompanyInfo_ds.findRecord(UpCompanyInfo); CompanyInfo_ds.refresh(); CompanyInfo_ds.research(); infolog.navPane().loadStartupButtons(); Infolog.navPane().refreshFavorites(infolog.navPane().selectedFavoriteGroup(),xInfo::currentWorkspaceNum()); } }
03)overwrite int and run method in the SysSetupFormRun
public void init() { ; // this.form().design().windowType(FormWindowType::Workspace); super(); SysSecurityFormSetup::loadSecurity(this); this.dimensionFieldCtrls(); this.inventStorageDimFieldCtrls(); if (this.isWorkflowEnabled()) { workflowControls = SysWorkflowFormControls::construct(this); workflowControls.initControls(); } }
//remark by Jimmy on 2011-05-26 ++ public void run() { FormDesign formDesign = this.design(); int COM,QCN,QHK,QUS,QVS; DataArea DataArea; DataAreaId CurDataAreaId = curExt(); CompanyInfo CompanyInfo = CompanyInfo::find(); ; super(); // Set the color scheme of this instance of te SysFormRUn to RGB formDesign.colorScheme(FormColorScheme::RGB); if(!CompanyInfo.QVS_RGBint) CompanyInfo.QVS_RGBint = winAPI::rgb2int(255,255,255);//white #FFFFFF while select DataArea where DataArea.id == CurDataAreaId { formDesign.backgroundColor(CompanyInfo.QVS_RGBint); } /* method 2) COM = winAPI::rgb2int(255,20,147);//red #FF1493 QVS = winAPI::rgb2int(170,170,170);//gray #AAAAAA QCN = winAPI::rgb2int(255,255,255);//white #FFFFFF QHK = winAPI::rgb2int(69,139,0);//green #458B00 QUS = winAPI::rgb2int(0,191,255);//blue #00BFFF if(CompanyInfo.QVS_RGBint) { COM = CompanyInfo.QVS_RGBint; QVS = CompanyInfo.QVS_RGBint; QCN = CompanyInfo.QVS_RGBint; QHK = CompanyInfo.QVS_RGBint; QUS = CompanyInfo.QVS_RGBint; } else //white { COM = QCN; QVS = QCN; QHK = QCN; QUS = QCN; } // Switch and based on the current company change colors, or not for default switch (CurDataAreaId) { case "COM": formDesign.backgroundColor(COM); break; case "QVS","NEW" : formDesign.backgroundColor(QVS); break; case "QCN": formDesign.backgroundColor(QCN); break; case "QHK": formDesign.backgroundColor(QHK); break; case "QUS": formDesign.backgroundColor(QUS); break; default : break; } */ }