Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

A transparent form on the Desktop

Posted on 2010-08-26
4
Medium Priority
?
741 Views
Last Modified: 2013-11-23
Hi,

I'm building a calendar and it needs to stay on desktop.
My form needs to be transparent and to stay maximized when the user press Show Desktop button or Win+D.
I'm using Delphi.
Windows XP, Vista and 7.

1) In order to make the form transparent, I'm using the following code:

  if SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED) = 0
  then ShowMessage(SysErrorMessage(GetLastError));


2) In order to make the form stay on desktop even when user press Win+D:

procedure TForm1.FormCreate(Sender: TObject);
var hWindow: hwnd;
begin
  hWindow := FindWindow(nil,PChar('Program Manager'));
  if hWindow <> 0 then Form1.ParentWindow := hWindow;
end;


The problem is when I set the form to stay on desktop using the code #2 the code #1 doesn't work, i.e. the form can't appear transparent.

These two code pieces work fine when tested separately.
My question is: Is there any way to put these two codes to work togheter?

Thanks
Unit1.pas
0
Comment
Question by:danival_lucas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:atul_parmar
ID: 33539171
Hi, try the following.

procedure TForm1.FormCreate(Sender: TObject);
var
  hWindow: hwnd;
begin
  //make it transparent first;
  AlphaBlend := True;
  AlphaBlendValue := 100; //0 = 100% transparent, 255 = opaque
  //
  hWindow := FindWindow(nil,PChar('Program Manager'));
  if hWindow <> 0 then Windows.SetParent(Handle, hWindow);
end;
0
 
LVL 13

Accepted Solution

by:
aflarin earned 1500 total points
ID: 33539424
When you the code #2, you make your form as child of 'Program Manager' window

I am afraid you can't make your form transparent then. Here is from MSDN:

WS_EX_LAYERED
Creates a layered window. Note that this cannot be used for child windows.  


0
 

Author Comment

by:danival_lucas
ID: 33544611
aflarin,
Thanks for your comment. This was very usefull to me. Now I'll start trying another options.

atul_parmar,
Your code worked in my test on Windows XP, but doesn't worked on Windows Vista (default theme) neither on Windows 7 (aero theme).
In these cases the window dissapear and only come back visible again when I choose Windows 7 Basic Theme or Windows Classic (on Vista).
Do you have any ideias why the window is not showed on these "more modern" themes?

Thank you!!!
0
 

Author Closing Comment

by:danival_lucas
ID: 33780824
Didn't solve the problem but gave directions to follow.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question