mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 07:49:33 +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
lcl/interfaces/win32
@ -2478,35 +2478,6 @@ begin
|
||||
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
|
||||
Params: window_hnd - handle of window for timer message, not set in this implementation
|
||||
|
@ -46,19 +46,31 @@ type
|
||||
end;
|
||||
PNMCustomDraw=^TNMCustomDraw;
|
||||
|
||||
TNMLVCustomDraw = Record
|
||||
hdr : NMHDR;
|
||||
dwDrawStage : DWORD;
|
||||
hdc : HDC;
|
||||
rc : TRECT;
|
||||
dwItemSpec : DWORD;
|
||||
uItemState : UINT;
|
||||
lItemlParam : longint;
|
||||
clrText,clrTextBk:COLORREF;
|
||||
iSubItem :longint;
|
||||
END;
|
||||
TNMLVCustomDraw = record
|
||||
hdr : NMHDR;
|
||||
dwDrawStage : DWORD;
|
||||
hdc : HDC;
|
||||
rc : TRECT;
|
||||
dwItemSpec : DWORD;
|
||||
uItemState : UINT;
|
||||
lItemlParam : longint;
|
||||
clrText,clrTextBk:COLORREF;
|
||||
iSubItem :longint;
|
||||
end;
|
||||
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 }
|
||||
const
|
||||
{ Recommended modal-dialog style }
|
||||
@ -248,6 +260,7 @@ const
|
||||
// load dynamic and use ownfunction if not defined
|
||||
var
|
||||
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
|
||||
// ComCtlVersions
|
||||
@ -405,15 +418,19 @@ end;
|
||||
|
||||
const
|
||||
msimg32lib = 'msimg32.dll';
|
||||
user32lib = 'user32.dll';
|
||||
|
||||
var
|
||||
msimg32handle: THandle = 0;
|
||||
user32handle: THandle = 0;
|
||||
|
||||
procedure Initialize;
|
||||
var
|
||||
p: Pointer;
|
||||
begin
|
||||
AlphaBlend := @_AlphaBlend;
|
||||
GetComboBoxInfo := nil;
|
||||
|
||||
msimg32handle := LoadLibrary(msimg32lib);
|
||||
if msimg32handle <> 0
|
||||
then begin
|
||||
@ -421,14 +438,28 @@ begin
|
||||
if p <> nil
|
||||
then Pointer(AlphaBlend) := p;
|
||||
end;
|
||||
|
||||
user32handle := LoadLibrary(user32lib);
|
||||
if user32handle <> 0 then
|
||||
begin
|
||||
p := GetProcAddress(user32handle, 'GetComboBoxInfo');
|
||||
if p <> nil then
|
||||
Pointer(GetComboboxInfo) := p;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Finalize;
|
||||
begin
|
||||
AlphaBlend := @_AlphaBlend;
|
||||
GetComboboxInfo := nil;
|
||||
|
||||
if msimg32handle <> 0
|
||||
then FreeLibrary(msimg32handle);
|
||||
msimg32handle := 0;
|
||||
|
||||
if user32handle <> 0 then
|
||||
FreeLibrary(user32handle);
|
||||
user32handle := 0;
|
||||
end;
|
||||
|
||||
initialization
|
||||
@ -437,4 +468,4 @@ initialization
|
||||
finalization
|
||||
Finalize;
|
||||
|
||||
End.
|
||||
end.
|
||||
|
@ -248,8 +248,6 @@ var
|
||||
|
||||
function WindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||
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;
|
||||
LParam: Windows.LParam): LResult;
|
||||
|
||||
|
@ -37,7 +37,7 @@ uses
|
||||
Themes,
|
||||
////////////////////////////////////////////////////
|
||||
WSStdCtrls, WSLCLClasses, WSProc, Windows, LCLType,
|
||||
Win32Int, Win32Proc, InterfaceBase, Win32WSControls;
|
||||
Win32Int, Win32Proc, InterfaceBase, Win32WSControls, Win32Extra;
|
||||
|
||||
type
|
||||
|
||||
@ -316,6 +316,37 @@ const
|
||||
|
||||
{$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 }
|
||||
|
||||
class function TWin32WSScrollBar.CreateHandle(const AWinControl: TWinControl;
|
||||
@ -694,7 +725,7 @@ begin
|
||||
with Params do
|
||||
begin
|
||||
Flags := Flags or CalcComboBoxWinFlags(TCustomComboBox(AWinControl));
|
||||
If TComboBox(AWinControl).Sorted Then
|
||||
if TComboBox(AWinControl).Sorted Then
|
||||
Flags:= Flags or CBS_SORT;
|
||||
pClassName := 'COMBOBOX';
|
||||
Flags := Flags or (WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS);
|
||||
@ -711,13 +742,17 @@ begin
|
||||
Buddy := Windows.GetTopWindow(Window);
|
||||
// If the style is CBS_DROPDOWNLIST, GetTopWindow returns null,
|
||||
// because the combobox has no edit in that case.
|
||||
if Buddy<>HWND(nil) then begin
|
||||
if Buddy <> HWND(nil) then
|
||||
begin
|
||||
SubClassWndProc := @WindowProc;
|
||||
WindowCreateInitBuddy(AWinControl, Params);
|
||||
BuddyWindowInfo^.isChildEdit := true;
|
||||
BuddyWindowInfo^.isComboEdit := true;
|
||||
end else BuddyWindowInfo:=nil;
|
||||
end
|
||||
else
|
||||
BuddyWindowInfo:=nil;
|
||||
end;
|
||||
|
||||
Result := Params.Window;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user