Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jan 28, 2010 8:55 pm   

Nasty Windows 7 problem
 
I'd like other people running Windows 7 to try this procedure and see if they get the same problem:

1) Run CMUD, Close the Session window
2) Click the Settings button in the toolbar
3) Now resize the right edge of the settings editor and see if the various fields resize themselves properly. For example, the window name field should stay the full width of the window. If you make the settings editor larger, tell me if you just see more blank space to the right or if the Name and "List of packaged enabled" properly fill in the wider space on the right.

On my system, none of the dialogs that have "client alignment" set are working at all. Note in the v2.37 Public, nor in the 3.12 Beta. The exact same EXE files work fine on Vista. So it seems to be something specific to Windows 7 that has changed. Note that this is the 64-bit version of Windows 7.

I'm going to try and make a simple test program for this to see if it's an issue with Delphi or not. But let me know what you find. This bug really makes CMUD (and TeSSH) look horrible when resizing windows on Windows 7. Just the kind of issue that I do NOT want to deal with today!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jan 28, 2010 9:33 pm   
 
Geez this is annoying. I played around in some test programs and narrowed it down. Seems pretty obscure when you first look at it. It only seems to be a problem if using a DevExpress PageControl (panel with tabs), which contains a Frame that itself contains another PageControl.

For example, in the Settings Editor, there is a top-level PageControl used to switch between Aliases, Triggers, Variables, etc. Each of these pages loads a Frame (AliasFrame, TriggerFrame, etc). Within AliasFrame, there is another PageControl used to the Text, XML, Compiled Code tabs.

I use this construct all the time. For example, it is also used in the Session window for editing sessions. A top-level page control switches between the main session view and the MUD Connector list. Within the Edit Session Frame is another PageControl for the Session/Autologin/PackageFiles/Notes tabs.

Unfortunately, this is so obscure, that I'm not sure I'm going to get any help from Developer Express on this. And I have no idea why only Windows 7 shows this problem and not even Vista. It's just really weird.
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Thu Jan 28, 2010 9:57 pm   
 
I've had this problem for a while too. I just click on another class name, then back again and the script resizes itself
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jan 28, 2010 10:54 pm   
 
It's something about the PageControl (tabs). But even using the built-in Delphi TPageControl, or another 3rd party page control, the problem still occurs. This is just really weird. It might be a fundamental problem with Delphi itself, or it might be an issue with Windows 7 not sending the same windows messages that Delphi is expecting. Still trying to find workarounds. But since it's not specific to the Developer Express controls, I'm going to have a hard time getting any other help on this. I'm on my own now.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jan 28, 2010 11:10 pm   
 
No, now it *is* related somehow to Developer Express controls. I replaced all DevExpress controls with normal Delphi controls. The problem remained. But then I removed all of the references to the DevExpress units in the Interface section. Then the problem went away. Then I added a DevExpress edit box to the form. The problem came back. Removed the edit box. Problem remained. Removed the DevExpress units, problem went away.

So just having a certain DevExpress unit listed in the interface uses clause is enough to screw things up. Narrowed it down to the "cxGraphics" unit. Maybe now I can put together a test program that DevExpress can try to reproduce.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jan 28, 2010 11:41 pm   
 
I'm getting more stumped the more I work on this.

From the "cxGraphics" unit, I learned that it was one of the other units "used" by "cxGraphics". After much debugging, I isolated the problem down to a hook installed by the cxContainers unit. It creates a hook into the CALLWNDPROC chain. If I remove the call to SetWindowsHookEx, then the problem goes away.

However, the really weird part is that if I create my own hook that just calls the next hook in the chain:
Code:

function MyApplicationCallWndProcHookProc(Code: Integer;  WParam, LParam: Longint): Longint stdcall;
begin
  Result := CallNextHookEx(FApplicationCallWndProcHook, Code, WParam, LParam);
end;

where FApplicationCallWndProcHook was defined by:
Code:

  FApplicationCallWndProcHook := SetWindowsHookEx(WH_CALLWNDPROC, MyApplicationCallWndProcHookProc, 0, GetCurrentThreadId);

then it still fails. If I remove the call to SetWindowsHookEx, then everything works. So I don't understand how just defining a "pass-through" hook could be causing this problem. Unless there is another hook to this event somewhere else in the DevExpress code.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jan 29, 2010 12:12 am   
 
Well, this is just great. If I compile my simple test program using Delphi 2010, then the problem goes away. So it looks like the problem is buried somewhere deep in Delphi 2007. My guess is that Delphi 2007 also has it's own WH_CALLWNDPROC hook and that is why just doing a simple hook chain is causing the problem. Don't really understand why the problem goes away when I remove the call to SetWindowsHook entirely. But several 3rd party components also use this hook, and I can't prevent all of them from using it.

All I can do is figure out a way to avoid putting PageControls within Frames within PageControls within other frames. But that's also a pretty fundamental UI design that I use in lots of places in CMUD. So any way I look at it, this is going to be hard to fix. This is really going to kill my beta release schedule. I can't have something like this which makes TeSSH look so unprofessional on the very system (Windows 7) that I plan to heavily promote TeSSH on. And I can't just start using Delphi 2010 because that Unicode conversion is a huge job.

I'm just going to need to sleep on this and hope that I get some sort of brilliant idea. And I still don't understand why I'm so cursed and all of these kinds of things seem to happen to me and not other developers. Am I the only person in the world using Delphi to create complex user interfaces?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jan 29, 2010 12:29 am   
 
WOOT!!!!! Somebody has come to my rescue!!

Now that I knew the problem was related to the WH_CALLWNDPROC hook, I was able to find this page: http://andy.jgknet.de/blog/?page_id=288

It provides a "VCLFixPack" unit for Delphi that fixes several bugs by patching the Delphi core code at runtime. One of the bugs mentioned specifically is:

# Control resize bugfix unit for the WH_CALLWNDPROC issue (fixed in Delphi 2009)

I downloaded this unit, added it to my test program, and the problem went away! I then went back to the CMUD project, added the VCLFixPack unit and recompiled CMUD. Problem solved!!

I need to write this guy an email to thank him for saving me! Maybe I'll still be able to release a beta tomorrow after all.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net