 |
|
|
 |
|
 |
Thanks for sharing your project.
Dr.Luiji
Trust and you'll be trusted.
Cryptography API: The Next Generation (CNG) - How to crypt documents with C++ programming, here.
|
|
|
|
 |
|
 |
Thank's a lot! Good article!
|
|
|
|
 |
|
 |
Great work man. Keep up the good work...!
|
|
|
|
 |
|
 |
Nice job!
It would be nice it the windows also closes smoothly.
|
|
|
|
 |
|
 |
Yes, that's good idea. but I think it's not necessary for all people.
Actually, closing smoothly is more simple than this.
I think you can add that function easily.
If you have any question, send me e-mail, I can help you.
my e-mail is yucco@naver.com
Thank you anyway.
|
|
|
|
 |
|
 |
Hi Youngman, (my english is not so good!)
I have a couple of questions for you:
a) I do not understand why you haven't used the function "SetLayeredWindowAttributes()" and related "#define" using the user32.h and user32.lib, instead of doing "LoadLibrary", "GetProcessAddress" and so on.
b) Why the transparency works with modal dialogs and not with modeless dialogs? With the last one I get the error "87-The Parameter is incorrect" with GetLastError.
Please reply asap: you work has been really interesting to me.
Thanks and regards.
|
|
|
|
 |
|
 |
yeah, here is my answer.
First, user32.h?? I think you mean winuser.h. Anyway The reason why I didn't use user32.lib is I failed using user32.lib.
I don't know why I failed using user32.lib but when I made this using user32.lib, I've got an LINK error like this "error LNK2001: unresolved external symbol __imp__SetLayeredWindowAttributes@16" well, surely I included winuser.h and user32.lib.
So I used a current way.
Second, You mean it doesn't work with modeless dialogs?? If you get the error 'GetLastError', It means that 'SetLayeredWindowAttributes' function fails.
If you send me e-mail with your source, I can help you. I think there is no problem to use with modeless Dialog. my e-mail is yucco@naver.com.
Thank you for your interest, GianniGP.
|
|
|
|
 |
|
 |
Hi Youngman,
it's true: it was "winuser.h".
Actually I cannot send you a source code: I tested those functionality inside my whole application. Also the application is completely written in C and not in C++.
To better explain my problem, is that SetLayeredWindowAttribute works with a dialog built with DialogBox() and with a window created with CreateWindow(). It doesn't work with a dialog built with the CreateDialog() function.
I cannot use DialogBox() because it is a modal dialog; I cannot use CreateWindow() because I cannot load dialogs built with the resource editor: hence, I have to use only CreateDialog().
If you can help me it will be great.
Regards, GianniGP.
|
|
|
|
 |
|
 |
I can understand your saying. If you didn't use MFC, you can't use this class 'CGlassDialog'. However this function is possible to use in Win32 Program as well. Just you should do coding by yourself but it's not difficult. Actually, this class is not necessary, just the reason why I made this is for a convenience of coding.
If you used Win32 for Dialog, probably you made any DialogProc function. If so, you can describe this function into there. For example, you can make any message case like WM_CREATE, WM_TIMER and so on.. and Into there, you can describe the function that make Dialog be transparent smoothly.
See the 'GlassClass.h' file. There are just 2 Message functions.
afx_msg void OnTimer(UINT nIDEvent);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
This 2 functions can be described as WM_CREATE and WM_TIMER in Win32 any DialogProc function.
Like this
switch( iMessage )
{
case WM_CREATE:
..
case WM_TIMER:
..
}
Anyway, Refer to the 2 functions in 'GlassDialog.cpp' and Do coding. Probably you can do easily I think.
p.s
If you can't understand my explain, tell me again. As I said, my English is really not good.
|
|
|
|
 |
|
 |
Hi Youngman,
as you understood, I cannot use your class because I'm on C and not C++ language. But your work has been very useful for me.
For a window created with CreateWindowEx() I put the following code inside the WindowProc, in the "case WM_CREATE", and it works:
SetWindowLong(hwnd,
GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);
For a dialog created with DialogBox() (modal dialog) I put the following code inside the DialogProc, in the "case WM_INITDIALOG", and it works:
SetWindowLong(hwnd,
GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);
For a dialog created with CreateDialog() (modeless dialog) I put the following code inside the DialogProc, in the "case WM_INITDIALOG", and it DON'T works:
SetWindowLong(hwnd,
GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);
What I need is to make work the modeless dialog created with CreateDialog().
I do not know (really) too much about C++ and MFC; can you do a test for me with the above three different windows and tell me what happens to your CGlassDialog? This will be great for me.
Actualy I don't care about the way to make a dialog become smoothly transparent (even though your example with SetTimer() works). First of all I need to solve the one and only problem with CreateDialog().
Thanks again. Bye.
PS: I think that with our poor english we will understand each other, isn't?
|
|
|
|
 |
|
 |
Here is a sample code and I'm sure there is no problem.
I hope this code will be your help.
int nGlass = 0; // nGlass must be Global variable.
When you creat Dialog in 'WndProc' function, you may do like this.
nGlass = 0;
hWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)About);
ShowWindow(hWnd, SW_SHOW);
This is the function for making Transparent Dialog.
void MakeGlass(HWND hWnd)
{
SLWA pSetLayeredWindowAttributes = NULL;
HINSTANCE hmodUSER32 = LoadLibrary("USER32.DLL");
pSetLayeredWindowAttributes = (SLWA)GetProcAddress(hmodUSER32,"SetLayeredWindowAttributes");
SetWindowLong(hWnd, GWL_EXSTYLE,GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
pSetLayeredWindowAttributes(hWnd, 0, (255 * nGlass) / 100, LWA_ALPHA);
(nGlass >= 70) ? KillTimer (hWnd, IDT_TIMER) : nGlass += 1;
}
Finally, this is a 'DlgProc' fuction.
As I said, There are just 2 message event, WM_INITDIALOG and WM_TIMER.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
SetTimer(hDlg, IDT_TIMER, 10, NULL);
MakeGlass(hDlg);
GdiFlush();
Sleep(10);
return TRUE;
case WM_TIMER:
MakeGlass(hDlg);
return TRUE;
...
}
return FALSE;
}
Probably, you have any question or can't understand my explain, tell me again. but I think you can understand my explain like before.
|
|
|
|
 |
|
 |
Thanks Youngman,
testing your sample, I finally discovered why tranparency won't work with CreateDialog(). Infact, in the dialog editor, changing the flag from WS_CHILD to WS_OVERLAPPED or WS_POPUP, I get transparency to work.
Well we do find the solution to the problem: there is no way to use tranparency when a window is WS_CHILD. These give me other problems, but anyway we figured out the problem.
Thanks for your cooperation.
Until next, take care.
|
|
|
|
 |
|
 |
For first problem, I think you need updated Platform SDK that release with Windows 2000 or later to include SetLayeredWindowAttributes in user32.lib. If you are using Windows 2000 or later, your user32.dll will have SetLayeredWindowAttributes function but your user32.lib is not.
|
|
|
|
 |
|
 |
Thanks Youngman, this is a cool class.
Every once in a while the dialog flickers when it's first presented. Calling MakeGlass() before GdiFlush() seems to fix it:
int CGlassDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
dword id = SetTimer(IDT_TIMER, m_nInterval , NULL);
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
MakeGlass(); // prevent initial flicker
GdiFlush();
Sleep(10);
return 0;
}
|
|
|
|
 |
|
 |
ya, you are right! I couldn't think about that.
Thank you, jnapier. I'm going to change this source like your saying.
-- modified at 22:05 Thursday 10th August, 2006
|
|
|
|
 |
|
 |
It's fun, i like. Good job
|
|
|
|
 |
|
 |
Thank you, davidoff.
|
|
|
|
 |
|
 |
you must be a careful man.
,my english is not good too.
I think you are a guy which always makes everything perfect.
-- modified at 23:31 Tuesday 8th August, 2006
|
|
|
|
 |
|
 |
I got it. Thank you anyway.
-- modified at 5:22 Wednesday 9th August, 2006
|
|
|
|
 |
|
 |
I try your demo and it works fine.
I also try to make the projct about dialog box to be transparent and it does not working...
|
|
|
|
 |
|
 |
If you are OK, I want to help you. send me e-mail with your project files.
my e-mail address is yucco@naver.com
|
|
|
|
 |
|
 |
I try it on your demo project. I just derive the about dialog from CGlassDialog
see:
// GlassTestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GlassTest.h"
#include "GlassTestDlg.h"
#include "GlassDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CGlassDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CGlassDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
Just select the about box...
|
|
|
|
 |
|
 |
Did you change this part in 'GlassTest.cpp'??
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
if you didn't, you must change also this part.
BEGIN_MESSAGE_MAP(CAboutDlg, CGlassDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
-- modified at 9:56 Tuesday 8th August, 2006
|
|
|
|
 |
|
 |
Thanks, it works, great job.
|
|
|
|
 |