Hi everyone
Hi everyone,
does anyone know how to handle Window messages in #firemonkey form?
I mean posting messages by PostMessage/SendMessage() methods.
PS: Actually I wanted to uncheck single RadioButton, as far as I can't uncheck it in its OnClick event handler, I wanted to post message in message queue and handle it after OnClick event.
does anyone know how to handle Window messages in #firemonkey form?
I mean posting messages by PostMessage/SendMessage() methods.
PS: Actually I wanted to uncheck single RadioButton, as far as I can't uncheck it in its OnClick event handler, I wanted to post message in message queue and handle it after OnClick event.
Use TCheckBox instead of TRadioButton
ReplyDeletebut set property StyleLookUp to "radiobuttonstyle" - it will looks like radiobutton but acts as checkbox
Sergionn Rad that is obvious answer :)
ReplyDeletethe question remains: how to handle window messages in FMX form in Windows
Andrew Terekhov TMessageManager.DefaultManager.SendMessage(const Sender: TObject; AMessage :TMessage; ADispose : Boolean);
ReplyDeletein FMX.Messages
Or in FMX.Platform.Win use
ReplyDeleteFormToHWND and then do PostMessage with it as Handle
Sergionn Rad TForm class itself does not recieve messages as it was in VCL, so we can't PostMessage directly to window and handle it in message procedure (procedure wmTest(var msg : TMessage); message WM_ TEST) because of crossplaform.
ReplyDeleteAndrew Terekhov Yes we can, you asked about windows remember?
ReplyDeleteTForm contains HWND under windows
use FMX.Platform.Win, Winapi.Windows;
if (Application.MainForm <> nil) then
PostMessage(FormToHWND(Application.MainForm), bla, bla, bla))
Just say what do you want to do exactly, i did a lot things in fmx but handle messages any way was not needed at all..........
ReplyDeleteSergionn Rad have you tried to run this code? It does not work in fmx as in vcl (in xe4). It was the first thing i did, thats why i asked about hooking window messages here. Anyway I do not need anything special, I'm just curious
ReplyDeleteyes did about year ago in my journey with fmx to fix cursor blinks, but finaly did it the other way without messages
ReplyDeletehttp://stackoverflow.com/questions/9186098/firemonkey-message-handling
Messages are indeed still present in the windows implementations of FMX forms, but controls and components don't get them the same way. Mouse and keyboard (for example) events are handled differently by the framework, but you can still, for windows at least, use them. You should be able to simulate mouse clicks on your forms and controls etc
ReplyDeleteone thing with radiobuttons...they are now grouped...in FMX..set the group name...the same..for all grouped radiobuttons
ReplyDeletePaul Foster Something the other way:
ReplyDeletefor win, and from p.2 to all:
1) Messages parse in FMX.Platform.Win
2) Then active Form get it by:
LForm.MouseDown(TMouseButton.mbMiddle, KeysToShiftState(wParam), P.X, P.Y);
3) Then MouseDown in CustomForm looks for control under Mouse coordinates:
Obj := IControl(ObjectAtPoint(ClientToScreen(FMousePos)));
and then pass in to control if found:
Obj.MouseDown(Button, Shift, P.X, P.Y);
- long way of little mouse click!
Simulate is very easy need just call
ReplyDeleteMouseClick() in needed control
or better can call method Click
Sergionn Rad indeed, some things are better here than in vcl, but also the abstraction from the hardware can be a problem too, but it also means (for example) that you can simulate that click on osx, ios and android in the exact same way.
ReplyDeleteI would advise not using windows messages in firemonkey to maintain this as much as possible :-)
Paul Foster sometimes you have to register window handle in third party libraries or Windows itseft to recieve notifications via Messages. Of course I mean not crossplatform apps.
ReplyDeleteIn which case you might be better sticking to the VCL
ReplyDeletePaul Foster seems SetWindowHookEx is the only solution to recieve messages from Message queue
ReplyDeleteIndeed. I'd stick to the vcl if you need to use windows messages....
ReplyDeletePaul Foster From step 2 it all crossplatform: units and code...
ReplyDelete