From: Mikel on 8 Oct 2009 02:27 On Oct 8, 7:33 am, Matrixinline <anup.kata...(a)gmail.com> wrote: > Hi All, > > Can you please tell me how to make CFileDialog, MessageBox, Tooltips > layered. > > I tried to extend the CFileDialog and in the OnInitDialogMethod I have > written following line but it did not changed anything for it. > > BOOL bTrue = ModifyStyleEx(0, WS_EX_LAYERED); > SetLayeredWindowAttributes(0,20,LWA_ALPHA); > > Please let me know how to make the dialog layered. > > Thanks > Anup Well, I've never done this, but in http://msdn.microsoft.com/en-us/library/ms997507.aspx you can read: "For any layering to take place, the WS_EX_LAYERED bit needs to be set, either at window creation time or by calling SetWindowLong with GWL_EXSTYLE" And gives an example: // Set WS_EX_LAYERED on this window SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); // Make this window 70% alpha SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA); So it seems that you have to use SetWindowLong, not ModifyStyleEx, or create it as layered. But as I said at the start, I've never done this.
From: Matrixinline on 9 Oct 2009 05:15 On Oct 7, 11:27 pm, Mikel <mikel.l...(a)gmail.com> wrote: > On Oct 8, 7:33 am, Matrixinline <anup.kata...(a)gmail.com> wrote: > > > Hi All, > > > Can you please tell me how to make CFileDialog, MessageBox, Tooltips > > layered. > > > I tried to extend the CFileDialog and in the OnInitDialogMethod I have > > written following line but it did not changed anything for it. > > > BOOL bTrue = ModifyStyleEx(0, WS_EX_LAYERED); > > SetLayeredWindowAttributes(0,20,LWA_ALPHA); > > > Please let me know how to make the dialog layered. > > > Thanks > > Anup > > Well, I've never done this, but inhttp://msdn.microsoft.com/en-us/library/ms997507.aspx > you can read: > "For any layering to take place, the WS_EX_LAYERED bit needs to be > set, either at window creation time or by calling SetWindowLong with > GWL_EXSTYLE" > And gives an example: > > // Set WS_EX_LAYERED on this window > SetWindowLong(hwnd, GWL_EXSTYLE, > GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); > // Make this window 70% alpha > SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA); > > So it seems that you have to use SetWindowLong, not ModifyStyleEx, or > create it as layered. But as I said at the start, I've never done this. No even it did not helped me. Please let me know if I am doing wrong Here is the code class CMySaveAsDialog : public CFileDialog { public: CMySaveAsDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL, DWORD dwSize = 0 ):CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName , dwFlags , lpszFilter , pParentWnd , dwSize ) {}; virtual BOOL OnInitDialog() { CFileDialog::OnInitDialog(); BOOL bTrue = ModifyStyleEx(WS_EX_TRANSPARENT, WS_EX_LAYERED); SetLayeredWindowAttributes(0,20,LWA_ALPHA); SetWindowLong(this->m_hWnd, GWL_EXSTYLE, GetWindowLong(this->m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); // Make this window 70% alpha SetLayeredWindowAttributes( 0, 10, LWA_ALPHA); RedrawWindow( NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); return TRUE; }; };
From: Scot T Brennecke on 10 Oct 2009 02:11 Matrixinline wrote: > On Oct 7, 11:27 pm, Mikel <mikel.l...(a)gmail.com> wrote: >> On Oct 8, 7:33 am, Matrixinline <anup.kata...(a)gmail.com> wrote: >> >>> Hi All, >>> Can you please tell me how to make CFileDialog, MessageBox, Tooltips >>> layered. >>> I tried to extend the CFileDialog and in the OnInitDialogMethod I have >>> written following line but it did not changed anything for it. >>> BOOL bTrue = ModifyStyleEx(0, WS_EX_LAYERED); >>> SetLayeredWindowAttributes(0,20,LWA_ALPHA); >>> Please let me know how to make the dialog layered. >>> Thanks >>> Anup >> Well, I've never done this, but inhttp://msdn.microsoft.com/en-us/library/ms997507.aspx >> you can read: >> "For any layering to take place, the WS_EX_LAYERED bit needs to be >> set, either at window creation time or by calling SetWindowLong with >> GWL_EXSTYLE" >> And gives an example: >> >> // Set WS_EX_LAYERED on this window >> SetWindowLong(hwnd, GWL_EXSTYLE, >> GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); >> // Make this window 70% alpha >> SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA); >> >> So it seems that you have to use SetWindowLong, not ModifyStyleEx, or >> create it as layered. But as I said at the start, I've never done this. > > No even it did not helped me. > > Please let me know if I am doing wrong > Here is the code > > class CMySaveAsDialog : public CFileDialog > { > public: > CMySaveAsDialog(BOOL bOpenFileDialog, > LPCTSTR lpszDefExt = NULL, > LPCTSTR lpszFileName = NULL, > DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, > LPCTSTR lpszFilter = NULL, > CWnd* pParentWnd = NULL, > DWORD dwSize = 0 > ):CFileDialog(bOpenFileDialog, > lpszDefExt, > lpszFileName , > dwFlags , > lpszFilter , > pParentWnd , > dwSize ) > > {}; > > > virtual BOOL OnInitDialog() > { > CFileDialog::OnInitDialog(); > BOOL bTrue = ModifyStyleEx(WS_EX_TRANSPARENT, WS_EX_LAYERED); > SetLayeredWindowAttributes(0,20,LWA_ALPHA); > > SetWindowLong(this->m_hWnd, GWL_EXSTYLE, GetWindowLong(this->m_hWnd, > GWL_EXSTYLE) | WS_EX_LAYERED); > // Make this window 70% alpha > SetLayeredWindowAttributes( 0, 10, LWA_ALPHA); > RedrawWindow( NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | > RDW_ALLCHILDREN); > > return TRUE; > }; > }; Two things are important to know about CFileDialog: 1) It doesn't wrap the entire window as most dialog classes do. The common dialogs, especially the common file dialog, require special handling, and the behavior will vary based on the OS you are targeting. http://msdn.microsoft.com/en-us/library/5fcd0hw9.aspx http://msdn.microsoft.com/en-us/library/dk77e5e7.aspx 2) Changing things in OnInitDialog for any CDialog class (especially after the base class call) is too late to be changing such things. You would need to hook into the window creation methods. However, in CFileDialog, because it is "special", even then it is unlikely to be effective. Customizing the common file dialog is a very difficult thing to accomplish, and requires lots of research and experimentation.
From: David Ching on 10 Oct 2009 11:13 "Scot T Brennecke" <ScotB(a)Spamhater.MVPs.org> wrote in message news:uy0rSCXSKHA.764(a)TK2MSFTNGP02.phx.gbl... > Customizing the common file dialog is a very difficult thing to > accomplish, and requires lots of research and experimentation. I believe nothing short of a WH_CBT hook would be enough to set the layered mode. -- David
From: Joseph M. Newcomer on 10 Oct 2009 19:12 See below... On Wed, 7 Oct 2009 23:27:19 -0700 (PDT), Mikel <mikel.luri(a)gmail.com> wrote: >On Oct 8, 7:33�am, Matrixinline <anup.kata...(a)gmail.com> wrote: >> Hi All, >> >> Can you please tell me how to make CFileDialog, MessageBox, Tooltips >> layered. >> >> I tried to extend the CFileDialog and in the OnInitDialogMethod I have >> written following line but it did not changed anything for it. >> >> BOOL bTrue = ModifyStyleEx(0, WS_EX_LAYERED); >> SetLayeredWindowAttributes(0,20,LWA_ALPHA); >> >> Please let me know how to make the dialog layered. >> >> Thanks >> Anup > >Well, I've never done this, but in http://msdn.microsoft.com/en-us/library/ms997507.aspx >you can read: >"For any layering to take place, the WS_EX_LAYERED bit needs to be >set, either at window creation time or by calling SetWindowLong with >GWL_EXSTYLE" >And gives an example: > >// Set WS_EX_LAYERED on this window >SetWindowLong(hwnd, GWL_EXSTYLE, > GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); >// Make this window 70% alpha >SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA); > > >So it seems that you have to use SetWindowLong, not ModifyStyleEx, or >create it as layered. But as I said at the start, I've never done this. **** This statement makes no sense whatsoever. The statement about layered windows is suggesting one of the possible implementations required to set the extended style bits. Spending less than a minute reveals that the definition is BOOL PASCAL CWnd::ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd, UINT nFlags) { return _AfxModifyStyle(hWnd, GWL_EXSTYLE, dwRemove, dwAdd, nFlags); } and it takes another ten seconds to discover that AFX_STATIC BOOL AFXAPI _AfxModifyStyle(HWND hWnd, int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UINT nFlags) { ASSERT(hWnd != NULL); DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset); DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; if (dwStyle == dwNewStyle) return FALSE; ::SetWindowLong(hWnd, nStyleOffset, dwNewStyle); if (nFlags != 0) { ::SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags); } return TRUE; } which is to say, GUESS WHAT, "ModifyStyleEx" uses "SetWindowLong" with "GWL_EXSTYLE", thus conforming to the requirement. Perhaps you do not understand MFC? joe Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: "Lock" splitter bar Next: How to convert const char * to wchar_t |