we are working on Delphi 7. Recently we have moved from Windows Server to windows 7. we are handling all the error messages in our application through MessageBox. MessageBox appearance is different in Windows Server 2003 and windows 7. Please find below screen shots, which shows difference in windows server 2003 and windows 7.
we want windows 7 message box to display same like windows server.
The MessageBox API is implemented by the system. It is a dialog implemented by Win32 in the user32 module. So you are just picking up the standard Windows dialogs. If you try to replicate the old XP/2003 dialogs on Windows 7, your application will look out of place.
Now, if you are absolutely desperate to replicate the XP/2003 appearance, then you cannot do that through MessageBox. You would need to create your own dialog. Create a form. Add a TImage for the icon, a label for the text, and whatever buttons you need. Show the form with ShowModal. Indeed, the Dialogs unit has a function that creates just such a form, CreateMessageDialog.
var
MessageBoxForm: TForm;
....
MessageBoxForm := CreateMessageDialog('Your message goes here', mtError, [mbOK]);
Try
MessageBoxForm.ShowModal;
Finally
MessageBoxForm.Free;
End;
And there's even a simple wrapper that allows this one-liner:
MessageDlg('Your message goes here', mtError, [mbOK], 0);
That is how to do what you ask but I cannot endorse that as being a good idea. Times change, and it is usually best to move with the times.
Related
I use Delphi XE2 on Windows 8. I have ported an D2009 application to XE2 and suddenly the save dialog (TSaveDialog) is very slow.
When Project/Options/Application/Runtime Themes is set to Enable Runtime Themes:
=>
When I open the save dialog the window freezes for about a minute (sometimes I can close the window but have to wait about a minute until I can open the dialog again (or another TOpenDialog). The new Vista style save dialog is shown.
If I try to run this exe on a PC with Windows 7, the app hangs upon start (I did also try with XP compatibility mode without success).
When Project/Options/Application/Runtime Themes set to none:
=>
Save dialog works well (fast) but the old style dialog is shown, se example below:
This exe works well on a PC with Windows 7 (though with the old style dialog).
Ps. My old exe-file compiled with D2009 on a Win 7 PC works however well on both the Win 7 and 8 PC:s, and shows the dialogs correctly using the new Vista dialog style.
Could it be some permission rights in Win 8/7 causing this? I use IDE FIX PACK 5.4,
Thanks,
Thomas
I found what the problem is. I use {$MAXSTACKSIZE $4000000} and this causes the save dialogue to freeze for about a minute.
The reason for this hefty stack size is that I use a recursive algorithm (that I now probably need to remake).
Reproduce as follows (XE2):
Create a new VCL forms application
Place a TSaveDialog1 on the form
Place a Tbutton with OnClick event
`
Begin
if SaveDialog1.Execute then
MessageDlg('ok', mtInformation,[mbOk], 0);
end;
`
4: Open the project source file and put the following rows:
//{$MAXSTACKSIZE $3500000} //this is a decimal value of 5 5574 528 OK!
{$MAXSTACKSIZE $4000000} //this is a decimal value of 6 7108 864 Not OK!
Run and click the button. Give a dummy file name and press save. Nothing happens. Keep on clicking the button for 60 seconds. The dialogue will finally close.
Change to the smaller stack size $3500000. Now the program works well. Thanks for all tips.
I guess this is yet another reason why VCL styles are not ready to be really used.
TDateTimePicker control looks fine without VCL styles. Turn on any vcl style, and I get this appearance:
I can turn off the vcl styles for just this component type, by registering a style hook, but that looks really ugly.
This is on Delphi XE2 with update 4 installed.
Ideally, I hope there is a workaround, or some properties of the datetime picker, or some subclass of datetimepicker I could do to force the datetime picker to paint and theme correctly.
Note that normal comboboxes are theming correctly. Note that this reproduces easily in the most minimal sample project imaginable. Yes. It's Yet Another Styles bug.
Update It might be platform specific, related to Windows Common Controls versions on Windows Server 2008 R2 without Aero ("Desktop Experience" in Windows server component terms). It just occurred to me after other people cannot reproduce it, to try this on several different Windows machines. After I did that, I find that the problem only reproduces on Windows Server 2008 R2. Some of our customers use Windows Server 2008 R2. As you know a major reason for using VCL Styles is that it makes your app look the same regardless of what the windows theme is. However in the case above, the whole app themes properly, except the DateTimePicker control, which is themed incorrectly, and only on Windows Server 2008 R2. The same XE2-based demo app works fine on Windows 7.
Both the working and non-working systems have a ComCtl32.dll in the SysWow64 folder with version reading 5.82.7601.17514. However, clearly the native layout and appearance of these controls is different, when VCL themes are off, and this affects the skinning code, which fails.
Update2: Reported as a bug: QC Entry 106783
Ok, I just made a small change to the Vcl.Styles.DateTimePickers unit which is part of the vcl-styles-utils. To fix this issue when the "Windows Classic" theme is active.
Use this style hook in this way
uses
Vcl.Styles,
Vcl.Themes,
Vcl.Styles.DateTimePickers;
initialization
TStyleManager.Engine.RegisterStyleHook(TDateTimePicker, TDateTimePickerStyleHookFix);
And this will be the result.
I can confirm that when I install Desktop Experience, enable Themes and start the Themes service, this glitch goes away.
Okay here's my workaround code for now:
function DetectWin7Or2008R2ClassicTheme:Boolean;
begin
if ( Win32MajorVersion>=6 ) then
result := (not Themes.ThemeServices.ThemesEnabled) // and IsServerOs
else
result := false;
end;
// main form initialization section:
initialization
if DetectWin7Or2008R2ClassicTheme then
TStyleManager.Engine.RegisterStyleHook(TDateTimePicker, TStyleHook); {no theme!}
end.
It's clearly a wild corner-case. I expect to find more, and I'll come back and update this question when I find what else breaks on Windows Server 2008R2 or Windows 7, when the theme service is not running, which is what happens when you pick "Windows Classic Theme" on Win7, also.
Win7/x64, Delphi 6 Prof.
Win7 drives me crazy with his side effect. I describe it:
When I force the suggestion with Ctrl+Space, or Delphi do this automatically, the Delphi don't show the suggestion dropdown listbox, he is only bring my all opened forms to front, one by one.
This causes that what I typing is not going to editor window: it is going to any property of the active form, of the active control.
For example.
Ctrl+Space+"ShowMes..."
I don't got ShowMessage with suggestion listbox, I type ShowMess into my main form's caption.
Many times I need to make update pack's because the buttons, caption, etc got "ShowMes" or "Excep" or other property, because I type into these windows...
This function is sometimes broken on win7.
May I can restore the normal working mode without "bring all opened form to front"?
Thanks:
dd
You can disable UAC in Windows 7, see here:
http://www.petri.co.il/disable-uac-in-windows-7.htm
Also running Delphi 6 in Windows XP compatibility mode should do the trick.
See this discussion on the embarcadero forums, it's about Delphi 7, but it's the same issue:
https://forums.codegear.com/thread.jspa?messageID=204928&tstart=0
Finally see here how to run a program in XP compatibility mode:
See: http://www.w7forums.com/application-compatibility-mode-t314.html
Or: http://www.sevenforums.com/tutorials/316-compatibility-mode.html
I have TWebBrowser embedded in a TForm.
Whenever I press Alt button the browser window becomes white. If I drag the form around it repaints correctly.
What I am doing wrong?
I have DevExpress Bars and Quantum Grid if that matters?
I use Delphi 2010 and Windows 7 and XP SP2. IE version is 7 and 8. Reproducible on all.
Before pressing Alt:
After pressing Alt:
I have resolved it by usnig the following:
procedure TMainForm.WndProc(var Message: TMessage);
begin
inherited WndProc(Message);
if Message.Msg = WM_UPDATEUISTATE then
begin
if Assigned(ProblematicWebBrowser) then
ProblematicWebBrowser.Repaint;
end;
end;
You don't say what version of Delphi you're using, what version of Windows you're using, or what version of IE you have installed, which is what TWebBrowser wraps. (As a general note because you're a new user here, you really need to provide more information when asking a question like this. Pretend it was a user of your software reporting this bug - you'd throw your hands up and say "Bah, not reproduced. Why can't they tell me what they're doing?" Same for us when reading your question.)
But, that said, the fact it vanishes when you press the Alt key is a hint. Windows has an option to hide accelerator keys (the underline mark such as the underlined F on a File menu) until the user presses the Alt key. When it does, controls are sent a WM_DRAWITEM message indicating something's changed. See also WM_CHANGEUISTATE.
There have been bugs in past versions of Delphi handling this (see this example bug) including a bug where controls completely vanished when the Alt key was pressed. TWebBrowser isn't listed in that QC item, but it's quite possible it's affected.
So my guess is:
You're using Delphi 7 or earlier
You're using XP or above, and running
themed
You're encountering this bug,
which is affecting either the
TWebBrowser control or a parent of it
Solution: upgrade Delphi or apply the fix listed in the QC item.
FWIW, with a plain vanilla Form with a TWebBrowser in D2010, pressing Alt has not effect on the WebBrowser display.
I currently use the TOpenTextFileDialog as it has the Encodings option, but under Vista it appears using the older open dialog style. I'd like the new style open dialog, but with an encoding combobox that I can fill with custom strings. Basically I want the exact open dialog that Notepad shows under Vista. Of course I also need the corresponding save dialog as well.
I've done some research and it seems that the OFN_ENABLETEMPLATE flag causes the Vista common dialog to fall back to the old style. Unfortunately that's also the flag that lets the TOpenTextFileDialog modify the window to add the encodings combobox (if I understand things properly.)
Does anyone have a suggestion on how to get what I want under Vista but still have it work under XP? I assume that Windows 7 will have the same issue. I'm using D2009. Thanks for any suggestions or help!
With Vista a new way of dealing with file dialogs has been introduced, for more information google for the IFileDialog interface or have a look at this blog post. As you say yourself, using the OFN_ENABLETEMPLATE flag causes the Vista common dialog to fall back to the old style.
With Delphi 2007 and 2009 you can use the TFileOpenDialog and TFileSaveDialog in the Vista Dialogs components category. To make your application compatible with pre-Vista Windows versions you should keep using the TOpenTextFileDialog for those, and check at runtime whether you are on Vista and can use the new dialogs:
if Win32MajorVersion >= 6 then begin
// use TFileOpenDialog
// ...
end else begin
// use TOpenTextFileDialog
// ...
end;
Now you only need to add the customization to the Vista dialog. The blog post shows how to do this, by adding a handler for OnExecute of the dialog (because at the time when this is called the IFileDialog interface has been set up already), querying the Dialog member of the file dialog for the IFileDialogCustomize interface, and using this to add the additional controls.