|
To do this, Firstly capture the desktop image.
then do the following steps.
1. Draw the captured image.
2. Draw the invererted image of captured image over it.
some vc++ code snippet to help you:-
void OnDraw( CDC* pDC_i )
{
if( 0 != m_NormalImage )
{
CDC MemDc;
MemDc.CreateCompatibleDC( pDC_i );
CImage *pOldImage = MemDc.SelectObject( m_NormalImage );
CRect rect;
GetClientRect( &rect );
rect.left = HEADER_OFFSET;
rect.right = max( rect.Width(), 300 ) + HEADER_OFFSET;
rect.top = HEADER_OFFSET;
rect.bottom = HEADER_OFFSET + HEADER_HEIGHT ;
COLORREF CurrentBkgd = pDC_i->SetBkColor( IMAGE_HEADER_BKGDCOLOR );
pDC_i->SetBkColor( CurrentBkgd );
pDC_i->BitBlt( 0, HEADER_OFFSET + HEADER_HEIGHT + HEADER_OFFSET , m_nWidth, HEADER_OFFSET + m_nHeight + HEADER_HEIGHT + HEADER_OFFSET,
&MemDc, 0, 0, SRCCOPY );
if( m_bInvertStatus && 0 != m_pInverseImage )
{
DrawInverseImage( pDC_i );
}
MemDc.SelectObject( pOldImage );
MemDc.DeleteDC();
}
}
void SetInvertImage( HBITMAP himageinverse_i)
{
m_pinverseImage = new CBitmap();
m_pinverseImage->Attach( himageinverse_i);
}
void DrawInvertImage( CDC* pDC_i )
{
if( 0 !=m_pinverseImage )
{
CDC Memdc;
Memdc.CreateCompatibleDC( pDC_i );
CBitmap *pOldBitmap = dcMem.SelectObject(m_inverseImage );
pDC_i->BitBlt( 0, HEADER_OFFSET + HEADER_HEIGHT + HEADER_OFFSET, m_nWidth, HEADER_OFFSET + m_nHeight + HEADER_HEIGHT + HEADER_OFFSET,
&dcMem, 0, 0, SRCINVERT );
dcMem.SelectObject( pOldBitmap );
dcMem.DeleteDC();
}
}
Now screen will be fully black.
3. Now make the inverted image part as transparent of your wish, just refer this article.([^])
I think your task is achieved
Величие не Бога может быть недооценена.
modified on Tuesday, October 20, 2009 12:02 AM
|
|
|
|
|
Thanks all. Capturing the desktop as an image and then altering that seems like the way forward. I've been researching GDI+ and the Effect Class, and I plan on trying the BrightnessContrast Class tomorrow. I'll draw the normal rectangle area using the original desktop image. And use a window layered over the top of the desktop. Sounds like a plan.
|
|
|
|
|
Neville Franks wrote: I understand how to make a window transparent, but that's not what I'm after.
I think you can do this by creating one window in the excat size of the desktop. In the erase background function first fill the background of dialog with black color. After that bitblt the content of the desktop DC to the dialog( try the SRCPAINT flag in the bitblt ). Now after that paint the rectangle that you want to show without darkening using bitblt again( this time specify SRCCOPY in it ).
|
|
|
|
|
Thanks, see my reply to ARJ 09 above.
|
|
|
|
|
As the other replies said, the trick is to take a snapshot of the desktop, then put a window on top using that image.
To make the area outside your selection be a bit darker, rather than black, I used GDI+:
In the following, I've already attached a Graphics object to a HDC, pts is an array of PointF's, and nPoints is the size of that array.
You could just make a rectangular exclude-from-shading area too, of course.
CRect rcClient;
GetClientRect (&rcClient);
Color clrBrush (128,0,0,0);
SolidBrush brush (clrBrush);
GraphicsPath path;
path.AddPolygon (pts, nPoints);
Region region (Rect (rcClient.left, rcClient.top, rcClient.Width (), rcClient.Height ()));
region.Exclude (&path);
gfx.FillRegion (&brush, ®ion);
This does the effect over the whole of a window - your window will probably be larger than mine, but the point remains.
I hope that helps,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Thanks Iain, see my reply to ARJ 09 above.
|
|
|
|
|
I want to modify MSPaint's Save file dialog's default file type to JPG using SetWindowsHookEx In the hook function what message should I look for to get at GetSaveFileName ?
|
|
|
|
|
Patcher32 wrote: I want to modify MSPaint's Save file dialog's default file type to JPG using SetWindowsHookEx
I don't know that you can hook into another program without replacing a dll that is used by the application. And even if you did, you still need to figure out what message MSPaint uses to signal File Save. However, if you do figure out how to do this I would be very interested in the solution.
|
|
|
|
|
I have following header file defines
test2.h ----------> header file
template<class T>
class temp2
{
public:
temp2();
virtual ~temp2();
};
test1.h ----------> header file
template<class T>
class temp1
{
public:
temp1(temp2<T> (temp2<T> *temp2ptr);
~temp1(temp2<T> ();
protected:
temp2<T> *tempptr;
};
test3.h -------------> header file
class test3
{
public:
test3();
virtual ~test3();
};
template<class T> temp1<T>::temp1(temp2<T> *temp2ptr)
{
tempptr = temp2ptr;
}
main.h ----------> header file
temp1 *maintemp1;
temp2<test3> maintemp2;
and in main.cpp -------> source file I am creating an object for this like given below
maintemp1 = new temp1(&maintemp2);
Now when I compile I am getting error
error C2955: 'temp1' : use of class template requires template argument list
can any body tell me what is the wrong with my code block ..
modified on Monday, October 19, 2009 4:13 PM
|
|
|
|
|
Please format properly the code snippet using the code block button.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
temp1 is a class template. You haven't provided any template arguments when using temp1. How could the error message possibly be any clearer?
You need to declare maintemp1 as:
temp1<test3> *maintemp1;
and use it like this:
maintemp1 = new temp1<test3>(&maintemp2);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Is it possible for a service under windows XP to hook for example mouse or keyboard?
I have tried to call SetWindowsHookEx inside a windows service but the callback
function receives no messages. If yes how can it be done.
I know already about desktop interactive option for a service and SetTheadDesktop etc but none
of them work. I also tried impersonation, to give the hooking thread a specific process token
no luck there too.
Thanx
|
|
|
|
|
I guess it will not work in the default SYSTEM account.
Check it by running the service in another user context.
|
|
|
|
|
I have the same problem.
Service sets out under the Admin account.
SetWindowsHookEx does not intercept the message, what's the problem?
|
|
|
|
|
I have the same trouble too.
|
|
|
|
|
I am writing a WinAPI app and trying to use some code to make a systray icon. However, when I pass in the HWND into the class as below:
.h
public:<br />
HWND m_hParentWnd;
.cpp
void CTrayIcon::OnCreate(HWND parent, UINT uCallbackMessage, HICON icon)<br />
{<br />
m_hParentWnd = parent;
there is an unhandled exception:
Unhandled exception at 0x00415799 in blueline.exe: 0xC0000005: Access violation writing location 0x00000004.
The contents of parent is:
parent: 0x000b0d30 {unused=??? }
unused = CXX0030: Error: expression cannot be evaluated
It wuld be amazing if someone could suggest a direction to look in. I have found somebody with a similar problem, but they didn't get a responce.
Nicola.
|
|
|
|
|
can you show us the code where you create your CTrayIcon instance, and when you call Create ?
|
|
|
|
|
In most of the cases, this is due to the fact that you are manipulating a pointer to a CTrayIcon instance, and this pointer is NULL.
|
|
|
|
|
Do you mean if you comment out this line
m_hParentWnd = parent; then everything works fine?
parent: 0x000b0d30 looks like a valid windows handle. no problem with that.
Since you are getting write access violation, it means you are trying to write to an invalid location, now which location is that and why it is invalid seems hard to tell with the information you have provided..
|
|
|
|
|
Okay, I was looking in the wrong place for issues. The CTrayIcon object isn't being set up correctly. Thank you all for your help, it's really appreciated!
Nicola.
|
|
|
|
|
Dear All,
I am not able to Find the Wrong with the Following Code.
Please Help me out.
SQLHENV envHandle;
SQLHDBC ConnHandle;
SQLHSTMT StmtHandle;
SQLRETURN Ret;
SQLSMALLINT szConnStroutlen;
SQLCHAR sZ_AuthorName[50];
SDWORD sdoutputDataLen;
unsigned char szConnStrout[255];
Ret = ::SQLAllocEnv(&envHandle);
Ret = ::SQLAllocConnect(envHandle,&ConnHandle);
Ret = ::SQLDriverConnect(ConnHandle,
NULL,(SQLWCHAR *)_T("Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\\Uday.mdb"),
SQL_NTS,(SQLWCHAR*)szConnStrout,sizeof(szConnStrout),&szConnStroutlen,SQL_DRIVER_NOPROMPT);
Ret = ::SQLAllocStmt(ConnHandle,&StmtHandle);
//To Fetch a Relative Record.
Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); //The Code is Failing here.
Thanks & Regards,
Uday.
|
|
|
|
|
janaswamy uday wrote: Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); //The Code is Failing here.
Why?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
janaswamy uday wrote: Ret = SQLFetchScroll(StmtHandle,SQL_FETCH_FIRST,0); //The Code is Failing here.
According to thedocumentation[^], you should be looking into the return value of the function, and then based on the return value, you should be able to identify the reason for failure (if any). Have you done the diagnostics? Why does it fail?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Dear Rajesh,
If i really know why should i post this message. I have really Struk with this. If you have any Idea please Help me Out. I am in deep trouble. I want to know this Concept. Please Help Me Out with proper Solution.
Thanks & Regards,
Uday.
|
|
|
|
|
janaswamy uday wrote: If i really know why should i post this message. I have really Struk with this. If you have any Idea please Help me Out. I am in deep trouble. I want to know this Concept. Please Help Me Out with proper Solution.
I'm sorry to know that you're in deep trouble.
The said function returns a value that you should check. If the function fails, the return value actually tells why did it fail so. Take a look at the "diagnostics" section of the documentation page to know more.
“Follow your bliss.” – Joseph Campbell
|
|
|
|