From: Andreas H. <ah...@us...> - 2004-01-09 21:38:03
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1:/tmp/cvs-serv26615/run Modified Files: JvJCLUtils.pas JvProgressComponent.pas Log Message: CLX compatibility, style cleaning Index: JvJCLUtils.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvJCLUtils.pas,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** JvJCLUtils.pas 8 Jan 2004 21:51:36 -0000 1.53 --- JvJCLUtils.pas 9 Jan 2004 21:37:59 -0000 1.54 *************** *** 90,93 **** --- 90,100 ---- {$ENDIF LINUX} + {$IFDEF VCL} + NullHandle = 0; + {$ENDIF VCL} + {$IFDEF VisualCLX} + NullHandle = nil; + {$ENDIF VisualCLX} + {$IFDEF LINUX} type *************** *** 215,218 **** --- 222,226 ---- function GetWinDir: TFileName; {$ENDIF MSWINDOWS} + { GetTempDir returns Windows temporary folder name } function GetTempDir: string; *************** *** 289,295 **** procedure SwapInt(var Int1, Int2: Integer); function IntPower(Base, Exponent: Integer): Integer; ! {$IFDEF VCL} ! function ChangeTopException(E: TObject): TObject; ! {$ENDIF VCL} function StrToBool(const S: string): Boolean; --- 297,301 ---- procedure SwapInt(var Int1, Int2: Integer); function IntPower(Base, Exponent: Integer): Integer; ! function ChangeTopException(E: TObject): TObject; // Linux version writes error message to ErrOutput function StrToBool(const S: string): Boolean; *************** *** 892,898 **** function RectHeight(R: TRect): Integer; {$IFDEF MSWINDOWS} procedure FreeUnusedOle; - procedure Beep; function GetWindowsVersion: string; function LoadDLL(const LibName: string): THandle; --- 898,904 ---- function RectHeight(R: TRect): Integer; + procedure Beep; {$IFDEF MSWINDOWS} procedure FreeUnusedOle; function GetWindowsVersion: string; function LoadDLL(const LibName: string): THandle; *************** *** 924,935 **** procedure HugeMove(Base: Pointer; Dst, Src, Size: Longint); procedure HMemCpy(DstPtr, SrcPtr: Pointer; Amount: Longint); - {$IFDEF VCL} function WindowClassName(Wnd: HWND): string; procedure SwitchToWindow(Wnd: HWND; Restore: Boolean); procedure ActivateWindow(Wnd: HWND); procedure ShowWinNoAnimate(Handle: HWND; CmdShow: Integer); procedure KillMessage(Wnd: HWND; Msg: Cardinal); - { SetWindowTop put window to top without recreating window } {$ENDIF VCL} procedure SetWindowTop(const Handle: HWND; const Top: Boolean); procedure CenterWindow(Wnd: HWND); --- 930,941 ---- procedure HugeMove(Base: Pointer; Dst, Src, Size: Longint); procedure HMemCpy(DstPtr, SrcPtr: Pointer; Amount: Longint); function WindowClassName(Wnd: HWND): string; + {$IFDEF VCL} procedure SwitchToWindow(Wnd: HWND; Restore: Boolean); procedure ActivateWindow(Wnd: HWND); procedure ShowWinNoAnimate(Handle: HWND; CmdShow: Integer); procedure KillMessage(Wnd: HWND; Msg: Cardinal); {$ENDIF VCL} + { SetWindowTop put window to top without recreating window } procedure SetWindowTop(const Handle: HWND; const Top: Boolean); procedure CenterWindow(Wnd: HWND); *************** *** 1573,1585 **** while DosError = 0 do begin ! {$IFDEF MSWINDOWS} ! {$WARNINGS OFF} if (AnsiCompareText(SearchRec.FindData.cFileName, FileName) = 0) or (AnsiCompareText(SearchRec.FindData.cAlternateFileName, FileName) = 0) then ! {$WARNINGS ON} ! {$ENDIF MSWINDOWS} ! {$IFDEF LINUX} if AnsiCompareStr(SearchRec.Name, FileName) = 0 then ! {$ENDIF LINUX} begin Result := True; --- 1579,1591 ---- while DosError = 0 do begin ! {$IFDEF MSWINDOWS} ! {$WARNINGS OFF} if (AnsiCompareText(SearchRec.FindData.cFileName, FileName) = 0) or (AnsiCompareText(SearchRec.FindData.cAlternateFileName, FileName) = 0) then ! {$WARNINGS ON} ! {$ENDIF MSWINDOWS} ! {$IFDEF LINUX} if AnsiCompareStr(SearchRec.Name, FileName) = 0 then ! {$ENDIF LINUX} begin Result := True; *************** *** 2048,2052 **** {$IFDEF LINUX} FileSetReadOnly(FileName, False); ! {$ENDIF LINUX} Result := DeleteFile(FileName); end; --- 2054,2058 ---- {$IFDEF LINUX} FileSetReadOnly(FileName, False); ! {$ENDIF LINUX} Result := DeleteFile(FileName); end; *************** *** 2143,2147 **** end; - {$IFDEF VCL} function ChangeTopException(E: TObject): TObject; type --- 2149,2152 ---- *************** *** 2151,2155 **** ExceptAddr: Pointer; ExceptObject: TObject; ! ExceptionRecord: PExceptionRecord; end; begin --- 2156,2160 ---- ExceptAddr: Pointer; ExceptObject: TObject; ! //ExceptionRecord: PExceptionRecord; end; begin *************** *** 2158,2164 **** comment this function implementation, compile, then uncomment and compile again. } ! {$IFDEF COMPILER6_UP} ! {$WARN SYMBOL_DEPRECATED OFF} ! {$ENDIF} if RaiseList <> nil then begin --- 2163,2170 ---- comment this function implementation, compile, then uncomment and compile again. } ! {$IFDEF MSWINDOWS} ! {$IFDEF COMPILER6_UP} ! {$WARN SYMBOL_DEPRECATED OFF} ! {$ENDIF} if RaiseList <> nil then begin *************** *** 2168,2174 **** else Result := nil; ! // raise Exception.Create('Not in exception'); end; function TTFontSelected(const DC: HDC): Boolean; var --- 2174,2186 ---- else Result := nil; ! {$ENDIF MSWINDOWS} ! {$IFDEF LINUX} ! // XXX: changing exception in stack frame is not supported on Kylix ! Writeln(ErrOutput, 'ChangeTopException'); ! Result := E; ! {$ENDIF LINUX} end; + {$IFDEF VCL} function TTFontSelected(const DC: HDC): Boolean; var *************** *** 2523,2549 **** function GetComputerName: string; - {$IFDEF MSWINDOWS} var ! nSize: DWORD; begin nSize := MAX_COMPUTERNAME_LENGTH + 1; SetLength(Result, nSize); ! if Windows.GetComputerName( ! PChar(Result), // address of name buffer ! nSize) then // address of size of name buffer SetLength(Result, nSize) else Result := ''; end; - {$ENDIF MSWINDOWS} - {$IFDEF LINUX} - begin - SetLength(Result, 255); - if gethostname(PChar(Result), Length(Result)) = -1 then - Result := '' - else - SetLength(Result, StrLen(PChar(Result))); - end; - {$ENDIF LINUX} function StrToBool(const S: string): Boolean; --- 2535,2553 ---- function GetComputerName: string; var ! nSize: Cardinal; begin nSize := MAX_COMPUTERNAME_LENGTH + 1; SetLength(Result, nSize); ! {$IFDEF MSWINDOWS} ! if Windows.GetComputerName(PChar(Result), nSize) then ! {$ENDIF MSWINDOWS} ! {$IFDEF LINUX} ! if QWindows.GetComputerName(PChar(Result), nSize) then ! {$ENDIF LINUX} SetLength(Result, nSize) else Result := ''; end; function StrToBool(const S: string): Boolean; *************** *** 3037,3041 **** function TextWidth(const AStr: string): Integer; - {$IFDEF VCL} var Canvas: TCanvas; --- 3041,3044 ---- *************** *** 3047,3051 **** --- 3050,3058 ---- Canvas.Handle := DC; Result := Canvas.TextWidth(AStr); + {$IFDEF VCL} Canvas.Handle := 0; + {$ELSE} + Canvas.Handle := nil; + {$ENDIF VCL} finally ReleaseDC(HWND_DESKTOP, DC); *************** *** 3053,3069 **** end; end; - {$ENDIF VCL} - {$IFDEF VisualCLX} - var - Bmp: TBitmap; - begin - Bmp := TBitmap.Create; - try - Result := Bmp.Canvas.TextWidth(AStr); - finally - Bmp.Free; - end; - end; - {$ENDIF VisualCLX} procedure SetChildPropOrd(Owner: TComponent; const PropName: string; Value: Longint); --- 3060,3063 ---- *************** *** 3611,3614 **** --- 3605,3609 ---- { Real-size icons support routines } + {$ENDIF VCL} const *************** *** 3660,3667 **** DC, Mem1, Mem2: HDC; Old1, Old2: HBITMAP; ! Bitmap: Windows.TBitmap; begin ! Mem1 := CreateCompatibleDC(0); ! Mem2 := CreateCompatibleDC(0); GetObject(Src, SizeOf(Bitmap), @Bitmap); if Mono then --- 3655,3662 ---- DC, Mem1, Mem2: HDC; Old1, Old2: HBITMAP; ! Bitmap: tagBITMAP; begin ! Mem1 := CreateCompatibleDC(NullHandle); ! Mem2 := CreateCompatibleDC(NullHandle); GetObject(Src, SizeOf(Bitmap), @Bitmap); if Mono then *************** *** 3670,3678 **** begin DC := GetDC(0); ! if DC = 0 then OutOfResources; try Result := CreateCompatibleBitmap(DC, Size.X, Size.Y); ! if Result = 0 then OutOfResources; finally --- 3665,3673 ---- begin DC := GetDC(0); ! if DC = NullHandle then OutOfResources; try Result := CreateCompatibleBitmap(DC, Size.X, Size.Y); ! if Result = NullHandle then OutOfResources; finally *************** *** 3680,3692 **** end; end; ! if Result <> 0 then begin Old1 := SelectObject(Mem1, Src); Old2 := SelectObject(Mem2, Result); StretchBlt(Mem2, 0, 0, Size.X, Size.Y, Mem1, 0, 0, Bitmap.bmWidth, ! Bitmap.bmHeight, SrcCopy); ! if Old1 <> 0 then SelectObject(Mem1, Old1); ! if Old2 <> 0 then SelectObject(Mem2, Old2); end; --- 3675,3687 ---- end; end; ! if Result <> NullHandle then begin Old1 := SelectObject(Mem1, Src); Old2 := SelectObject(Mem2, Result); StretchBlt(Mem2, 0, 0, Size.X, Size.Y, Mem1, 0, 0, Bitmap.bmWidth, ! Bitmap.bmHeight, SRCCOPY); ! if Old1 <> NullHandle then SelectObject(Mem1, Old1); ! if Old2 <> NullHandle then SelectObject(Mem2, Old2); end; *************** *** 3706,3710 **** Colors: PLongArray; IconSize: TPoint; ! BM: Windows.TBitmap; begin IconSize.X := GetSystemMetrics(SM_CXICON); --- 3701,3705 ---- Colors: PLongArray; IconSize: TPoint; ! BM: tagBITMAP; begin IconSize.X := GetSystemMetrics(SM_CXICON); *************** *** 3717,3726 **** end; DC := GetDC(0); ! if DC = 0 then OutOfResources; try Bits := Pointer(Longint(@BI) + SizeOf(BI) + NumColors * SizeOf(TRGBQuad)); Temp := CreateDIBitmap(DC, BI, CBM_INIT, Bits, PBitmapInfo(@BI)^, DIB_RGB_COLORS); ! if Temp = 0 then OutOfResources; try --- 3712,3721 ---- end; DC := GetDC(0); ! if DC = NullHandle then OutOfResources; try Bits := Pointer(Longint(@BI) + SizeOf(BI) + NumColors * SizeOf(TRGBQuad)); Temp := CreateDIBitmap(DC, BI, CBM_INIT, Bits, PBitmapInfo(@BI)^, DIB_RGB_COLORS); ! if Temp = NullHandle then OutOfResources; try *************** *** 3744,3748 **** Colors^[1] := $FFFFFF; Temp := CreateDIBitmap(DC, BI, CBM_INIT, Bits, PBitmapInfo(@BI)^, DIB_RGB_COLORS); ! if Temp = 0 then OutOfResources; try --- 3739,3743 ---- Colors^[1] := $FFFFFF; Temp := CreateDIBitmap(DC, BI, CBM_INIT, Bits, PBitmapInfo(@BI)^, DIB_RGB_COLORS); ! if Temp = NullHandle then OutOfResources; try *************** *** 3782,3786 **** IconSize.Y := GetSystemMetrics(SM_CYICON); DC := GetDC(0); ! if DC = 0 then OutOfResources; try --- 3777,3781 ---- IconSize.Y := GetSystemMetrics(SM_CYICON); DC := GetDC(0); ! if DC = NullHandle then OutOfResources; try *************** *** 3862,3865 **** --- 3857,3861 ---- end; + {$IFDEF VCL} procedure GetIconSize(Icon: HIcon; var W, H: Integer); var *************** *** 7416,7424 **** end; - procedure Beep; - begin - MessageBeep(0); - end; - procedure FreeUnusedOle; begin --- 7412,7415 ---- *************** *** 7427,7430 **** --- 7418,7426 ---- {$ENDIF MSWINDOWS} + procedure Beep; + begin + MessageBeep(0); + end; + {$IFDEF MSWINDOWS} function GetEnvVar(const VarName: string): string; *************** *** 7953,7957 **** PostQuitMessage(M.WParam); end; - {$ENDIF VCL} --- 7949,7952 ---- Index: JvProgressComponent.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvProgressComponent.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** JvProgressComponent.pas 9 Jan 2004 01:06:05 -0000 1.8 --- JvProgressComponent.pas 9 Jan 2004 21:37:59 -0000 1.9 *************** *** 84,88 **** uses ! JvConsts, JvResources; const --- 84,88 ---- uses ! JvConsts, JvResources, JvJCLUtils; const *************** *** 101,137 **** procedure CMShowEvent(var Msg: TCMShowEvent); message CM_SHOWEVENT; end; - - function ChangeTopException(E: TObject): TObject; - type - PRaiseFrame = ^TRaiseFrame; - TRaiseFrame = record - NextRaise: PRaiseFrame; - ExceptAddr: Pointer; - ExceptObject: TObject; - //ExceptionRecord: PExceptionRecord; - end; - begin - { C++ Builder 3 Warning !} - { if linker error occured with message "unresolved external 'System::RaiseList'" try - comment this function implementation, compile, - then uncomment and compile again. } - {$IFDEF MSWINDOWS} - {$IFDEF COMPILER6_UP} - {$WARN SYMBOL_DEPRECATED OFF} - {$ENDIF} - if RaiseList <> nil then - begin - Result := PRaiseFrame(RaiseList)^.ExceptObject; - PRaiseFrame(RaiseList)^.ExceptObject := E - end - else - Result := nil; - {$ENDIF MSWINDOWS} - {$IFDEF LINUX} - // XXX: changing exception in stack frame is not supported on Kylix - Writeln('ChangeTopException'); - Result := E; - {$ENDIF LINUX} - end; //=== TJvProgressComponent =================================================== --- 101,104 ---- |