

wqmeng
Members-
Content Count
26 -
Joined
-
Last visited
Community Reputation
0 Neutral-
Why TFooBaseClass = class of TFooBase in parameter can not compile, but TClass could?
wqmeng replied to wqmeng's topic in RTL and Delphi Object Pascal
Sorry, Find the problem that the TFooBaseClass = class of TFooBase; Was defined in two units, after delete one, the problem get fixed. Thanks. -
Why TFooBaseClass = class of TFooBase in parameter can not compile, but TClass could?
wqmeng replied to wqmeng's topic in RTL and Delphi Object Pascal
Hello Dave, Thank you, I just create an empty project and add the code above, It could compiles. But in my work project, it use the similar approach, get the error as [dcc32 Error] xxx.pas(517): E2037 Declaration of 'FindIndicatorByClass' differs from previous declaration. Not sure why. -
I have a function which need pass a class referrence in as a parameter. So I have type TFooBase = class; TFooBaseClass = class of TFooBase; TFooA = class(TFooBase) end; TFooB = class(TFooBase) end; //Then in another class type TBar = class public function FindFooByClass(AFooClass: TFooBaseClass): TFooBase; end; implement function TBar.FindFooByClass(AFooClass: TFooBaseClass): TFooBase; Then at the line function TBar.FindFooByClass(AFooClass: TFooBaseClass): TFooBase; Delphi report [dcc32 Error] xxx: E2037 Declaration of 'FindFooByClass' differs from previous declaration, But as you see, the Declaration is same. And if I change TFooBaseClass to be TClass in both the declaration and the implement as function FindFooByClass(AFooClass: TClass): TFooBase; function TBar.FindFooByClass(AFooClass: TClass): TFooBase; Then the source will complile. Just want to know that why TFooBaseClass not work?
-
SetLength of TArray<double> in ASM get strange result
wqmeng replied to wqmeng's topic in RTL and Delphi Object Pascal
Hello, They are 3 differnt 1 D array which passed in as parameters var dst1, dst2, dst3. In asm, I would like to check if the dst1, dst2, dst3 have already set for enough length to hold results get from the srcData. So need Resize dst1, dst2, dst3 if needed. If I setlength of dst1, dst2, dst3 before call the procedure, there will be no problem. If dst1, dst2, dst3 has not setlength of the length is less than srcData, will call the asm code to DynArraySetLength of them, then various exceptions will raise up. I gusss the problem is caused by the DynArraySetLength and fillchar which clear of the wrong memorys. Thank you. -
SetLength of TArray<double> in ASM get strange result
wqmeng posted a topic in RTL and Delphi Object Pascal
SetLength of TArray<double> in ASM get strange result. Hello, I have a procedure which try to setlength for 3 TArray<Double>. But seems cause unexcpeted result. procedure OpArrSSE2(const srcData: TArray<Double>; A1, A2, A3: Integer; var dst1, dst2, dst3: TArray<Double>; var P1, P2, P3: Double; var F1, F2, F3: Double; const B1: Boolean); asm ... // start to setlength of dst1, dst2, dst3. { mov eax, dst1 // dst1 Pointer mov edx, edi call System.@SetLength } // procedure DynArraySetLength(var a: Pointer; typeInfo: Pointer; dimCnt: NativeInt; lengthVec: PNativeint); mov eax, dst1 // dst1 Pointer mov edx, offset TypeInfoArrayDouble // Type info: Get the type information pointer for TArray<Double> mov ecx, 1 // DimCnt (number of dimensions), for a one-dimensional array it's 1 push edi // New length (NativeInt), edi = newlength_value call System.@DynArraySetLength // procedure DynArraySetLength(var a: Pointer; typeInfo: Pointer; dimCnt: NativeInt; lengthVec: PNativeint); add esp, 4 // pop edi // fill 0 mov eax, dst1 // dst1 Pointer -> @dst1[0] mov eax, [eax] // @dst1[0] mov edx, edi // Number of elements shl edx, 3 // Multiply by SizeOf(Double) (which is 8) xor ecx, ecx // Value to fill (zero) call System.@FillChar // Call FillChar function // then repeat the same operate on dst2, dst3. problem is here, after FillChar dst3. the dst2 array become empty, and then some exception will raise up. Seems the fillchar of dst3 override some memory data of dst2, and other unknown data which cause AV error. end. Please see the above problem descritption at the bottom of the code. I have tried SetLength at first, but seems it not work, as SetLength is a overload function, I do not know how to call it correctly, then try DynArraySetLength, which seems could setlength correctly, but after fillchar, it shows that the memory which get may has confulic with other data, what's wrong of my codes? Any advice will be appreciated. Thank you. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Hello Remy I tried hooking the left mouse button and capturing the thumbnail preview window title, but after trying all possible methods, it is still difficult to get the window text. Use Wnd := WindowFromPoint(MouseInfo^.pt); to try to get the window, then GetWindowText, it is '', then try to use CoCUIAutomation to try to get it, hr := UIAutomation.ElementFromPoint(Point, Element); The element can be obtained with the class name of 'TaskListThumbnailWnd' but no name, try to get the child elements from it, can only get the child elements through Element.FindAll(TreeScope_Children, Condition, children); The class name is 'TaskListOverlayWnd' and there are no other child elements under this child element, and there is no name. I also tried Spy++ and Inspect to find more details, but both of them can't capture the thumbnail preview window well, because it is a pop-up window, when using spy++ you can't get the thumbnail preview window pop-up, if using Inspect, when the thumbnail preview window pops up, it will hide the Inspect window, if you click it, then Inspect will show the result of restoring the window after clicking. I will try more if I can. So if the above function can't get the title of the window, Using a fake main window and try to subclassproc to override WINPROC, maybe we can do it. Thank you very much. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Tried 2, also has problem, If form 3 or other sub-form was hiden by other apps. Click a taskbar button will bring all the hiden sub-form to be front than other app, though the sub-forms will not get the focus. 3 The id seems is the tumbbutton id on the taskbar button pre-view window, not the taskbar button id. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Hello Remy Yes, it is better to let the fmx does as it is. What I find more information about this matter, 1, Find that when VCL, there could setup the sub-form's WndParent to be desktop, that will keep the sub-form as a seperate form as the main form as? So that when delphi restore the main form after clicking the taskbar button, it will not find any child-forms and then active itself instead find a child-form and then restore the child-form if it is active before? So I tried to but not work as VCL app, not sure why. procedure TForm2.FormCreate(Sender: TObject); begin Winapi.Windows.SetParent(FormToHWND(Self), GetDesktopWindow); end; procedure TForm2.FormShow(Sender: TObject); begin Winapi.Windows.SetParent(FormToHWND(Self), GetDesktopWindow); end; 2, If the sub-form works as we expect, so we could hide the main-form and its taskbar button at the whole app life-time? And use the sub-form1 to act as a fake main-form do what the main-form's work? It sound be simple and easy to do just add a new form, and set the new form as the main-form, and min/hide it when the fmx app is running. I tried to create form1(hide), form2(fake-main, when close the app will terminate too), form3. From my test currently, the prolem is the when fmx app start, the form1 will flash before hide it. From another post, seems it is need to modify the FMX source code to avoid the flash of main form. I do not test this on my app yet so do not know if it will cause any other side effect yet. As my app manage other form behavior such as min max fullscreen restore, but I think it should work while need to adjust my codes to work with multi sub-forms. 3, Another find before 2 is the itaskbar interface from win api, In the api, seems it could set a button id, and pass the id back to the message with the LParam, So that we could use our form's wnd as the id and then when the subclassproc get the message, check that LParam and then setfocus on the correct form. I do not know if we could pass the LParam to the setwindowlongptr or some other api could do that, I think there should has. So we could use the api instead itaskbar inerface for the same thing. I do not test this yet. Your posts here are very very helpful. Thank you so much. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Hello Hide the default app taskbar button do active the forms by clicking their taskbar button. While I find that when click the min button to minimize the form1 window, it will hide all the taskbar buttons. And a window's title bar will shows on desktop, zero width and height, this is the default main zero window managed by FMX? Thank you. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Hi Remy, So this is weird, did you change any property of the form or did I miss something in the application configuration? Where do you call InitCommonControlsEx? Can you attach your complete test project here? I have tested my code and the code you posted here. If form2 is active, clicking the form1 taskbar button will still keep form2 active, because I think in FMX, if the main form is hidden by a child form, then FMX should consider that the child form should keep the focus when only one taskbar button for all the FMX forms created and get clicked. This should be the intention of FMX design. Since we added multiple taskbar buttons, we want each button to activate its own form, which will conflict with the design of FMX and therefore cause problems. But as you explained above, it really confuses me. Thank you very much. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
You see, if the form1 is not active, after you click the taskbar button form1, the form2 is still the active form, you have to use mouse to click the form1 to get it active. My codes attached. Thank you so much. TestWindowSubClassProc.7z -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Hello Remy, I test your codes, it is the same behavior as my, in my test app, the main form and the subform both use the same subclassproc in the unit2, I do not copy it to unit1. I would like to click the taskbar button of form1, then get the form1 to be front and active. If created a form2, and the form2 is already active. Then when you click the taskbar button of form1, You will see that the form1 does not active, the form2 is still the active form. Maybe I do not explain clearly? Thank you very much. 1) click mouse button on a form2, the form2 is active form. form1(main) is not active. 2) click the form1 taskbar button The form1 still not the active form, the form2 always keep active. In my app, I just want the result Click form1 taskbar button, form1 active and to the front. Click form2/form3 taskbar button, form2/form3 active and to the front. Now it works for form2, form3, but not work for form1 when the form1 is not active. Thank you very much. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
There is still a problem when clicking the main form taskbar button, if you have already activated the child form, the application will activate the child form instead of the main form. And the main form subclass procedure will not be called but the child form subclass procedure. It seems that the Wnd of the main form taskbar button is not always the same as the main form, it will change to the active child form so that when you click the main form taskbar button, the active child form will be active. On VCL forms, it seems that it can be changed by Application.MainFormOnTaskbar := False, but FMX does not have it. So there should be something in UpdateApplicationHwnd or something else change the main form handle of the taskbar button (main) to be the active child form handle. If we can get the title of the taskbar button that was just clicked intead of the Wnd, maybe we can switch forms more flexibly by the title. Thank you. -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Hello Remy Lebeau After InitCommonControlsEx, the SubToolBarSubclassProc works now, Thank you so much. var icc: TInitCommonControlsEx; icc.dwSize := SizeOf(icc); icc.dwICC := ICC_INTERNET_CLASSES or ICC_USEREX_CLASSES or ICC_DATE_CLASSES; InitCommonControlsEx(icc); -
FMX with multi taskbar buttons, switch forms by clicking taskbar buttons and bring the clicked form to front?
wqmeng replied to wqmeng's topic in FMX
Seems the code always return fail result. Not sure why. if not SetWindowSubclass(Wnd, SubToolBarSubclassProc, 1, DWORD_PTR(Self)) then begin LMsg := 'SetWindowSubclass failed! Error code: ' + IntToStr(GetLastError()); end; and the error code always 0.