On Wed, 19 Apr 2006 12:37:36 +0330, roozbeh gholizadeh <[EMAIL PROTECTED]> wrote:


This patch fixes some bugs,button captions are working now,tstatictext is
also working!

well  saw other peaple pasted patch in text message so here it is again


Index: wincecallback.inc
===================================================================
--- wincecallback.inc   (revision 9144)
+++ wincecallback.inc   (working copy)
@@ -863,14 +863,15 @@
     End;
     WM_CLOSE:
     Begin
-      if (Window = TWinCEWidgetSet(WidgetSet).AppHandle) and
-        (Application.MainForm <> nil) then
+//      if (Window = TWinCEWidgetSet(WidgetSet).AppHandle) and
+//        (Application.MainForm <> nil) then
       begin
+        Windows.SendMessage(Application.MainForm.Handle, WM_CLOSE, 0, 0);
         Application.Terminate;
-// Windows.SendMessage(Application.MainForm.Handle, WM_CLOSE, 0, 0);
-      end else begin
-        LMessage.Msg := LM_CLOSEQUERY;
       end;
+//      else begin
+//        LMessage.Msg := LM_CLOSEQUERY;
+//      end;
       // default is to destroy window, inhibit
       WinProcess := false;
     End;
Index: winceint.pp
===================================================================
--- winceint.pp (revision 9144)
+++ winceint.pp (working copy)
@@ -152,6 +152,7 @@
     Procedure AttachMenuToWindow(AMenuObject: TComponent); override;
     procedure AppRun(const ALoop: TApplicationMainLoop); override;

+
     // create and destroy
     function CreateComponent(Sender : TObject): THandle; override;
function CreateTimer(Interval: integer; TimerFunc: TFNTimerProc) : integer; override;
@@ -218,7 +219,7 @@
 // WinCEWSGrids,
 // WinCEWSImgList,
 // WinCEWSMaskEdit,
-// WinCEWSMenus,
+// WinCEWSMenus,//roozbeh:not yet ready for use!
 // WinCEWSPairSplitter,
 // WinCEWSSpin,
  WinCEWSStdCtrls,
Index: winceobject.inc
===================================================================
--- winceobject.inc     (revision 9144)
+++ winceobject.inc     (working copy)
@@ -195,8 +195,18 @@
 end;

 procedure TWinCEWidgetSet.AttachMenuToWindow(AMenuObject: TComponent);
+var
+  AMenu: TMenu;
+  AWinControl: TWinControl;
 begin
-  inherited AttachMenuToWindow(AMenuObject);
+  AMenu := AMenuObject as TMenu;
+  if AMenu is TMainMenu then
+  begin
+    AWinControl := TWinControl(AMenu.Owner);
+//roozbeh this is somehow very difficut to achieve for now!
+//    Windows.SetMenu(AWinControl.Handle, AMenu.Handle);
+    AddToChangedMenus(AWinControl.Handle);
+  end;
 end;

 function TWinCEWidgetSet.CreateComponent(Sender: TObject): THandle;
Index: winceproc.pp
===================================================================
--- winceproc.pp        (revision 9144)
+++ winceproc.pp        (working copy)
@@ -63,6 +63,14 @@
 procedure DisableApplicationWindows(Window: HWND);
 procedure EnableApplicationWindows(Window: HWND);

+procedure AddToChangedMenus(Window: HWnd);
+
+//roozbeh:this thing belong to windows unit...someone should move them there! +function GetTextExtentPoint(DC: HDC; Str: PWideChar; Count: Integer; var Size: TSize): BOOL; +function GetTextExtentPoint32(DC: HDC; Str: PWideChar; Count: Integer; var Size: TSize): BOOL;
+function SysAllocStringLen(psz:pointer;len:dword):pointer;
+procedure SysFreeString(bstr:pointer);
+
 type
   PDisableWindowsInfo = ^TDisableWindowsInfo;
   TDisableWindowsInfo = record
@@ -72,14 +80,26 @@

 var
   DefaultWindowInfo: TWindowInfo;
+  ChangedMenus: TList; // list of HWNDs which menus needs to be redrawn

+
 implementation

 uses
   SysUtils, LCLStrConsts, Dialogs, StdCtrls, ExtCtrls,
   LCLIntf; //remove this unit when GetWindowSize is moved to TWSWinControl

-//roozbeh:should these be here?why not in windows or...?
+function GetTextExtentPoint(DC: HDC; Str: PWideChar; Count: Integer; var Size: TSize): BOOL;
+begin
+Windows.GetTextExtentExPoint(dc, Str, Count, 0, nil, nil, @Size);
+end;
+
+function GetTextExtentPoint32(DC: HDC; Str: PWideChar; Count: Integer; var Size: TSize): BOOL;
+begin
+GetTextExtentPoint(dc, Str, Count, Size);
+end;
+
+
 function SysAllocStringLen(psz:pointer;len:dword):pointer;stdcall;
  external 'oleaut32.dll' name 'SysAllocStringLen';

@@ -605,6 +625,36 @@
   end;
 end;

+
+{-------------------------------------------------------------------------------
+  procedure AddToChangedMenus(Window: HWnd);
+
+  Adds Window to the list of windows which need to redraw the main menu.
+-------------------------------------------------------------------------------}
+procedure AddToChangedMenus(Window: HWnd);
+begin
+ if ChangedMenus.IndexOf(Pointer(Window)) = -1 then // Window handle is not yet in the list
+    ChangedMenus.Add(Pointer(Window));
+end;
+
+{------------------------------------------------------------------------------
+  Method: RedrawMenus
+  Params:  None
+  Returns: Nothing
+
+  Redraws all changed menus
+ 
------------------------------------------------------------------------------}
+{procedure RedrawMenus;
+var
+  I: integer;
+begin
+  for I := 0 to  ChangedMenus.Count - 1 do
+    DrawMenuBar(HWND(ChangedMenus[I]));
+  ChangedMenus.Clear;
+end;}
+
+
+
 initialization
   New(ThePropertyLists);
   ThePropertyLists^.WindowInfo := 0;
Index: wincewinapi.inc
===================================================================
--- wincewinapi.inc     (revision 9144)
+++ wincewinapi.inc     (working copy)
@@ -912,6 +912,10 @@
   Result := Windows.GetTextColor(DC);
 End;

+function TWinCEWidgetSet.UpdateWindow(Handle: HWND): Boolean;
+begin
+Result := Windows.UpdateWindow(Handle);
+end;
 {------------------------------------------------------------------------------
   Method:  GetTextExtentPoint
   Params:  DC    - handle of device context
@@ -923,7 +927,6 @@

   Computes the width and height of the specified string of text.
  
------------------------------------------------------------------------------}
-//function GetTextExtentPoint32W(DC: HDC; Str: LPWSTR; Count: Integer; var Size: TSize): BOOL; external 'KernelDLL' name 'GetTextExtentPoint32W';

Function TWinCEWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; Var Size: TSize): Boolean;
 var
@@ -931,7 +934,6 @@
 Begin
   Assert(False, 'Trace:[TWinCEWidgetSet.GetTextExtentPoint] - Start');
   Result := false;
-  //roozbeh:why compiler error...not found?!
   WideStr := CreatePWideCharFromString(String(Str));
Result := Boolean(Windows.GetTextExtentExPoint(DC, WideStr, Count, 0,nil,nil,@Size));
   DisposePWideChar(WideStr);
Index: wincewinapih.inc
===================================================================
--- wincewinapih.inc    (revision 9144)
+++ wincewinapih.inc    (working copy)
@@ -136,6 +136,7 @@
 function GetSysColor(nIndex: Integer): DWORD; override;
 function GetSystemMetrics(nIndex: Integer): Integer;  override;
 function GetTextColor(DC: HDC) : TColorRef; Override;
+function UpdateWindow(Handle: HWND): Boolean;override;
function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override;
 function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;  override;
 Function GetWindowLong(Handle : hwnd; int: Integer): PtrInt; override;
Index: wincewsbuttons.pp
===================================================================
--- wincewsbuttons.pp   (revision 9144)
+++ wincewsbuttons.pp   (working copy)
@@ -115,8 +115,6 @@
   FinishCreateWindow(AWinControl, Params, false);
   Result := Params.Window;

-// MultiByteToWideChar(CP_ACP, 0, PChar(AWinControl.Caption), -1, @Str, 256);
-
   {$ifdef VerboseWinCE}
   WriteLn('End Create Button. Handle = ' + IntToStr(Result) +
    ' Left ' + IntToStr(AWinControl.Left) +
@@ -142,8 +140,13 @@
   Returns: Nothing
  
------------------------------------------------------------------------------}
class function TWinCEWSButton.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
+var
+tmpStr : PWideChar;
 begin
-  Result := True;
+  tmpstr := SysAllocStringLen(nil,256);
+  Result := Boolean(Windows.GetWindowText(AWinControl.Handle,tmpStr,256));
+  AText := String(tmpStr);
+  SysFreeString(tmpStr);
 end;

 {------------------------------------------------------------------------------
@@ -152,7 +155,12 @@
   Returns: Nothing
  
------------------------------------------------------------------------------}
class procedure TWinCEWSButton.SetText(const AWinControl: TWinControl; const AText: String);
+var
+tmpStr : PWideChar;
 begin
+ tmpstr := CreatePWideCharFromString(AText);
+ Windows.SetWindowText(AWinControl.Handle,tmpStr);
+ DisposePWideChar(tmpStr);
 end;

 initialization
Index: wincewscontrols.pp
===================================================================
--- wincewscontrols.pp  (revision 9144)
+++ wincewscontrols.pp  (working copy)
@@ -169,9 +169,9 @@
     if AWinControl.Parent <> nil then
     begin
       Parent := AWinControl.Parent.Handle;
-    end;
-    //else
-    //  Parent := TWinCEWidgetSet(WidgetSet).AppHandle;
+    end
+    else
+      Parent := TWinCEWidgetSet(WidgetSet).AppHandle;

     SubClassWndProc := @WindowProc;
     WindowTitle := nil;
@@ -303,7 +303,9 @@
 var
   Params: TCreateWindowExParams;
 begin
+  {$ifdef VerboseWinCE}
   writeln(' TWinCEWSWinControl.CreateHandle ');
+  {$endif}
   // general initialization of Params
   PrepareCreateWindow(AWinControl, Params);
   // customization of Params
@@ -322,14 +324,14 @@
 var
   ParentPanelHandle, ParentHandle, ChildHandle: HWND;
 begin
-(*  {$ifdef OldToolbar}
+  {$ifdef OldToolbar}
   if (AControl.Parent is TToolbar) then
     exit;
   {$endif}

   with TWinControl(AControl) do
   begin
- Assert(False, Format('Trace:[TWin32WSWinControl.AddControl] %S --> Calling Add Child: %S', [Parent.ClassName, ClassName])); + Assert(False, Format('Trace:[TWinCEWSWinControl.AddControl] %S --> Calling Add Child: %S', [Parent.ClassName, ClassName]));
     ParentHandle := Parent.Handle;
     ChildHandle := Handle;
   end;
@@ -340,7 +342,7 @@
   ParentPanelHandle := GetWindowInfo(ChildHandle)^.ParentPanel;
   if ParentPanelHandle <> 0 then
     ChildHandle := ParentPanelHandle;
-  SetParent(ChildHandle, ParentHandle);*)
+  SetParent(ChildHandle, ParentHandle);
 end;

function TWinCEWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
Index: wincewsstdctrls.pp
===================================================================
--- wincewsstdctrls.pp  (revision 9144)
+++ wincewsstdctrls.pp  (working copy)
@@ -405,8 +405,6 @@
function TWinCEWSCustomStaticText.CreateHandle(const AWinControl: TWinControl;
   const AParams: TCreateParams): HWND;
 var
-  hwnd: THandle;
-  Str: array[0..255] of WideChar;
   Params: TCreateWindowExParams;
 begin
   {$ifdef VerboseWinCE}
@@ -421,7 +419,7 @@
   begin
     pClassName := @LabelClsName;
WindowTitle := CreatePWideCharFromString(AWinControl.Caption);//roozbeh..we already have this in strcaptiob..whats the diffrence? - Flags := Flags or CalcStaticTextFlags(TCustomStaticText(AWinControl).Alignment);//is ws_child included? + Flags := WS_CHILD or WS_VISIBLE or WS_TABSTOP or SS_LEFT;//Flags or CalcStaticTextFlags(TCustomStaticText(AWinControl).Alignment);//is ws_child included?
   end;

   // create window
@@ -460,7 +458,7 @@
 //  RegisterWSComponent(TCheckBox, TWinCEWSCheckBox);
 //  RegisterWSComponent(TToggleBox, TWinCEWSToggleBox);
   RegisterWSComponent(TRadioButton, TWinCEWSRadioButton);
-//  RegisterWSComponent(TCustomStaticText, TWinCEWSCustomStaticText);
-  RegisterWSComponent(TStaticText, TWinCEWSStaticText);
+  RegisterWSComponent(TCustomStaticText, TWinCEWSCustomStaticText);
+//  RegisterWSComponent(TStaticText, TWinCEWSStaticText);
 ////////////////////////////////////////////////////
 end.

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to