1
I’m having trouble sending text messages from a Client Socket. The form that sends the text, is always displayed above the form that always stays at the top, when FormOnTop
does not exist (is not shown), works well, already when FormOnTop
exists and form that sends the text is displayed above the FormOnTop
, the sending fails, and the text (message) does not even leave the Client.exe of my software.
Is there any solution to this?
To better understand, I will leave below the code I use:
Form containing Client Socket component:
unit Unit1;
interface
uses
FormSender;
type
......
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.CS1Read(Sender: TObject; Socket: TCustomWinSocket);
var
StrCommand: String;
begin
StrCommand := Socket.ReceiveText;
if Pos('<|Command_From_Server|>', StrCommand) > 0 then
begin
FormSender.PopupMode:= pmExplicit;
FormSender.PopupParent:= FormOnTop;
FormSender.Show;
end;
end;
end.
Form that sends the text (Formsender) and appears above the form that always stays at the top:
unit FormSender;
interface
uses
Unit1;
type
......
end;
var
FormSender: TFormSender;
implementation
{$R *.dfm}
procedure TFormSender.Button1Click(Sender: TObject);
begin
Form1.CS1.Socket.SendText('<|Hello_To_Server|>' + Edit1.Text + '<<|);
end;
end.
Form that always stays at the top:
NOTE: The Formstyle property is: fsStayOnTop
.
unit FormOnTop;
interface
uses
.......
type
......
end;
var
FormOnTop: TFormOnTop;
implementation
{$R *.dfm}
procedure TFormOnTop.FormCreate(Sender: TObject);
begin
{ Position form }
Top := 0 ;
Left := 0 ;
{ Go full screen }
BorderStyle := bsNone ;
WindowState := wsmaximized;
ClientWidth := Screen.Width ;
ClientHeight := Screen.Height;
Refresh;
SetForegroundWindow(Handle) ;
SetActiveWindow(Application.Handle);
end;
procedure TFormOnTop.CreateParams(var Params: TCreateParams);
begin
inherited;
if (FormStyle = fsStayOnTop) then begin
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow;
end;
end;
procedure TFormOnTop.FormShow(Sender: TObject);
begin
SetWindowPos(FormOnTop.handle, HWND_TOPMOST, FormOnTop.Left, FormOnTop.Top, FormOnTop.Width, FormOnTop.Height, 0);
end;
end.
If you comment on the line
if Pos('<|Command_From_Server|>', StrCommand) > 0 then
something appears?– Guilherme Nascimento
@Guilhermenascimento, this part is ok. The problem is in the sending part:
Form1.CS1.Socket.SendText('<|Hello_To_Server|>' + Edit1.Text + '<<|);
– Edejofre PRG1
I guess you don’t understand, you’re sending and it doesn’t look like you’re getting anything is that? So it seems to me that you’re using
Pos
wrong way. I will try to formulate a response.– Guilherme Nascimento
Actually the sending is not even leaving the Client.exe, the problem is not related to the receipt by Server.exe, the code I showed above refers only to part Client.exe :-). That one
'<|Command_From_Server|>'
is Server.exe who sends to upload Forms in Client.exe.– Edejofre PRG1
I understand I’ll read your question again, I think I missed something.
– Guilherme Nascimento
When you say that "not even out", you mean that the requested window does not appear?
– Guilherme Nascimento
No, not even the content to be sent :-), IE does not send anything.
– Edejofre PRG1
It looks like you’re focused on Button’s possible problem, which means you hit the button and nothing happened, is that it? If it is try to see if my answer makes sense.
– Guilherme Nascimento