Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2019, 11:15 AM
walker1 walker1 is offline
Junior Member
 
Join Date: Feb 2011
Posts: 12
Thumbs down Problem handling messages?

I am using Delphi 6 on Win 7 32 bit.


My .exe files all work, but if I run from within the IDE, my apps will not handle incoming messages from other applications. I use a LOT of those messages!



Which flags do I have to adjust?


Windows directory attributes, Delphi IDE and/or debug flags or .. ?


I also seem to have problems with breakpoints. Every now and then they seem to be disabled at run time.



I do have administrator privileges, directories should all be fully accessible etc, but I may have missed something?

Last edited by walker1; 04-11-2019 at 11:32 AM.
Reply With Quote
  #2  
Old 04-24-2019, 08:14 AM
walker1 walker1 is offline
Junior Member
 
Join Date: Feb 2011
Posts: 12
Default

So far no answers?!
Maybe I should put in some more specifics?


I use messaging inside and between applications.
Almost all message numbers are in the WM_App and WM_User ranges (external and internal respectively)


At startup I search for wanted forms of other apps and then transmit the current apps handle to them.
All transmitting is done using SendMessage, and finding external forms is done with FindWindow.


The code below is (part of) the seeker for external apps.
(Sorry about the indents, I can not figure out how to get them to show properly)



procedure MesToDebug(MesID : integer; wParam : cardinal; lParam : integer);
begin
if DebugWindow<>0 then
sendmessage(DebugWindow, MesID, wParam, lParam);

end;

procedure FindOthers(OwnWindow : THandle; OwnID : integer);
begin
MySelfWindow:=OwnWindow;
MySelfID:=OwnID;

if MySelfID <>RemoteID then
begin
RemoteWindow:=findwindow(pchar('TRemoteform'),pcha r('MRS Remote Display'));
MesToRemote(MRS_WinIdentify, MySelfID, MySelfWindow);
end;

if MySelfID <>DisplayID then
begin
DisplayWindow:=findwindow(pchar('TMainform'),pchar ('MRS Live Display'));
MesToDisplay(MRS_WinIdentify, MySelfID, MySelfWindow);
end;

if MySelfID <>DebugID then
begin
DebugWindow:=findwindow(pchar('TDbgForm'),pchar('M RS Debug Status'));
MesToDebug(MRS_WinIdentify, MySelfID, MySelfWindow);
end;
end;



The code below receives the form handle from relevant just started external apps.


private
procedure WinIdentify(var mes : Tmessage); message MRS_WinIdentify;




procedure Tmainform.WinIdentify(var mes : Tmessage);
Begin
with mes do
case wparam of
ControlID : Controlwindow := lparam;
RemoteID : Remotewindow := lparam;
DebugID : DebugWindow:=lParam;
end;

end;


Under XP this all worked perfectly from within the IDE and as .exe.
Under Win 7 (32 bit), however, incoming messages, and at least to some extend breakpoints, are not handled when running from within the IDE.
Outgoing messages work fine, and the correct handle for a form is received in apps run as .exe.

Running one app from the IDE and then starting another does produce the correct handle to the IDE form, when the newly started .exe seeks it.
But the IDE run app never receives the handle to the .exe.



How to change that?

Last edited by walker1; 04-24-2019 at 08:23 AM.
Reply With Quote
  #3  
Old 04-24-2019, 01:16 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 198
Default

Since you want all the applications to have a unique message number for MRS_WinIdentify, you should be registering the message using the windows RegisterWindowMessage function from all your applications. The first app that runs RegisterWindowMessage gets the message number, all subsequent apps that run it, get the same message number as the 1st one, ensuring all of them get the same reference. Since you mention that all messages are in the WM_APP and WM_USER space, it leads me to believe you are just declaring it as a constant. Check reference here.
Reply With Quote
  #4  
Old 04-25-2019, 06:51 AM
walker1 walker1 is offline
Junior Member
 
Join Date: Feb 2011
Posts: 12
Default

Quote:
Originally Posted by rojam View Post
Since you want all the applications to have a unique message number for MRS_WinIdentify, you should be registering the message using the windows RegisterWindowMessage function from all your applications. The first app that runs RegisterWindowMessage gets the message number, all subsequent apps that run it, get the same message number as the 1st one, ensuring all of them get the same reference. Since you mention that all messages are in the WM_APP and WM_USER space, it leads me to believe you are just declaring it as a constant. Check reference here.
As I read the Win32 help file, RegisterWindowMessage should only be needed if I use broadcasting.

And I fail to see, why that use would make a difference between .exe and IDE execution of my code. Of course, I graduated in 1980, so I may not be too sharp anymore

I lean more towards some flag or setting (or blockade?) in Windows 7 (32 bit), the IDE or the shortcut wrapper I use to start the IDE with.
I have tried setting compatibility to XP SP3, but it does not seem to change much. My breakpoints may work better without it, but messages do not get handled by my code. XP or not.
The messages do get handled, however, because I see no blocking.

What does the handling so the transmitting code can continue?

On the other hand, the IDE does takes forever to start my code, and the same happens should the IDE react to a breakpoint. With Integrated Debugging disabled, the code starts immediately! Message handling is still off, however.
Reply With Quote
  #5  
Old 04-25-2019, 02:09 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

Delphi 6 is from 2001, so you're relying on a 18 year old help file which has API references of windows 2000?

Not to be rude or anything, but back in the day Delphi 6 (as for any even delphi release up to that point) didn't have a good track record of being good and stable.
But I would be carefull to assume that all API of windows 2000 is still compatible with newer windows versions...

As for you problem, I have no clue, the code samples don't provide any real logic of the problem.
Perhaps it's as simple as that it cannot find a window, because run as administrator for example ads administrator to the caption. And since you find windows by caption this could already result in a non-responsive situation.
But again, with the code provided it's not possible to figure these things out (and to be honest, I don't have Delphi 6 so if it's version related, what I don't assume in this case but just to note it, it's imposible to answer).

But what does your debugger say, just add some logs at all points to see if al variables are correctly filled.
Reply With Quote
  #6  
Old 04-28-2019, 06:52 AM
Glenn1234 Glenn1234 is offline
Senior Member
 
Join Date: Aug 2009
Posts: 131
Default

I gather this is a transition between Windows XP and Windows 7? Note on Windows 7 there's a lot more security measures put in that are intended to keep certain things from happening.


As an initial step, I will point out that Delphi has to have the same permissions as the applications you need to debug. So if you use "Run as administrator" or the like to run your programs otherwise, you have to do the same with Delphi to debug these programs. Try that, and if your programs debug okay, you know what you'll need to do.


I had to do this with my Delphi 3 in going away from Windows XP. More or less, you can find the executable where you have it installed and set the file to permanently run as administrator if you find out that these programs will debug fine after simply right-clicking the icon and using that option.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 11:31 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.