Changeset 46 for trunk/NewView/StartupUnit.pas
- Timestamp:
- Jan 7, 2007, 10:01:36 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/StartupUnit.pas
r43 r46 173 173 end; 174 174 175 // Extract a single element of a window position spec176 // - take a value from comma-separated list177 // - convert to numeric178 // - if the number ends with P then take as179 // a percentage of given dimension180 Function ExtractPositionElement( Var ParamValue: string;181 ScreenDimension: longint ): longint;182 var183 Element: string;184 begin185 Element := ExtractNextValue( ParamValue, ',' );186 if Element = '' then187 raise Exception.Create( 'Missing position element' );188 if StrEnds( 'P', Element ) then189 begin190 Delete( Element, Length( Element ), 1 );191 if Element = '' then192 raise Exception.Create( 'Missing position element' );193 Result := StrToInt( Element );194 if Result < 0 then195 Result := 0;196 if Result > 100 then197 Result := 100;198 Result := Round( Result / 100 * ScreenDimension );199 end200 else201 begin202 Result := StrToInt( Element );203 end;204 end;205 206 Function SystemMetrics(sm:LONG):LongInt;207 Begin208 Result := WinQuerySysValue(HWND_DESKTOP,sm);209 end;210 211 // Extract a specified window position:212 // X,Y,W,H213 Function ExtractPositionSpec( ParamValue: string;214 Var Position: TWindowPosition ): boolean;215 begin216 try217 Position.Left := ExtractPositionElement( ParamValue, SystemMetrics(SV_CXSCREEN) );218 Position.Bottom := ExtractPositionElement( ParamValue, SystemMetrics(SV_CYSCREEN) );219 Position.Width := ExtractPositionElement( ParamValue, SystemMetrics(SV_CXSCREEN) );220 if Position.Width < 50 then221 Position.Width := 50;222 Position.Height := ExtractPositionElement( ParamValue, SystemMetrics(SV_CYSCREEN) );223 if Position.Height < 50 then224 225 Position.Height := 50;226 Result := true;227 except228 Result := false;229 end;230 end;231 232 233 175 // If another instance already has the files open 234 176 // activate it and return true.
Note:
See TracChangeset
for help on using the changeset viewer.