mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 17:20:37 +02:00
win32:
- move ComboBoxWindowProc from win32callback.inc to Win32WSStdCtrls - declare GetComboBoxInfo method in win32extra (this functions can be used to get listox and edit handles from combobox) git-svn-id: trunk@12289 -
This commit is contained in:
parent
c874dadef0
commit
9aca1999ae
@ -2478,35 +2478,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: ComboBoxWindowProc
|
|
||||||
Params: Window - The window that receives a message
|
|
||||||
Msg - The message received
|
|
||||||
WParam - Word parameter
|
|
||||||
LParam - Long-integer parameter
|
|
||||||
Returns: 0 if Msg is handled; non-zero long-integer result otherwise
|
|
||||||
|
|
||||||
Handles the messages sent to a combobox control by Windows or other
|
|
||||||
applications
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function ComboBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
|
||||||
LParam: Windows.LParam): LResult; stdcall;
|
|
||||||
begin
|
|
||||||
// darn MS: if combobox has edit control, and combobox receives focus, it
|
|
||||||
// passes it on to the edit, so it will send a WM_KILLFOCUS; inhibit
|
|
||||||
// also don't pass WM_SETFOCUS to the lcl,
|
|
||||||
// it will get one from the edit control
|
|
||||||
if ((Msg = WM_KILLFOCUS) or (Msg = WM_SETFOCUS)) and
|
|
||||||
(Windows.GetTopWindow(Window) <> HWND(nil)) then
|
|
||||||
begin
|
|
||||||
// continue normal processing, don't send to lcl
|
|
||||||
Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
|
|
||||||
end else begin
|
|
||||||
// normal processing
|
|
||||||
Result := WindowProc(Window, Msg, WParam, LParam);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Procedure: TimerCallBackProc
|
Procedure: TimerCallBackProc
|
||||||
Params: window_hnd - handle of window for timer message, not set in this implementation
|
Params: window_hnd - handle of window for timer message, not set in this implementation
|
||||||
|
@ -46,7 +46,7 @@ type
|
|||||||
end;
|
end;
|
||||||
PNMCustomDraw=^TNMCustomDraw;
|
PNMCustomDraw=^TNMCustomDraw;
|
||||||
|
|
||||||
TNMLVCustomDraw = Record
|
TNMLVCustomDraw = record
|
||||||
hdr : NMHDR;
|
hdr : NMHDR;
|
||||||
dwDrawStage : DWORD;
|
dwDrawStage : DWORD;
|
||||||
hdc : HDC;
|
hdc : HDC;
|
||||||
@ -56,9 +56,21 @@ type
|
|||||||
lItemlParam : longint;
|
lItemlParam : longint;
|
||||||
clrText,clrTextBk:COLORREF;
|
clrText,clrTextBk:COLORREF;
|
||||||
iSubItem :longint;
|
iSubItem :longint;
|
||||||
END;
|
end;
|
||||||
PNMLVCustomDraw=^TNMLVCustomDraw;
|
PNMLVCustomDraw=^TNMLVCustomDraw;
|
||||||
|
|
||||||
|
tagCOMBOBOXINFO = record
|
||||||
|
cbSize: DWORD;
|
||||||
|
rcItem: TRect;
|
||||||
|
rcButton: TRect;
|
||||||
|
stateButton: DWORD;
|
||||||
|
hwndCombo: HWND;
|
||||||
|
hwndItem: HWND;
|
||||||
|
hwndList: HWND;
|
||||||
|
end;
|
||||||
|
TComboboxInfo = tagCOMBOBOXINFO;
|
||||||
|
PComboboxInfo = ^TComboboxInfo;
|
||||||
|
|
||||||
{ Win32 API constants not included in windows.pp }
|
{ Win32 API constants not included in windows.pp }
|
||||||
const
|
const
|
||||||
{ Recommended modal-dialog style }
|
{ Recommended modal-dialog style }
|
||||||
@ -248,6 +260,7 @@ const
|
|||||||
// load dynamic and use ownfunction if not defined
|
// load dynamic and use ownfunction if not defined
|
||||||
var
|
var
|
||||||
AlphaBlend: function(hdcDest: HDC; nXOriginDest, nYOriginDest, nWidthDest, nHeightDest: Integer; hdcSrc: HDC; nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc: Integer; blendFunction: TBlendFunction): BOOL; stdcall;
|
AlphaBlend: function(hdcDest: HDC; nXOriginDest, nYOriginDest, nWidthDest, nHeightDest: Integer; hdcSrc: HDC; nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc: Integer; blendFunction: TBlendFunction): BOOL; stdcall;
|
||||||
|
GetComboBoxInfo: function(hwndCombo: HWND; pcbi: PComboboxInfo): BOOL; stdcall;
|
||||||
|
|
||||||
const
|
const
|
||||||
// ComCtlVersions
|
// ComCtlVersions
|
||||||
@ -405,15 +418,19 @@ end;
|
|||||||
|
|
||||||
const
|
const
|
||||||
msimg32lib = 'msimg32.dll';
|
msimg32lib = 'msimg32.dll';
|
||||||
|
user32lib = 'user32.dll';
|
||||||
|
|
||||||
var
|
var
|
||||||
msimg32handle: THandle = 0;
|
msimg32handle: THandle = 0;
|
||||||
|
user32handle: THandle = 0;
|
||||||
|
|
||||||
procedure Initialize;
|
procedure Initialize;
|
||||||
var
|
var
|
||||||
p: Pointer;
|
p: Pointer;
|
||||||
begin
|
begin
|
||||||
AlphaBlend := @_AlphaBlend;
|
AlphaBlend := @_AlphaBlend;
|
||||||
|
GetComboBoxInfo := nil;
|
||||||
|
|
||||||
msimg32handle := LoadLibrary(msimg32lib);
|
msimg32handle := LoadLibrary(msimg32lib);
|
||||||
if msimg32handle <> 0
|
if msimg32handle <> 0
|
||||||
then begin
|
then begin
|
||||||
@ -421,14 +438,28 @@ begin
|
|||||||
if p <> nil
|
if p <> nil
|
||||||
then Pointer(AlphaBlend) := p;
|
then Pointer(AlphaBlend) := p;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
user32handle := LoadLibrary(user32lib);
|
||||||
|
if user32handle <> 0 then
|
||||||
|
begin
|
||||||
|
p := GetProcAddress(user32handle, 'GetComboBoxInfo');
|
||||||
|
if p <> nil then
|
||||||
|
Pointer(GetComboboxInfo) := p;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Finalize;
|
procedure Finalize;
|
||||||
begin
|
begin
|
||||||
AlphaBlend := @_AlphaBlend;
|
AlphaBlend := @_AlphaBlend;
|
||||||
|
GetComboboxInfo := nil;
|
||||||
|
|
||||||
if msimg32handle <> 0
|
if msimg32handle <> 0
|
||||||
then FreeLibrary(msimg32handle);
|
then FreeLibrary(msimg32handle);
|
||||||
msimg32handle := 0;
|
msimg32handle := 0;
|
||||||
|
|
||||||
|
if user32handle <> 0 then
|
||||||
|
FreeLibrary(user32handle);
|
||||||
|
user32handle := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
@ -437,4 +468,4 @@ initialization
|
|||||||
finalization
|
finalization
|
||||||
Finalize;
|
Finalize;
|
||||||
|
|
||||||
End.
|
end.
|
||||||
|
@ -248,8 +248,6 @@ var
|
|||||||
|
|
||||||
function WindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
function WindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||||
LParam: Windows.LParam): LResult; stdcall;
|
LParam: Windows.LParam): LResult; stdcall;
|
||||||
function ComboBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
|
||||||
LParam: Windows.LParam): LResult; stdcall;
|
|
||||||
function CallDefaultWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
function CallDefaultWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||||
LParam: Windows.LParam): LResult;
|
LParam: Windows.LParam): LResult;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ uses
|
|||||||
Themes,
|
Themes,
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLType,
|
WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLType,
|
||||||
Win32Int, Win32Proc, InterfaceBase, Win32WSControls;
|
Win32Int, Win32Proc, InterfaceBase, Win32WSControls, Win32Extra;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -316,6 +316,37 @@ const
|
|||||||
|
|
||||||
{$I win32memostrings.inc}
|
{$I win32memostrings.inc}
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: ComboBoxWindowProc
|
||||||
|
Params: Window - The window that receives a message
|
||||||
|
Msg - The message received
|
||||||
|
WParam - Word parameter
|
||||||
|
LParam - Long-integer parameter
|
||||||
|
Returns: 0 if Msg is handled; non-zero long-integer result otherwise
|
||||||
|
|
||||||
|
Handles the messages sent to a combobox control by Windows or other
|
||||||
|
applications
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
function ComboBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||||
|
LParam: Windows.LParam): LResult; stdcall;
|
||||||
|
begin
|
||||||
|
// darn MS: if combobox has edit control, and combobox receives focus, it
|
||||||
|
// passes it on to the edit, so it will send a WM_KILLFOCUS; inhibit
|
||||||
|
// also don't pass WM_SETFOCUS to the lcl,
|
||||||
|
// it will get one from the edit control
|
||||||
|
|
||||||
|
if ((Msg = WM_KILLFOCUS) or (Msg = WM_SETFOCUS)) and
|
||||||
|
(Windows.GetTopWindow(Window) <> HWND(nil)) then
|
||||||
|
begin
|
||||||
|
// continue normal processing, don't send to lcl
|
||||||
|
Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
// normal processing
|
||||||
|
Result := WindowProc(Window, Msg, WParam, LParam);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWin32WSScrollBar }
|
{ TWin32WSScrollBar }
|
||||||
|
|
||||||
class function TWin32WSScrollBar.CreateHandle(const AWinControl: TWinControl;
|
class function TWin32WSScrollBar.CreateHandle(const AWinControl: TWinControl;
|
||||||
@ -694,7 +725,7 @@ begin
|
|||||||
with Params do
|
with Params do
|
||||||
begin
|
begin
|
||||||
Flags := Flags or CalcComboBoxWinFlags(TCustomComboBox(AWinControl));
|
Flags := Flags or CalcComboBoxWinFlags(TCustomComboBox(AWinControl));
|
||||||
If TComboBox(AWinControl).Sorted Then
|
if TComboBox(AWinControl).Sorted Then
|
||||||
Flags:= Flags or CBS_SORT;
|
Flags:= Flags or CBS_SORT;
|
||||||
pClassName := 'COMBOBOX';
|
pClassName := 'COMBOBOX';
|
||||||
Flags := Flags or (WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS);
|
Flags := Flags or (WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS);
|
||||||
@ -711,13 +742,17 @@ begin
|
|||||||
Buddy := Windows.GetTopWindow(Window);
|
Buddy := Windows.GetTopWindow(Window);
|
||||||
// If the style is CBS_DROPDOWNLIST, GetTopWindow returns null,
|
// If the style is CBS_DROPDOWNLIST, GetTopWindow returns null,
|
||||||
// because the combobox has no edit in that case.
|
// because the combobox has no edit in that case.
|
||||||
if Buddy<>HWND(nil) then begin
|
if Buddy <> HWND(nil) then
|
||||||
|
begin
|
||||||
SubClassWndProc := @WindowProc;
|
SubClassWndProc := @WindowProc;
|
||||||
WindowCreateInitBuddy(AWinControl, Params);
|
WindowCreateInitBuddy(AWinControl, Params);
|
||||||
BuddyWindowInfo^.isChildEdit := true;
|
BuddyWindowInfo^.isChildEdit := true;
|
||||||
BuddyWindowInfo^.isComboEdit := true;
|
BuddyWindowInfo^.isComboEdit := true;
|
||||||
end else BuddyWindowInfo:=nil;
|
end
|
||||||
|
else
|
||||||
|
BuddyWindowInfo:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := Params.Window;
|
Result := Params.Window;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user