diff --git a/source/console/Console.h b/source/console/Console.h index c124e6a7f..32edf9c10 100644 --- a/source/console/Console.h +++ b/source/console/Console.h @@ -81,7 +81,7 @@ struct TConsoleCommStruct bool Error; // TRANSFERIN only }; - size_t Size; + unsigned int Size; int Version; enum { NONE, PRINT, INPUT, CHOICE, TITLE, INIT, PROGRESS, TRANSFEROUT, TRANSFERIN } Event; diff --git a/source/core/Security.cpp b/source/core/Security.cpp index 40122bb73..0556bfc3b 100644 --- a/source/core/Security.cpp +++ b/source/core/Security.cpp @@ -162,14 +162,11 @@ bool WindowsValidateCertificate(const unsigned char * Certificate, size_t Len, U CERT_CHAIN_ENGINE_CONFIG ChainConfig; memset(&ChainConfig, 0, sizeof(ChainConfig)); - const size_t ChainConfigSize = - reinterpret_cast(&ChainConfig.CycleDetectionModulus) + sizeof(ChainConfig.CycleDetectionModulus) - - reinterpret_cast(&ChainConfig); // The hExclusiveRoot and hExclusiveTrustedPeople were added in Windows 7. // The CertGetCertificateChain fails with E_INVALIDARG when we include them to ChainConfig.cbSize. // The dwExclusiveFlags was added in Windows 8 + const size_t ChainConfigSize = RTL_SIZEOF_THROUGH_FIELD(CERT_CHAIN_ENGINE_CONFIG, CycleDetectionModulus); DebugAssert(ChainConfigSize == 40); - DebugAssert(ChainConfigSize == sizeof(CERT_CHAIN_ENGINE_CONFIG) - sizeof(ChainConfig.hExclusiveRoot) - sizeof(ChainConfig.hExclusiveTrustedPeople) - sizeof(ChainConfig.dwExclusiveFlags)); ChainConfig.cbSize = ChainConfigSize; ChainConfig.hRestrictedRoot = NULL; ChainConfig.hRestrictedTrust = NULL; diff --git a/source/filezilla/FileZillaIntf.cpp b/source/filezilla/FileZillaIntf.cpp index ac5a6bec9..3ce5447d8 100644 --- a/source/filezilla/FileZillaIntf.cpp +++ b/source/filezilla/FileZillaIntf.cpp @@ -226,7 +226,7 @@ bool __fastcall TFileZillaIntf::FileTransfer( Transfer.server = *FServer; // 1 = ascii, 2 = binary Transfer.nType = Type; - Transfer.nUserData = reinterpret_cast(UserData); + Transfer.nUserData = reinterpret_cast(UserData); Transfer.OnTransferOut = OnTransferOut; Transfer.OnTransferIn = OnTransferIn; diff --git a/source/filezilla/FzApiStructures.h b/source/filezilla/FzApiStructures.h index 4d4ebe4b5..4ee7f83c8 100644 --- a/source/filezilla/FzApiStructures.h +++ b/source/filezilla/FzApiStructures.h @@ -38,7 +38,7 @@ typedef struct __int64 size; t_server server; int nType; - int nUserData; + NativeInt nUserData; TTransferOutEvent OnTransferOut; TTransferInEvent OnTransferIn; } t_transferfile; diff --git a/source/forms/Console.cpp b/source/forms/Console.cpp index 0182552ae..0765574b8 100644 --- a/source/forms/Console.cpp +++ b/source/forms/Console.cpp @@ -276,7 +276,7 @@ void __fastcall TConsoleDialog::DoAdjustWindow() { GetTextMetrics(DC, &TM); - OutputMemo->Perform(EM_GETRECT, 0, reinterpret_cast(&Rect)); + OutputMemo->Perform(EM_GETRECT, 0, reinterpret_cast(&Rect)); } __finally { diff --git a/source/forms/CustomScpExplorer.cpp b/source/forms/CustomScpExplorer.cpp index eb8cec2d4..87682da34 100644 --- a/source/forms/CustomScpExplorer.cpp +++ b/source/forms/CustomScpExplorer.cpp @@ -1924,8 +1924,8 @@ void __fastcall TCustomScpExplorerForm::UpdateHistoryMenu(TOperationSide Side, Data.Index = static_cast(i * (Back ? -1 : 1)); Item->Caption = MinimizeName(DView->HistoryPath[Data.Index], 50, !IsSideLocalBrowser(Side)); Item->Hint = DView->HistoryPath[Data.Index]; - DebugAssert(sizeof(int) == sizeof(THistoryItemData)); - Item->Tag = *reinterpret_cast(&Data); + DebugAssert(sizeof(Item->Tag) >= sizeof(Data)); + Item->Tag = *reinterpret_cast(&Data); Item->OnClick = HistoryItemClick; Menu->Items->Add(Item); } @@ -7565,7 +7565,7 @@ void __fastcall TCustomScpExplorerForm::SessionListChanged(bool ForceTruncationU if (IsSessionTab) { TTerminal * Terminal = Manager->Sessions[Index]; - TabSheet->Tag = reinterpret_cast(Terminal); + TabSheet->Tag = reinterpret_cast(Terminal); TabSheet->CaptionTruncation = WinConfiguration->SessionTabCaptionTruncation ? tttEllipsis : tttNone; UpdateSessionTab(TabSheet); @@ -11391,7 +11391,7 @@ void __fastcall TCustomScpExplorerForm::CreateOpenDirMenuList( Item->Caption = EscapeHotkey(Directory); Item->ShortCut = Bookmark->ShortCut; Item->OnClick = OnBookmarkClick; - Item->Tag = reinterpret_cast(Bookmark); + Item->Tag = reinterpret_cast(Bookmark); Directories->Add(Directory); Menu->Add(Item.release()); } @@ -11435,7 +11435,7 @@ void __fastcall TCustomScpExplorerForm::CreateOpenDirMenuList( Item->Caption = Bookmark->Name; Item->ShortCut = Bookmark->ShortCut; Item->OnClick = OnBookmarkClick; - Item->Tag = reinterpret_cast(Bookmark); + Item->Tag = reinterpret_cast(Bookmark); if (((Bookmark->Name == Bookmark->Local) || (Bookmark->Name == Bookmark->Remote)) && (Bookmark->Local.IsEmpty() || Bookmark->Remote.IsEmpty())) diff --git a/source/forms/Editor.cpp b/source/forms/Editor.cpp index ab0e982b9..8a067bd15 100644 --- a/source/forms/Editor.cpp +++ b/source/forms/Editor.cpp @@ -309,7 +309,7 @@ void __fastcall TEditorRichEdit::WMPaste() { // replacement for EM_PASTESPECIAL, // which ignores trailing line end for some reason - Perform(EM_REPLACESEL, true, reinterpret_cast(Text)); + Perform(EM_REPLACESEL, true, reinterpret_cast(Text)); } __finally { @@ -1537,7 +1537,7 @@ bool __fastcall TEditorForm::CursorInUpperPart() { GetTextMetrics(DC, &TM); - EditorMemo->Perform(EM_GETRECT, 0, reinterpret_cast(&Rect)); + EditorMemo->Perform(EM_GETRECT, 0, reinterpret_cast(&Rect)); } __finally { diff --git a/source/forms/NonVisual.cpp b/source/forms/NonVisual.cpp index a17212ab9..b8c60adc4 100644 --- a/source/forms/NonVisual.cpp +++ b/source/forms/NonVisual.cpp @@ -1567,7 +1567,7 @@ void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Acti DebugAssert(Session != NULL); TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu); Item->Caption = SessionList->Strings[Index]; - Item->Tag = int(Session); + Item->Tag = reinterpret_cast(Session); Item->Hint = FMTLOAD(OPENED_TAB_HINT, (Item->Caption)); Item->Checked = (Manager->ActiveSession == Session); Item->ShortCut = OpenSessionShortCut(Index); @@ -2004,7 +2004,7 @@ void __fastcall TNonVisualDataModule::CreateToolbarButtonsList() Item = new TTBXItem(CustomizeItem); Item->Caption = StripEllipsis(ButtonItem->Caption); Item->ImageIndex = ButtonItem->ImageIndex; - Item->Tag = reinterpret_cast(ButtonItem); + Item->Tag = reinterpret_cast(ButtonItem); Item->OnClick = ToolbarButtonItemClick; Item->Checked = ButtonItem->Visible; } diff --git a/source/forms/SiteAdvanced.cpp b/source/forms/SiteAdvanced.cpp index 40ce1636c..5f85c8f15 100644 --- a/source/forms/SiteAdvanced.cpp +++ b/source/forms/SiteAdvanced.cpp @@ -806,7 +806,7 @@ void __fastcall TSiteAdvancedDialog::UpdateNavigationTree() } Node->Text = Label; - Node->SelectedIndex = reinterpret_cast(Tab); + Node->Data = Tab; PrevNode = Node; if (PageControl->ActivePage == Tab) { @@ -1155,7 +1155,7 @@ void __fastcall TSiteAdvancedDialog::NavigationTreeChange(TObject * /*Sender*/, { TAutoNestingCounter Guard(NoUpdate); - TTabSheet * Tab = reinterpret_cast(Node->SelectedIndex); + TTabSheet * Tab = static_cast(Node->Data); // should happen only while loading language // (UpdateNavigationTree may not be called yet) if (Tab != NULL) @@ -1186,8 +1186,7 @@ void __fastcall TSiteAdvancedDialog::PageChanged() { for (int Index = 0; Index < NavigationTree->Items->Count; Index++) { - if (NavigationTree->Items->Item[Index]->SelectedIndex == - reinterpret_cast(PageControl->ActivePage)) + if (NavigationTree->Items->Item[Index]->Data == PageControl->ActivePage) { NavigationTree->Items->Item[Index]->Selected = true; Found = true; diff --git a/source/packages/dragndrop/DragDrop.pas b/source/packages/dragndrop/DragDrop.pas index b65cdb50d..a59c97a12 100644 --- a/source/packages/dragndrop/DragDrop.pas +++ b/source/packages/dragndrop/DragDrop.pas @@ -1858,16 +1858,16 @@ begin (not FMessageHooked) and ((FSourceEffects <> 0) or (FTargetEffects <> 0)) then begin WndProcPtr := MakeObjectInstance(WndMethod); - OldWndProc := Pointer(SetWindowLong(FDragDropControl.Handle, GWL_WNDPROC, LongInt(WndProcPtr))); + OldWndProc := Pointer(SetWindowLongPtr(FDragDropControl.Handle, GWLP_WNDPROC, NativeInt(WndProcPtr))); FMessageHooked := True; end; end; procedure TDragDrop.UnhookMessageHandler(ForceUnhook: Boolean); begin - if FMessageHooked and (ForceUnhook or ((FSourceEffects=0) and (FTargetEffects=0))) then + if FMessageHooked and (ForceUnhook or ((FSourceEffects = 0) and (FTargetEffects = 0))) then begin - SetWindowLong(FDragDropControl.Handle, GWL_WNDPROC, LongInt(OldWndProc)); + SetWindowLongPtr(FDragDropControl.Handle, GWLP_WNDPROC, NativeInt(OldWndProc)); FreeObjectInstance(WndProcPtr); WndProcPtr := nil; OldWndProc := nil; diff --git a/source/packages/filemng/CustomDirView.pas b/source/packages/filemng/CustomDirView.pas index 22c96ba50..40623c3d6 100644 --- a/source/packages/filemng/CustomDirView.pas +++ b/source/packages/filemng/CustomDirView.pas @@ -2162,7 +2162,7 @@ begin try Screen.Cursor := crHourglass; FNotifyEnabled := False; - CustomSort(SortProc, Integer(Pointer(Self))); + CustomSort(SortProc, NativeInt(Self)); finally Screen.Cursor := SavedCursor; FNotifyEnabled := SavedNotifyEnabled; diff --git a/source/packages/my/CompThread.pas b/source/packages/my/CompThread.pas index 44ef4e52e..e40010273 100644 --- a/source/packages/my/CompThread.pas +++ b/source/packages/my/CompThread.pas @@ -81,7 +81,7 @@ begin end; end; -function ThreadWndProc(Window: HWND; Message, wParam, lParam: Longint): Longint; stdcall; +function ThreadWndProc(Window: HWND; Message: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; begin case Message of CM_EXECPROC: @@ -305,7 +305,7 @@ procedure TCompThread.Synchronize(Method: TThreadMethod); begin FSynchronizeException := nil; FMethod := Method; - SendMessage(ThreadWindow, CM_EXECPROC, 0, Longint(Self)); + SendMessage(ThreadWindow, CM_EXECPROC, 0, LPARAM(Self)); if Assigned(FSynchronizeException) then raise FSynchronizeException; end; diff --git a/source/packages/my/UpDownEdit.pas b/source/packages/my/UpDownEdit.pas index baa048387..c527e4384 100644 --- a/source/packages/my/UpDownEdit.pas +++ b/source/packages/my/UpDownEdit.pas @@ -414,7 +414,7 @@ begin SetRect(Loc, GetButtonWidth + 1, 0, ClientWidth - 1, ClientHeight + 1) else SetRect(Loc, 0, 0, ClientWidth - GetButtonWidth - 2, ClientHeight + 1); - SendMessage(Handle, EM_SETRECTNP, 0, Longint(@Loc)); + SendMessage(Handle, EM_SETRECTNP, 0, LPARAM(@Loc)); end; procedure TUpDownEdit.SetAlignment(Value: TAlignment); diff --git a/source/packages/tb2k/TB2Common.pas b/source/packages/tb2k/TB2Common.pas index d72b8b3e2..ccc3e2ef3 100644 --- a/source/packages/tb2k/TB2Common.pas +++ b/source/packages/tb2k/TB2Common.pas @@ -33,7 +33,7 @@ uses type TListSortExCompare = function(const Item1, Item2, ExtraData: Pointer): Integer; - THandleWMPrintNCPaintProc = procedure(Control: TControl; Wnd: HWND; DC: HDC; AppData: Longint); + THandleWMPrintNCPaintProc = procedure(Control: TControl; Wnd: HWND; DC: HDC; AppData: NativeUInt); function AddToFrontOfList(var List: TList; Item: Pointer): Boolean; function AddToList(var List: TList; Item: Pointer): Boolean; @@ -61,7 +61,7 @@ function GetRectOfPrimaryMonitor(const WorkArea: Boolean): TRect; function GetTextHeight(const DC: HDC): Integer; function GetTextWidth(const DC: HDC; S: String; const Prefix: Boolean): Integer; procedure HandleWMPrint(Control: TControl; const Wnd: HWND; var Message: TMessage; - const NCPaintFunc: THandleWMPrintNCPaintProc; const AppData: Longint); + const NCPaintFunc: THandleWMPrintNCPaintProc; const AppData: NativeUInt); procedure HandleWMPrintClient(const Control: TWinControl; var Message: TMessage); procedure ListSortEx(const List: TList; const Compare: TListSortExCompare; @@ -168,7 +168,7 @@ begin end; procedure HandleWMPrint(Control: TControl; const Wnd: HWND; var Message: TMessage; - const NCPaintFunc: THandleWMPrintNCPaintProc; const AppData: Longint); + const NCPaintFunc: THandleWMPrintNCPaintProc; const AppData: NativeUInt); { note: AppData is an application-defined value which is passed to NCPaintFunc } var DC: HDC; diff --git a/source/packages/tb2k/TB2Dock.pas b/source/packages/tb2k/TB2Dock.pas index ccc216e88..a6f5e88c9 100644 --- a/source/packages/tb2k/TB2Dock.pas +++ b/source/packages/tb2k/TB2Dock.pas @@ -1759,14 +1759,14 @@ begin DrawNCArea(False, 0, HRGN(Message.WParam)); end; -procedure DockNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: Longint); +procedure DockNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: NativeUInt); begin TTBDock(AppData).DrawNCArea(True, DC, 0); end; procedure TTBDock.WMPrint(var Message: TMessage); begin - HandleWMPrint(Self, Handle, Message, DockNCPaintProc, Longint(Self)); + HandleWMPrint(Self, Handle, Message, DockNCPaintProc, NativeUInt(Self)); end; procedure TTBDock.WMPrintClient(var Message: TMessage); @@ -2051,7 +2051,7 @@ begin DrawNCArea(False, 0, HRGN(Message.WParam), twrdAll); end; -procedure FloatingWindowParentNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: Longint); +procedure FloatingWindowParentNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: NativeUInt); begin with TTBFloatingWindowParent(AppData) do DrawNCArea(True, DC, 0, twrdAll); @@ -2059,7 +2059,7 @@ end; procedure TTBFloatingWindowParent.WMPrint(var Message: TMessage); begin - HandleWMPrint(Self, Handle, Message, FloatingWindowParentNCPaintProc, Longint(Self)); + HandleWMPrint(Self, Handle, Message, FloatingWindowParentNCPaintProc, NativeUInt(Self)); end; procedure TTBFloatingWindowParent.WMPrintClient(var Message: TMessage); @@ -3489,7 +3489,7 @@ begin DrawNCArea(False, 0, HRGN(Message.WParam)); end; -procedure DockableWindowNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: Longint); +procedure DockableWindowNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: NativeUInt); begin with TTBCustomDockableWindow(AppData) do DrawNCArea(True, DC, 0) @@ -3497,7 +3497,7 @@ end; procedure TTBCustomDockableWindow.WMPrint(var Message: TMessage); begin - HandleWMPrint(Self, Handle, Message, DockableWindowNCPaintProc, Longint(Self)); + HandleWMPrint(Self, Handle, Message, DockableWindowNCPaintProc, NativeUInt(Self)); end; procedure TTBCustomDockableWindow.WMPrintClient(var Message: TMessage); diff --git a/source/packages/tb2k/TB2Item.pas b/source/packages/tb2k/TB2Item.pas index b48b2bbe3..630371d3a 100644 --- a/source/packages/tb2k/TB2Item.pas +++ b/source/packages/tb2k/TB2Item.pas @@ -3596,7 +3596,7 @@ end; function TTBView.HandleWMGetObject(var Message: TMessage): Boolean; begin - if (Message.LParam = Integer(OBJID_CLIENT)) then begin + if (Integer(Message.LParam) = Integer(OBJID_CLIENT)) then begin Message.Result := LresultFromObject(ITBAccessible, Message.WParam, GetAccObject); Result := True; end @@ -6688,7 +6688,7 @@ begin inherited; end; -procedure PopupWindowNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: Longint); +procedure PopupWindowNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: NativeUInt); var R: TRect; {$IFNDEF TB2K_USE_STRICT_O2K_MENU_STYLE} @@ -6722,7 +6722,7 @@ begin DC := GetWindowDC(Handle); try SelectNCUpdateRgn(Handle, DC, HRGN(Message.WParam)); - PopupWindowNCPaintProc(Self, Handle, DC, Longint(Self)); + PopupWindowNCPaintProc(Self, Handle, DC, NativeUInt(Self)); finally ReleaseDC(Handle, DC); end; @@ -6730,7 +6730,7 @@ end; procedure TTBPopupWindow.WMPrint(var Message: TMessage); begin - HandleWMPrint(Self, Handle, Message, PopupWindowNCPaintProc, Longint(Self)); + HandleWMPrint(Self, Handle, Message, PopupWindowNCPaintProc, NativeUInt(Self)); end; procedure TTBPopupWindow.WMPrintClient(var Message: TMessage); diff --git a/source/packages/tbx/TBX.pas b/source/packages/tbx/TBX.pas index 65c966fe5..c635184c2 100644 --- a/source/packages/tbx/TBX.pas +++ b/source/packages/tbx/TBX.pas @@ -2306,7 +2306,7 @@ begin Message.Result := 1; end; -procedure TBXPopupNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: Longint); +procedure TBXPopupNCPaintProc(Control: TControl; Wnd: HWND; DC: HDC; AppData: NativeUInt); var R, R2: TRect; Canvas: TCanvas; @@ -2367,7 +2367,7 @@ begin try Assert(DC <> 0, 'TTBXPopupWindow.WMNCPaint'); SelectNCUpdateRgn(Handle, DC, HRGN(Message.WParam)); - TBXPopupNCPaintProc(Self, Handle, DC, LongInt(Self.View)); + TBXPopupNCPaintProc(Self, Handle, DC, NativeUInt(Self.View)); finally ReleaseDC(Handle, DC); end; @@ -2375,7 +2375,7 @@ end; procedure TTBXPopupWindow.WMPrint(var Message: TMessage); begin - HandleWMPrint(Self, Handle, Message, TBXPopupNCPaintProc, LongInt(Self.View)); + HandleWMPrint(Self, Handle, Message, TBXPopupNCPaintProc, NativeUInt(Self.View)); end; procedure TTBXPopupWindow.WMTB2kPopupShowing(var Message: TMessage); diff --git a/source/windows/UserInterface.cpp b/source/windows/UserInterface.cpp index 3c257bdc1..3f3419f7e 100644 --- a/source/windows/UserInterface.cpp +++ b/source/windows/UserInterface.cpp @@ -1035,7 +1035,7 @@ void __fastcall CreateColorPalette(TTBCustomItem * Owner, TColor Color, int Rows ColorSet->ColCount = ColorCols; ColorSet->RowCount = Rows; ColorSet->OnGetColorInfo = OnGetColorInfo; - ColorSet->Tag = static_cast(SessionColors); + ColorSet->Tag = static_cast(SessionColors); } // clNone = no selection, see also ColorChange diff --git a/source/windows/VCLCommon.cpp b/source/windows/VCLCommon.cpp index db02dd13b..26eac3cd4 100644 --- a/source/windows/VCLCommon.cpp +++ b/source/windows/VCLCommon.cpp @@ -753,7 +753,7 @@ static void __fastcall FormShowingChanged(TForm * Form, TWndMethod WndProc, TMes { Form->Caption = FormatFormCaption(Form, Form->Caption); } - SendMessage(Form->Handle, WM_SETICON, ICON_BIG, reinterpret_cast(Application->Icon->Handle)); + SendMessage(Form->Handle, WM_SETICON, ICON_BIG, reinterpret_cast(Application->Icon->Handle)); } else { @@ -2100,7 +2100,7 @@ void __fastcall InvokeHelp(TWinControl * Control) HelpInfo.dwContextId = 0; HelpInfo.MousePos.x = 0; HelpInfo.MousePos.y = 0; - SendMessage(Control->Handle, WM_HELP, NULL, reinterpret_cast(&HelpInfo)); + SendMessage(Control->Handle, WM_HELP, NULL, reinterpret_cast(&HelpInfo)); } //--------------------------------------------------------------------------- //---------------------------------------------------------------------------