applied menu fix from Micha Nelissen

git-svn-id: trunk@4301 -
This commit is contained in:
mattias 2003-06-24 08:32:03 +00:00
parent d98a5ac0ca
commit 6bb58b5c11

View File

@ -109,7 +109,7 @@ Begin
Assert(False, 'Trace:Win32Object.Init - Toolbar button Register Failed'); Assert(False, 'Trace:Win32Object.Init - Toolbar button Register Failed');
Exit; Exit;
End; End;
FToolTipWindow := CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nil, WS_POPUP Or TTS_NOPREFIX Or TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, FParentWindow, HMENU(nil), HInstance, nil); FToolTipWindow := CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nil, WS_POPUP Or TTS_NOPREFIX Or TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, FParentWindow, HMENU(nil), HInstance, nil);
Windows.SendMessage(FParentWindow, TTM_ACTIVATE, WPARAM(True), 0); Windows.SendMessage(FParentWindow, TTM_ACTIVATE, WPARAM(True), 0);
@ -126,9 +126,9 @@ Begin
end; end;
Assert(False,'Trace:FTimerWindow: ' + IntToStr(FTimerWindow)); Assert(False,'Trace:FTimerWindow: ' + IntToStr(FTimerWindow));
//Init stock objects; //Init stock objects;
LogBrush.lbStyle := BS_NULL; LogBrush.lbStyle := BS_NULL;
FStockNullBrush := CreateBrushIndirect(LogBrush); FStockNullBrush := CreateBrushIndirect(LogBrush);
LogBrush.lbStyle := BS_SOLID; LogBrush.lbStyle := BS_SOLID;
LogBrush.lbColor := $000000; LogBrush.lbColor := $000000;
FStockBlackBrush := CreateBrushIndirect(LogBrush); FStockBlackBrush := CreateBrushIndirect(LogBrush);
LogBrush.lbColor := $C0C0C0; LogBrush.lbColor := $C0C0C0;
@ -182,7 +182,7 @@ Begin
StrDispose(Caption); StrDispose(Caption);
End; End;
csPage: csPage:
Begin Begin
Assert(False, 'Trace:TWin32Object.GetText - csPage: Start'); Assert(False, 'Trace:TWin32Object.GetText - csPage: Start');
Ctrl := ((Sender As TPage).Parent As TNotebook); Ctrl := ((Sender As TPage).Parent As TNotebook);
Caption := StrAlloc(MAX_PATH); Caption := StrAlloc(MAX_PATH);
@ -227,18 +227,18 @@ Procedure TWin32Object.SetLabel(Sender: TObject; Data: Pointer);
cbsize:=sizeof(MENUITEMINFO); cbsize:=sizeof(MENUITEMINFO);
{In Win32 Menu items that are created without a initial caption default to disabled, {In Win32 Menu items that are created without a initial caption default to disabled,
the next three lines are to counter that.} the next three lines are to counter that.}
fMask:=MIIM_STATE; fMask:=MIIM_STATE or MIIM_TYPE or MIIM_ID;
GetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle), false, @MenuInfo); GetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle) and $FFFF, false, @MenuInfo);
if (Sender as TMenuItem).Enabled then fState := fState and (not (MFS_DISABLED or MFS_GRAYED)); if (Sender as TMenuItem).Enabled then fState := fState and (not (MFS_DISABLED or MFS_GRAYED));
fMask:=MIIM_TYPE or MIIM_STATE; fMask:=MIIM_TYPE or MIIM_STATE;
fType:=Style; fType:=Style;
dwTypeData:=Data; dwTypeData:=Data;
end; end;
SetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle), false, @MenuInfo); SetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle) and $FFFF, false, @MenuInfo);
DrawMenuBar(((Sender as TMenuItem).Owner as TWinControl).Handle); DrawMenuBar(((Sender as TMenuItem).Owner as TWinControl).Handle);
End; End;
Var Var
Handle, HOwner: HWnd; Handle, HOwner: HWnd;
R: TRect; R: TRect;
@ -260,7 +260,7 @@ Begin
HOwner := GetAncestor(Handle, GA_ROOTOWNER); HOwner := GetAncestor(Handle, GA_ROOTOWNER);
Assert(Handle<>0,'Trace:WARNING: [TWin32Object.SetLabel] --> Got NULL handle'); Assert(Handle<>0,'Trace:WARNING: [TWin32Object.SetLabel] --> Got NULL handle');
Assert(False, 'Trace:Setting the label in TWin32Object.SetLabel'); Assert(False, 'Trace:Setting the label in TWin32Object.SetLabel');
Case TControl(Sender).FCompStyle Of Case TControl(Sender).FCompStyle Of
csBitBtn: csBitBtn:
IntSendMessage3(LM_IMAGECHANGED, Sender, Nil); IntSendMessage3(LM_IMAGECHANGED, Sender, Nil);
@ -335,7 +335,7 @@ End;
Data - pointer to message-specific data (optional) Data - pointer to message-specific data (optional)
Returns: depends on the message and the sender Returns: depends on the message and the sender
Processes messages from different components. Processes messages from different components.
WARNING: the result of this function sometimes is not always really an WARNING: the result of this function sometimes is not always really an
integer!!!!! integer!!!!!
@ -402,7 +402,7 @@ Begin
PLMScreenInit(Data)^.PixelsPerInchY := GetDeviceCaps(DC, LogPixelsY); PLMScreenInit(Data)^.PixelsPerInchY := GetDeviceCaps(DC, LogPixelsY);
PLMScreenInit(Data)^.ColorDepth := GetDeviceCaps(DC, BitsPixel); PLMScreenInit(Data)^.ColorDepth := GetDeviceCaps(DC, BitsPixel);
ReleaseDC(Handle, DC); ReleaseDC(Handle, DC);
End; End;
LM_LOADXPM: LM_LOADXPM:
Begin Begin
If (Sender is TBitmap) Then If (Sender is TBitmap) Then
@ -436,10 +436,10 @@ Begin
//TWinControl(Sender).Handle := Handle; //TWinControl(Sender).Handle := Handle;
//Assert(False, Format('Trace:[TWin32Object.IntSendMessag3] Sender is %S', [Sender.ClassName])); //Assert(False, Format('Trace:[TWin32Object.IntSendMessag3] Sender is %S', [Sender.ClassName]));
Exit; Exit;
End; End;
Case LM_Message of Case LM_Message of
LM_SETTEXT: LM_SETTEXT:
SetText(Handle, Data); SetText(Handle, Data);
LM_ADDCHILD: LM_ADDCHILD:
Begin Begin
Assert(False, 'Trace:Adding a child to Parent'); Assert(False, 'Trace:Adding a child to Parent');
@ -519,7 +519,7 @@ Begin
End; End;
LM_DESTROY: LM_DESTROY:
Begin Begin
If (Sender Is TWinControl) Or (Sender Is TCommonDialog) Then If (Sender Is TWinControl) Or (Sender Is TCommonDialog) Then
Begin Begin
If Handle <> 0 Then If Handle <> 0 Then
DestroyWindow(Handle); DestroyWindow(Handle);
@ -553,23 +553,23 @@ Begin
Assert(False, 'Trace:********************'); Assert(False, 'Trace:********************');
End; End;
{Displays a menu and makes it available for selection. Applications can use this function to display context-sensitive menus, {Displays a menu and makes it available for selection. Applications can use this function to display context-sensitive menus,
and will typically supply NULL for the parent_menu_shell, parent_menu_item, func and data parameters. and will typically supply NULL for the parent_menu_shell, parent_menu_item, func and data parameters.
The default menu positioning function will position the menu at the current pointer position. The default menu positioning function will position the menu at the current pointer position.
menu : a GtkMenu. menu : a GtkMenu.
parent_menu_shell : the menu shell containing the triggering menu item. parent_menu_shell : the menu shell containing the triggering menu item.
parent_menu_item : the menu item whose activation triggered the popup. parent_menu_item : the menu item whose activation triggered the popup.
func : a user supplied function used to position the menu. func : a user supplied function used to position the menu.
data : user supplied data to be passed to func. data : user supplied data to be passed to func.
button : the button which was pressed to initiate the event. button : the button which was pressed to initiate the event.
activate_time : the time at which the activation event occurred. activate_time : the time at which the activation event occurred.
} }
LM_POPUPSHOW: LM_POPUPSHOW:
Begin Begin
SetProp(((Sender as TPopupMenu).Owner as TWinControl).Handle, 'PopupMenu', Pointer((Sender as TPopupMenu).Handle)); SetProp(((Sender as TPopupMenu).Owner as TWinControl).Handle, 'PopupMenu', Pointer((Sender as TPopupMenu).Handle));
TrackPopupMenuEx((Sender as TPopupMenu).Handle, TPM_LEFTALIGN or TPM_LEFTBUTTON or TPM_RIGHTBUTTON, TPoint(Data^).x, TPoint(Data^).y, ((Sender as TPopupMenu).Owner as TWinControl).Handle, Nil); TrackPopupMenuEx((Sender as TPopupMenu).Handle, TPM_LEFTALIGN or TPM_LEFTBUTTON or TPM_RIGHTBUTTON, TPoint(Data^).x, TPoint(Data^).y, ((Sender as TPopupMenu).Owner as TWinControl).Handle, Nil);
End; End;
LM_SETFILTER: LM_SETFILTER:
Begin Begin
PStr := StrAlloc(Length(TFileDialog(Sender).Filter) + 1); PStr := StrAlloc(Length(TFileDialog(Sender).Filter) + 1);
Try Try
StrPCopy(PStr, TFileDialog(Sender).Filter); StrPCopy(PStr, TFileDialog(Sender).Filter);
@ -578,9 +578,9 @@ activate_time : the time at which the activation event occurred.
Finally Finally
StrDispose(pStr); StrDispose(pStr);
End; End;
End; End;
LM_SETFILENAME: LM_SETFILENAME:
Begin Begin
PStr := StrAlloc(Length(TFileDialog(Sender).FileName) + 1); PStr := StrAlloc(Length(TFileDialog(Sender).FileName) + 1);
Try Try
StrPCopy(PStr, TFileDialog(Sender).FileName); StrPCopy(PStr, TFileDialog(Sender).FileName);
@ -589,7 +589,7 @@ activate_time : the time at which the activation event occurred.
Finally Finally
StrDispose(pStr); StrDispose(pStr);
End; End;
End; End;
LM_SETFOCUS: LM_SETFOCUS:
Begin Begin
If Handle <> 0 Then If Handle <> 0 Then
@ -648,10 +648,10 @@ activate_time : the time at which the activation event occurred.
Result := -1; Result := -1;
End; End;
//SH: think of TCanvas.handle!!!! //SH: think of TCanvas.handle!!!!
LM_REDRAW: LM_REDRAW:
Begin Begin
Assert(False, Format('Trace:[TWin32Object.IntSendMessage3] %S --> Redraw', [Sender.ClassName])); Assert(False, Format('Trace:[TWin32Object.IntSendMessage3] %S --> Redraw', [Sender.ClassName]));
If Sender Is TCanvas Then If Sender Is TCanvas Then
ReDraw(TCanvas(Sender)) ReDraw(TCanvas(Sender))
Else If Not (Sender Is TSpeedbutton) Then Else If Not (Sender Is TSpeedbutton) Then
ReDraw(Sender) ReDraw(Sender)
@ -711,13 +711,13 @@ activate_time : the time at which the activation event occurred.
StrPCopy(PStr, TToolButton(Sender).Caption); StrPCopy(PStr, TToolButton(Sender).Caption);
PStr2 := StrAlloc(Length(TControl(Sender).Hint) + 1); PStr2 := StrAlloc(Length(TControl(Sender).Hint) + 1);
StrPCopy(PStr2, TControl(Sender).Hint); StrPCopy(PStr2, TControl(Sender).Hint);
End End
Else Else
Begin Begin
Raise Exception.Create('Can not assign this control to the toolbar'); Raise Exception.Create('Can not assign this control to the toolbar');
Exit; Exit;
End; End;
Num := TToolbar(TWinControl(Sender).Parent).Buttonlist.IndexOf(TControl(Sender)); Num := TToolbar(TWinControl(Sender).Parent).Buttonlist.IndexOf(TControl(Sender));
If Num < 0 Then If Num < 0 Then
Num := TToolbar(TWinControl(Sender).Parent).Buttonlist.Count + 1; Num := TToolbar(TWinControl(Sender).Parent).Buttonlist.Count + 1;
@ -747,8 +747,8 @@ activate_time : the time at which the activation event occurred.
Begin Begin
SendMessage((Sender As TWinControl).Parent.Handle, TB_DELETEBUTTON, 0, 0); SendMessage((Sender As TWinControl).Parent.Handle, TB_DELETEBUTTON, 0, 0);
End; End;
LM_INVALIDATE: LM_INVALIDATE:
Begin Begin
Assert(False, 'Trace:Trying to invalidate window... !!!'); Assert(False, 'Trace:Trying to invalidate window... !!!');
GetClientRect(Handle, R); GetClientRect(Handle, R);
InvalidateRect(Handle, @R, True); InvalidateRect(Handle, @R, True);
@ -763,11 +763,11 @@ activate_time : the time at which the activation event occurred.
Begin Begin
Data := TWin32CListStringList.Create(Handle,TControl(Sender)); Data := TWin32CListStringList.Create(Handle,TControl(Sender));
Result := Integer(Data); Result := Integer(Data);
End End
Else Else
Begin Begin
Data := TWin32ListStringList.Create(Handle,TControl(Sender)); Data := TWin32ListStringList.Create(Handle,TControl(Sender));
Result := Integer(Data); Result := Integer(Data);
End; End;
End; End;
LM_GETTEXT : LM_GETTEXT :
@ -777,7 +777,7 @@ activate_time : the time at which the activation event occurred.
LM_GETITEMINDEX : LM_GETITEMINDEX :
Begin Begin
Case (Sender as TControl).FCompStyle Of Case (Sender as TControl).FCompStyle Of
csListBox, csCListBox: csListBox, csCListBox:
Begin Begin
Result := SendMessage(Handle, LB_GETCURSEL, 0, 0); Result := SendMessage(Handle, LB_GETCURSEL, 0, 0);
If Result = LB_ERR Then If Result = LB_ERR Then
@ -791,7 +791,7 @@ activate_time : the time at which the activation event occurred.
TLMNotebookEvent(Data^).Page := SendMessage(Handle, TCM_GETCURSEL, 0, 0); TLMNotebookEvent(Data^).Page := SendMessage(Handle, TCM_GETCURSEL, 0, 0);
End; End;
End; End;
End; End;
LM_SETITEMINDEX : LM_SETITEMINDEX :
Begin Begin
Case (Sender as TControl).FCompStyle Of Case (Sender as TControl).FCompStyle Of
@ -817,12 +817,12 @@ activate_time : the time at which the activation event occurred.
end; end;
End; End;
End; End;
End; End;
LM_GETSELSTART: LM_GETSELSTART:
Begin Begin
If (Sender as TControl).FCompStyle = csComboBox Then If (Sender as TControl).FCompStyle = csComboBox Then
Begin Begin
Result := Low(SendMessage(Handle, CB_GETEDITSEL, WPARAM(nil), LPARAM(nil))); Result := Low(SendMessage(Handle, CB_GETEDITSEL, WPARAM(nil), LPARAM(nil)));
End; End;
End; End;
LM_GETSELLEN: LM_GETSELLEN:
@ -840,11 +840,11 @@ activate_time : the time at which the activation event occurred.
Result := Integer(GetProp(Handle, 'LIMIT_TEXT')); Result := Integer(GetProp(Handle, 'LIMIT_TEXT'));
End; End;
End; End;
LM_SETSELSTART: LM_SETSELSTART:
Begin Begin
If (Sender Is TControl) And (TControl(Sender).FCompStyle = csComboBox) Then If (Sender Is TControl) And (TControl(Sender).FCompStyle = csComboBox) Then
SendMessage(Handle, CB_SETEDITSEL, 0, MakeLParam(Word(Integer(Data)), -1)); SendMessage(Handle, CB_SETEDITSEL, 0, MakeLParam(Word(Integer(Data)), -1));
End; End;
LM_SETSELLEN: LM_SETSELLEN:
Begin Begin
If (Sender Is TControl) And (TControl(Sender).FCompStyle = csComboBox) Then If (Sender Is TControl) And (TControl(Sender).FCompStyle = csComboBox) Then
@ -888,25 +888,25 @@ activate_time : the time at which the activation event occurred.
End; End;
LM_SETSEL: LM_SETSEL:
Begin Begin
If (Sender is TControl) And (TControl(Sender).FCompStyle In [csListBox, csCListBox]) And Assigned(Data) Then If (Sender is TControl) And (TControl(Sender).FCompStyle In [csListBox, csCListBox]) And Assigned(Data) Then
Begin Begin
If TControl(Sender).FCompStyle = csListBox Then If TControl(Sender).FCompStyle = csListBox Then
Begin Begin
If TLMSetSel(Data^).Selected Then If TLMSetSel(Data^).Selected Then
SendMessage(Handle, LB_SELITEMRANGE, WParam(True), MakeLParam(0, 0)) SendMessage(Handle, LB_SELITEMRANGE, WParam(True), MakeLParam(0, 0))
Else Else
SendMessage(Handle, LB_SELITEMRANGE, WParam(False), MakeLParam(0, 0)); SendMessage(Handle, LB_SELITEMRANGE, WParam(False), MakeLParam(0, 0));
End End
End; End;
End; End;
LM_SETSELMODE: LM_SETSELMODE:
If (Sender is TCustomListBox) And Assigned(data) Then If (Sender is TCustomListBox) And Assigned(data) Then
Begin Begin
//The win32 api doesn't change the selection mode on the fly: it needs recreate the window //The win32 api doesn't change the selection mode on the fly: it needs recreate the window
//RecreateWnd(Sender); -> cause endless loop //RecreateWnd(Sender); -> cause endless loop
//Recreates the window step by step //Recreates the window step by step
If TCustomListBox(Sender).FCompStyle = csListBox Then If TCustomListBox(Sender).FCompStyle = csListBox Then
RecreateListControl(Handle,TControl(Sender),TListBox(Sender).Sorted) RecreateListControl(Handle,TControl(Sender),TListBox(Sender).Sorted)
Else Else
RecreateListControl(Handle,TControl(Sender),TCListBox(Sender).Sorted); RecreateListControl(Handle,TControl(Sender),TCListBox(Sender).Sorted);
@ -964,7 +964,7 @@ Begin
Window := (Sender As TCustomForm).Handle Window := (Sender As TCustomForm).Handle
Else Else
Window := (Sender as TWinControl).Handle; Window := (Sender as TWinControl).Handle;
{$IFDEF VER1_1} {$IFDEF VER1_1}
List := TMsgArray(GetProp(Window, 'MsgList')); List := TMsgArray(GetProp(Window, 'MsgList'));
SetLength(List, Length(List) + 1); SetLength(List, Length(List) + 1);
@ -1065,7 +1065,7 @@ End;
Creates a window again Creates a window again
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Function TWin32Object.RecreateWnd(Sender: TObject): Integer; Function TWin32Object.RecreateWnd(Sender: TObject): Integer;
Var Var
AParent,AWinControl : TWinControl; AParent,AWinControl : TWinControl;
@ -1153,7 +1153,7 @@ end;
Method: TWin32Object.WinRegister Method: TWin32Object.WinRegister
Params: None Params: None
Returns: If the window was successfully regitered Returns: If the window was successfully regitered
Registers the main window class Registers the main window class
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Function TWin32Object.WinRegister: Boolean; Function TWin32Object.WinRegister: Boolean;
@ -1235,7 +1235,7 @@ Begin
DrawIcon(DC, (Surface As TWinControl).Left, (Surface As TWinControl).Top, Pixmap); DrawIcon(DC, (Surface As TWinControl).Left, (Surface As TWinControl).Top, Pixmap);
ReleaseDC((Surface As TWinControl).Handle, DC); ReleaseDC((Surface As TWinControl).Handle, DC);
End; End;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TWin32Object.NormalizeIconName Method: TWin32Object.NormalizeIconName
Params: IconName - The name of the icon to normalize Params: IconName - The name of the icon to normalize
@ -1270,7 +1270,7 @@ End;
Params: Window - The window that has the text to be limited Params: Window - The window that has the text to be limited
Limit - Number of characters to limit the text to Limit - Number of characters to limit the text to
Returns: Nothing Returns: Nothing
Sets the text limit Sets the text limit
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Procedure TWin32Object.SetLimitText(Window: HWND; Limit: Word); Procedure TWin32Object.SetLimitText(Window: HWND; Limit: Word);
@ -1471,7 +1471,7 @@ End;
Returns: Nothing Returns: Nothing
Sets the cursor for a window Sets the cursor for a window
WARNING: Sender will be casted to TControl, CLEANUP! WARNING: Sender will be casted to TControl, CLEANUP!
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Procedure TWin32Object.SetCursor(Sender: TObject); Procedure TWin32Object.SetCursor(Sender: TObject);
@ -1629,7 +1629,7 @@ Begin
Else Else
Parent :=((Sender As TWinControl).Parent As TPage).Parent.Handle; Parent :=((Sender As TWinControl).Parent As TPage).Parent.Handle;
Assert(False, Format('Trace:TWin32Object.CreateComponent - parent handle --> 0x%X', [Parent])); Assert(False, Format('Trace:TWin32Object.CreateComponent - parent handle --> 0x%X', [Parent]));
Assert(False, 'Trace:Setting parent'); Assert(False, 'Trace:Setting parent');
End End
Else Else
@ -2029,7 +2029,7 @@ Begin
End; End;
End; {Case} End; {Case}
If (Sender Is TWinControl) Or (CompStyle = csImage) Then If (Sender Is TWinControl) Or (CompStyle = csImage) Then
Begin Begin
TWinControl(Sender).Handle := Window; TWinControl(Sender).Handle := Window;
If Window <> HWND(Nil) Then If Window <> HWND(Nil) Then
@ -2083,7 +2083,7 @@ End;
Params: Window - The window to assign Params: Window - The window to assign
Data - The data to assign to the window Data - The data to assign to the window
Returns: Nothing Returns: Nothing
Assigns data to a window Assigns data to a window
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TWin32Object.AssignSelf(Window: HWnd; Data: Pointer); procedure TWin32Object.AssignSelf(Window: HWnd; Data: Pointer);
@ -2256,7 +2256,7 @@ Begin
Handle := TWinControl(Sender).Handle; Handle := TWinControl(Sender).Handle;
Assert (Handle = 0, 'Trace:WARNING: TWin32Object.GetValue --> got no window'); Assert (Handle = 0, 'Trace:WARNING: TWin32Object.GetValue --> got no window');
Case TControl(Sender).FCompStyle Of Case TControl(Sender).FCompStyle Of
csTrackbar: csTrackbar:
If (Handle <> HWnd(Nil)) Then If (Handle <> HWnd(Nil)) Then
@ -2323,7 +2323,7 @@ Begin
Handle := TWinControl(Sender).Handle; Handle := TWinControl(Sender).Handle;
If Handle = HWnd(Nil) Then If Handle = HWnd(Nil) Then
Assert (False, 'Trace:WARNING:[TWin32Object.SetValue] --> got no window'); Assert (False, 'Trace:WARNING:[TWin32Object.SetValue] --> got no window');
Case TControl(Sender).FCompStyle Of Case TControl(Sender).FCompStyle Of
csArrow: csArrow:
Begin Begin
@ -2410,7 +2410,7 @@ begin
Handle := TWinControl(Sender).Handle; Handle := TWinControl(Sender).Handle;
If Handle = HWND(Nil) Then If Handle = HWND(Nil) Then
Assert (False, 'Trace:WARNING: [TWin32Object.SetProperties] --> got nil pointer'); Assert (False, 'Trace:WARNING: [TWin32Object.SetProperties] --> got nil pointer');
Case TControl(Sender).FCompStyle Of Case TControl(Sender).FCompStyle Of
csEdit: csEdit:
With (TCustomEdit(Sender)) Do With (TCustomEdit(Sender)) Do
@ -2473,7 +2473,7 @@ begin
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) Or WS_EX_LTRLEADING); SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) Or WS_EX_LTRLEADING);
End; End;
End; End;
If BarShowText Then If BarShowText Then
Begin Begin
SetWindowText(Handle, StrToPChar((Sender As TControl).Caption)); SetWindowText(Handle, StrToPChar((Sender As TControl).Caption));
End End
@ -2497,7 +2497,7 @@ begin
Begin Begin
SendMessage(Handle, UDM_SETPOS, 0, MakeLong(Trunc(TSpinEdit(Sender).Value), 0)); SendMessage(Handle, UDM_SETPOS, 0, MakeLong(Trunc(TSpinEdit(Sender).Value), 0));
End; End;
csTrackbar: csTrackbar:
With(TTrackBar(Sender)) Do With(TTrackBar(Sender)) Do
Begin Begin
SendMessage(Handle, TBM_SETRANGEMAX, WPARAM(True), Max); SendMessage(Handle, TBM_SETRANGEMAX, WPARAM(True), Max);
@ -2536,7 +2536,7 @@ begin
Style := Style Or SS_CENTER; Style := Style Or SS_CENTER;
taRightJustify: taRightJustify:
Style := Style Or SS_CENTER; Style := Style Or SS_CENTER;
Else Else
Style := STYLE Or SS_LEFT; // default, shouldn't happen Style := STYLE Or SS_LEFT; // default, shouldn't happen
End; End;
Case Layout of Case Layout of
@ -2546,7 +2546,7 @@ begin
Style := Style Or BS_VCENTER; Style := Style Or BS_VCENTER;
tlBottom: tlBottom:
Style := Style Or BS_BOTTOM; Style := Style Or BS_BOTTOM;
Else Else
Style := Style Or BS_BOTTOM; //default, shouldn't happen Style := Style Or BS_BOTTOM; //default, shouldn't happen
End; End;
// Experimental wordwrapping support // Experimental wordwrapping support
@ -2566,7 +2566,7 @@ End;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TWin32Object.AttachMenu Method: TWin32Object.AttachMenu
Params: Sender - the lcl object which called this func Params: Sender - the lcl object which called this func
Returns: nothing Returns: nothing
Attaches the calling Menu to its Parent Attaches the calling Menu to its Parent
@ -2581,7 +2581,7 @@ var MenuInfo: MENUITEMINFO;
Msg: TLMShortCut; Msg: TLMShortCut;
Begin Begin
ParentMenuHandle := (Sender as TMenuItem).Parent.Handle; ParentMenuHandle := (Sender as TMenuItem).Parent.Handle;
{Following part fixes the case when an item is added in runtime {Following part fixes the case when an item is added in runtime
but the parent item has not defined the submenu flag (hSubmenu=0) } but the parent item has not defined the submenu flag (hSubmenu=0) }
if (Sender as TMenuItem).Parent.Parent<>nil then if (Sender as TMenuItem).Parent.Parent<>nil then
@ -2591,14 +2591,14 @@ Begin
cbSize:=sizeof(MENUITEMINFO); cbSize:=sizeof(MENUITEMINFO);
fMask:=MIIM_SUBMENU; fMask:=MIIM_SUBMENU;
end; end;
GetMenuItemInfo(ParentOfParent, ParentMenuHandle, false, @MenuInfo); GetMenuItemInfo(ParentOfParent, (ParentMenuHandle) and $FFFF, false, @MenuInfo);
if MenuInfo.hSubmenu=0 then // the parent menu item is not yet defined with submenu flag if MenuInfo.hSubmenu=0 then // the parent menu item is not yet defined with submenu flag
begin begin
MenuInfo.hSubmenu:=ParentMenuHandle; MenuInfo.hSubmenu:=ParentMenuHandle;
SetMenuItemInfo(ParentOfParent, ParentMenuHandle, false, MenuInfo); SetMenuItemInfo(ParentOfParent, Integer(ParentMenuHandle) and $FFFF, false, MenuInfo);
end; end;
end; end;
Mask := MIIM_ID or MIIM_DATA; Mask := MIIM_ID or MIIM_DATA;
if ((Sender as TMenuItem).Count > 0) then Mask := Mask or MIIM_SUBMENU; if ((Sender as TMenuItem).Count > 0) then Mask := Mask or MIIM_SUBMENU;
MenuHandle := (Sender as TMenuItem).Handle; MenuHandle := (Sender as TMenuItem).Handle;
@ -2607,7 +2607,7 @@ Begin
fMask:=Mask; fMask:=Mask;
fType:=Style; fType:=Style;
{fState:=MFS_ENABLED;} {not needed} {fState:=MFS_ENABLED;} {not needed}
wID:=integer(MenuHandle); wID:=integer(MenuHandle) and $FFFF; {value is only 16 bit wide!}
hSubmenu:=MenuHandle; hSubmenu:=MenuHandle;
{hbmpChecked:=0; {hbmpChecked:=0;
hbmpUnchecked:=0;} {not needed} hbmpUnchecked:=0;} {not needed}
@ -2615,7 +2615,7 @@ Begin
{dwTypeData:=LPSTR((Sender as TmenuItem).Caption);} {dwTypeData:=LPSTR((Sender as TmenuItem).Caption);}
{cch:=length((Sender as TMenuItem).Caption);} {not needed} {cch:=length((Sender as TMenuItem).Caption);} {not needed}
end; end;
InsertMenuItem(ParentMenuHandle, 0, false, @MenuInfo); InsertMenuItem(ParentMenuHandle, -1, true, @MenuInfo);
if (Sender as TMenuItem).ShortCut <> 0 then if (Sender as TMenuItem).ShortCut <> 0 then
begin begin
Msg.Handle:=MenuHandle; Msg.Handle:=MenuHandle;
@ -2659,6 +2659,9 @@ End;
{ {
$Log$ $Log$
Revision 1.52 2003/06/24 08:32:03 mattias
applied menu fix from Micha Nelissen
Revision 1.51 2003/03/25 08:12:39 mattias Revision 1.51 2003/03/25 08:12:39 mattias
patch from Martin Smat for menu items and default messages patch from Martin Smat for menu items and default messages
@ -2817,4 +2820,4 @@ End;
+ Initial import + Initial import
} }