|
In what method (or function) is that code snippet located?
|
|
|
|
|
|
Well, I created a transparent window using WS_EX_TRANSPARENT. I downloaded the CxImage library from CodeProject. Built the libraries. Added the "us.png" file from the demo as a resource to my project, setup a WM_PAINT handler, dropped in your code snippet to my OnPaint, modified it to use my CPaintDC, verified that my drawing code for the view was being obscurred by the png to demonstrate that the transparent effect was correctly being implemented. I then dragged various windows over it, and scrolled the view so the transparent window fell out of the view client area, etc...
I cannot reproduce your issue. It is invalidated correctly and the WM_PAINT is called and the image is always reproduced (i.e. No eraser effect is observed). There are some occasional remnant areas that don't get invalidated when using WS_POPUP. Are you using WS_POPUP or WS_CHILD?
It does however, flicker because of the drawing sequence inherent in using WS_EX_TRANSPARENT. This was expected as I've never found WS_EX_TRANSPARENT very useful in past attempts at using it (except for mouse pass-through).
I'm not sure how to reproduce your issue without more data. However, since I'm confident that you will probably not like the flicker you'll get once you get it all worked out, I would recommend using WS_EX_LAYERED as it is possible to get some pretty smooth results with almost no flicker. It also has a more versatile mouse pass-through effect and you can always use WS_EX_TRANSPARENT to allow mouse messages to pass through the whole window while using WS_EX_LAYERED.
Anyway, if you can give me more detail on your window creation, I might have better luck at reproducing your issue. Regardless, consider WS_EX_LAYERED instead if you can.
|
|
|
|
|
Well i tried with WX_EX_LAYERED and SetLayeredWindowAttributes with opacity 0. But that makes my whole window transparent including that PNG.. Anyways here's my whole code.. Please take a look..
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include "..\cximage600_full\CxImage\ximage.h"
#include ".\resource.h"
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
HINSTANCE hGlobalInst = NULL;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
hGlobalInst = hInstance;
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
ZeroMemory(&wndclass,sizeof(WNDCLASSEX));
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (NULL_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = "WndProc";
if (!RegisterClassEx (&wndclass))
{
MessageBox (NULL, "Registration Fails","Error", MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW | WS_EX_LAYERED,
"WndProc",
NULL, WS_POPUP, 1, 1, 170, 45,
NULL,
NULL,
hInstance,
NULL) ;
if(!hwnd)
{
MessageBox (NULL, "Window Creation Fails","Error", MB_ICONERROR) ;
return 0 ;
}
DWORD eRR1 = GetLastError();
ShowWindow (hwnd, iCmdShow) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.lParam;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps ;
RECT rect;
GetWindowRect(hWnd, &rect);
switch (message)
{
case WM_PAINT:
{
HDC hdc = GetDC(NULL);
hdc = BeginPaint (NULL, &ps) ;
CxImage* image = new CxImage();
image->LoadResource(FindResource(NULL,MAKEINTRESOURCE(IDR_PNG1),"PNG"),CXIMAGE_FORMAT_PNG);
BOOL iReturn = image->Draw(hdc, 1, 1);
EndPaint (NULL , &ps) ;
break;
}
default: return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
</windows.h>
|
|
|
|
|
May be i'm doing something wrong in CreateWindowEx.. Can you please post your code..
Thanks.
|
|
|
|
|
Hello,
I am working on an mfc application. In it I am using a static control and a checkbox.
I am using a Picture control on top of it i have placed the checkbox and static control.
The problem is that the background of checkbox and static control is not tranparent as a result of which the picture colour and background colours of the controls are not matching..
please help me.
Thanks & regards.
Dhiraj Kumar Saini
|
|
|
|
|
You might want this.
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC) wParam;
HWND hwndStatic = (HWND) lParam;
HBRUSH hbrBkcolor = (HBRUSH)GetStockObject(NULL_BRUSH);
if (hwndStatic == GetDlgItem(hWnd, IDC_STATIC_CONTROL))
{
SetBkMode(hdc, TRANSPARENT);
return (LRESULT) hbrBkcolor;
}
break;
}
Same stuff do with your Check Box also..
Hope this help.
|
|
|
|
|
I am using MFC and not win32 .
Please help me with MFC code as i dont know win32.
Thanks
|
|
|
|
|
|
Its not working. Please tell me whats the problem.
|
|
|
|
|
Please tell him what is not working. Unless one of you two has psychic powers, you need to help him to help you.
Iain.
|
|
|
|
|
I also think so...
|
|
|
|
|
Greets.
You could try handling the WM_CTLCOLOR (or WM_CTLCOLORBTN and/or WM_CTLCOLORSTATIC) messages in the parent window and return a NULL brush. Am not sure that would work, haven't tried it but it's worth a shot.
AtomAnt
- If God wanted man to code, man would have been born without the need to sleep.
|
|
|
|
|
Hi all,
please tell me how can i get Hard Drive Modal details,like Modal Number or Serial Number.
please help me for this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
|
See here
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
You can use Win32_DiskDrive[^] WMI class. Check Model property.
Sohail
modified on Thursday, November 13, 2008 4:44 AM
modified 21-Apr-21 21:01pm.
|
|
|
|
|
How to get disk's capacitance of remote computer with ip?
|
|
|
|
|
You can use Win32_DiskDrive[^] WMI class.
Sohail
modified on Thursday, November 13, 2008 4:47 AM
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Are you sure capacitance is the word you're looking for? If so, why would you need to know such low-level (i.e., electronics) information?
Perhaps you're looking for GetDiskFreeSpaceEx() instead?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
in my programme,OnDragOver/OnDropEx cannot be executed(can compile), but i dont know why...
the code is:
(thanks!)
--------
A.h
--------
class A: public CStatic
{
... ...
protected:
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnDrop(WPARAM pDropInfoClass, LPARAM lParm);
afx_msg DROPEFFECT OnDropEx(WPARAM pDropInfoClass, LPARAM lParm);
afx_msg DROPEFFECT OnDragOver(WPARAM pDropInfoClass, LPARAM lParm);
DECLARE_MESSAGE_MAP()
protected:
COleDropTargetEx m_dropEx;
static WORD s_wNvrChnClipboardFormat;
... ...
}
----
A.cpp
----
WORD A::s_wNvrChnClipboardFormat = 0X0;
BEGIN_MESSAGE_MAP(A, CStatic)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_WINDOWPOSCHANGED()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
ON_WM_CREATE()
ON_MESSAGE(DROPM_DRAGOVER,OnDragOver)
ON_MESSAGE(DROPM_DROPEX,OnDropEx)
ON_MESSAGE(DROPM_DROP,OnDrop)
END_MESSAGE_MAP()
int A::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
s_wNvrChnClipboardFormat = RegisterClipboardFormat(NAME_NC_NVRCHN_CLPFMT);
BOOL bRet = m_dropEx.Register (this);
ASSERT(bRet);
return 0;
}
DROPEFFECT A::OnDragOver(WPARAM pDropInfoClass,LPARAM lParm)
{
COleDropInfo* pInfo = (COleDropInfo* )pDropInfoClass;
ASSERT(pInfo->IsKindOf(RUNTIME_CLASS(COleDropInfo)));
if( pInfo->m_pDataObject->IsDataAvailable(s_wNvrChnClipboardFormat) )
return DROPEFFECT_COPY;
else
return DROPEFFECT_NONE;
}
DROPEFFECT A::OnDropEx(WPARAM pDropInfoClass, LPARAM lParm)
{
return (DROPEFFECT)-1;
}
modified on Thursday, November 13, 2008 1:54 AM
|
|
|
|
|
ok,i get it!
because i Register in OnCreate...
|
|
|
|
|
i want to create shortcut for my application. while doing set up for appication, that shortcut should get created.
thanks in advance
|
|
|
|
|
|
Hi All
How can i get folder size in vc++?Please help me
|
|
|
|
|