View Issue Details

IDProjectCategoryView StatusLast Update
0001644JEDI VCL00 JVCL Componentspublic2004-08-03 07:21
ReporteranonymousAssigned Toobones 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001644: Bug in TJvCaptionButton under XP
DescriptionLatest CVS!
Only OS: WinXP and higher (with Theming enabled)

1. Compile the CaptionButtonDemo
2. Create a shortcut of the executable file
3. Change shortcut properties to "Themes disabled"
4. Launch the application

Now you can see the captionbutton (e.g. screenshots) and when you change something then the caption button is drawn in black only. This maybe happens because the theming is only disabled for this application?

Please help me out with this bug...

Thanks in advance,
Soren
TagsNo tags attached.

Activities

2004-04-15 08:34

 

2004-04-15 08:34

 

remkobonte

2004-04-15 11:33

developer   ~0003881

Last edited: 2004-04-15 11:41

Mmm, never tried that :) will check it.

edited on: 04-15-04 11:41

anonymous

2004-04-15 11:39

viewer   ~0003882

Compiler: D7 Enterprise

And this happens only when you use the Demo executable under Windows XP Home/Pro and create a shortcut of the exe-file and edit the properties of the *.lnk File (Compatibility - Themes disabled). This should happend with every kind of compiler, because i think there is a bug in the sources to detect that the theming is not enabled. UXTHEME?

remkobonte

2004-04-15 11:42

developer   ~0003883

Yeah, I can reproduce it now; I was just reading a bit too fast and thought I recognized a D6<= problem.

remkobonte

2004-04-15 12:06

developer   ~0003884

Changing function TJvCaptionButton.GetIsThemed to

function TJvCaptionButton.GetIsThemed: Boolean;
begin
  Result := ThemeServices.ThemesAvailable and IsThemeActive and IsAppThemed;
end;

seems to be enough, but will investigate some more.

anonymous

2004-04-15 12:53

viewer   ~0003886

Yeah this seems much better now :-)
Small Things could do sooo much! *smile*

Is there a way to paint the button in caption bar color or to show an custom image (whole button size) to create a better WinXP looking custom button? I think there could be a way to get the background image from the current theme for the custom button (Windows XP - e. g. Blue Button) or a gradient style?

Thanks again for your great support!

anonymous

2004-04-15 13:06

viewer   ~0003887

Ok... for example look under C:\WINDOWS\Resources\Themes\Luna\luna.msstyles (open with ResourceHacker or something else) now open the BITMAP Tree!

BITMAP -> BLUE_CAPTIONBUTTON_BMP shows the correct background images for the a custom caption button. It would be great if we could use these images (from the current theme) as background? :-)

remkobonte

2004-04-15 13:07

developer   ~0003889

Yeah, I know it looks really ugly now, but I don't know a straight forward way to make it better. That is, I don't know a good way to construct a good image for the button at run-time.

I know e-mule just includes 3x8 (3 themes (blue,green,gray), 8 states of the button) images for the minimize to tray caption button. I think allmost all XP users use one of these three themes so that might be a reasonable good solution.

2004-04-15 13:27

 

BLUE_CAPTIONBUTTON.bmp (14,166 bytes)
BLUE_CAPTIONBUTTON.bmp (14,166 bytes)

2004-04-15 13:27

 

2004-04-15 13:27

 

anonymous

2004-04-15 13:29

viewer   ~0003890

Ok i've uploaded the extracted Bitmaps out of C:\WINDOWS\Resources\Themes\Luna\luna.msstyles ... Maybe there is a way to check out if theming is used and which msstyles file is used to extract the current background bitmap online?

With this solution you could extract anykind of msstyles <name>_CAPTIONBUTTON_BMP resource! :-)

remkobonte

2004-04-15 13:39

developer   ~0003891

Okay didn't know that :) But I see 2 problems:

1. You might have to resize the image (large/extra large caption) This is not so big problem but might look not so good.
2. It's undocumented by Microsoft, thus it might be broken in newer systems (for example windows 2003 but can't test that) Offcourse you can check whether the luna.msstyles file exists and if it the file does not exists, draw the button as it is done now; or include the bmps as a resource file.

Anyways will check what can be done. Looks promising :)

anonymous

2004-04-15 13:43

viewer   ~0003892

Ok... Here it's the next step to the perfect solution... With this documented function you could check out the correct used msstyles file. The last problem is to know which of the included 3 themes is used (BLUE, HOMESTEAD or METALLIC) ... i'm still working on it!

------ USE THIS CODE!

uses ComObj, SyncObjs; // <-- add this to uses clauses

var
  GetCurrentThemeName: function (pszThemeFileName: LPWSTR; cchMaxNameChars: Integer;
    pszColorBuff: LPWSTR; cchMaxColorChars: Integer; pszSizeBuff: LPWSTR;
    cchMaxSizeChars: Integer): HRESULT; stdcall;

procedure TForm1.Button1Click(Sender: TObject);
var
  FileName, ColorScheme, SizeName: WideString;
  hThemeLib: THandle;
begin
  try
    hThemeLib := LoadLibrary('uxtheme.dll');
    if hThemeLib > 0 then
      GetCurrentThemeName := GetProcAddress(hThemeLib, 'GetCurrentThemeName');
    if Assigned(GetCurrentThemeName) then
    begin
      SetLength(FileName, 255);
      SetLength(ColorScheme, 255);
      SetLength(SizeName, 255);
      OleCheck(GetCurrentThemeName(PWideChar(FileName), 255,
        PWideChar(ColorScheme), 255, PWideChar(SizeName), 255));
      // show the the theme path and file name.
      ShowMessage(PWideChar(FileName));
      // show the color scheme name
      ShowMessage(PWideChar(ColorScheme));
      // show the size name
      ShowMessage(PWideChar(SizeName));
    end;
  finally
    FreeLibrary(hThemeLib);
  end;
end;

anonymous

2004-04-15 13:48

viewer   ~0003893

There is now problem with this under Windows 2003 Server / Advanced Server :-) all newer OS uses the UXTHEME.DLL for Theming.

remkobonte

2004-04-16 10:38

developer   ~0003915

Okay, it is in Rev 1.21.

2004-04-17 13:29

 

2004-04-17 13:29

 

2004-04-17 13:30

 

anonymous

2004-04-17 13:31

viewer   ~0003923

Ok... i'll try to allow each theming not only luna.msstyles. This seems to work good for now, but there is a strange bug in the


procedure TGlobalXPData.Draw(HDC: HDC; State: Integer;
  const DrawRect: TRect);

....

with the function StretchBltTransparent (see uploaded Screenshot)
when i alternative use the TransparentBlt then it seems better (not stretched) but the Transparentcolor doesn't work :-( (see also uploaded Screenshot)

Please try this with the attached STRETCHED_CAPTIONBUTTON.BMP!

Thanks a lot ... and great work!
Soren

anonymous

2004-04-25 01:22

viewer   ~0004064

Is this topic closed?

It would be great if someone could help me out with the STRETCH-Problem (see bugnote above).

Best regards,
Soren

remkobonte

2004-04-27 18:24

developer   ~0004095

I have changed StretchBltTransparent to TransparentBlt. AFAICS TransparentBlt does not work right when the source rect has not the same dimensions as the dest rect. (Your STRETCHED_CAPTIONBUTTON.BMP has dimension 20x20, the button probably 21x21)

I've changed the copy routine again, and now it looks pretty good on my machine. Please test and feedback whether it works for you. It is in rev 1.23.

> Is this topic closed?

No, just not much free time :)

2004-04-28 00:38

 

Drawing_Failure.jpg (73,543 bytes)
Drawing_Failure.jpg (73,543 bytes)

anonymous

2004-04-28 00:40

viewer   ~0004096

It seems now that the wrong background image is used?

(see screenshot: drawing_failure.jpg)

remkobonte

2004-04-28 04:49

developer   ~0004103

Last edited: 2004-04-28 06:14

The caption button saw that the default style was not used, thus used SimpleDraw instead of Draw. This should be fixed in rev 1.24.

edited on: 04-28-04 06:14

obones

2004-08-03 07:21

administrator   ~0004883

This bug has not had any activity for more than a month, it is therefore considered resolved.
To the original poster: If you think the issue is still there, even after having tested with the JVCL3, please create a new bug report.

Issue History

Date Modified Username Field Change
2004-04-15 08:34 anonymous New Issue
2004-04-15 08:34 anonymous File Added: JvCaptionBug_XP_withoutThemes1.jpg
2004-04-15 08:34 anonymous File Added: JvCaptionBug_XP_withoutThemes2.jpg
2004-04-15 11:33 remkobonte Note Added: 0003881
2004-04-15 11:33 remkobonte Status new => feedback
2004-04-15 11:34 remkobonte Note Edited: 0003881
2004-04-15 11:39 anonymous Note Added: 0003882
2004-04-15 11:41 remkobonte Note Edited: 0003881
2004-04-15 11:42 remkobonte Note Added: 0003883
2004-04-15 12:06 remkobonte Note Added: 0003884
2004-04-15 12:53 anonymous Note Added: 0003886
2004-04-15 13:06 anonymous Note Added: 0003887
2004-04-15 13:07 remkobonte Note Added: 0003889
2004-04-15 13:27 anonymous File Added: BLUE_CAPTIONBUTTON.bmp
2004-04-15 13:27 anonymous File Added: HOMESTEAD_CAPTIONBUTTON.bmp
2004-04-15 13:27 anonymous File Added: METALLIC_CAPTIONBUTTON.bmp
2004-04-15 13:29 anonymous Note Added: 0003890
2004-04-15 13:39 remkobonte Note Added: 0003891
2004-04-15 13:43 anonymous Note Added: 0003892
2004-04-15 13:48 anonymous Note Added: 0003893
2004-04-16 10:38 remkobonte Note Added: 0003915
2004-04-17 13:29 anonymous File Added: Usage_of_StretchBltTransparent.jpg
2004-04-17 13:29 anonymous File Added: Usage_of_TransparentBlt.jpg
2004-04-17 13:30 anonymous File Added: STRETCHED_CAPTIONBUTTON.BMP
2004-04-17 13:31 anonymous Note Added: 0003923
2004-04-25 01:22 anonymous Note Added: 0004064
2004-04-27 18:24 remkobonte Note Added: 0004095
2004-04-28 00:38 anonymous File Added: Drawing_Failure.jpg
2004-04-28 00:40 anonymous Note Added: 0004096
2004-04-28 04:49 remkobonte Note Added: 0004103
2004-04-28 06:14 remkobonte Note Edited: 0004103
2004-08-03 07:21 obones Status feedback => resolved
2004-08-03 07:21 obones Resolution open => fixed
2004-08-03 07:21 obones Assigned To => obones
2004-08-03 07:21 obones Note Added: 0004883