|
Thanks a lot. Its working now
|
|
|
|
|
I enjoy using types such as UINT as an alternative to unsigned int, which is all well and good if I have windows code in my project, however I have to manually define this in other projects that dont use any windows code. what I'd like to know is if it's possible to do something along the lines of the following...
#ifdef UINT
typedef UINT unsigned int;
#endif
I have a feeling that code doesn't do what I want, so I'm asking, does it, or doesn't it?
|
|
|
|
|
These datatypes are defined in Windef.h . Therefore,
#ifndef _WINDEF_
typedef unsigned int UINT;
#endif
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
thanks, that will do nicely
|
|
|
|
|
Hi all, is there anyway to write ("%d %lf %lf %lf\n", psn[i], px[i], py[i], pz[i]) into a CStdioFile or CFile? I also wish to know for read function.
CStdioFile test;
test.Write("%d %lf %lf %lf\n", psn[i], px[i], py[i], pz[i]);
test.Read(("%d %lf %lf %lf\n", psn[i], px[i], py[i], pz[i]);
How can i do read and write in thoes format?
Please help me out. Thanks alot.
|
|
|
|
|
You first need to convert it to a string and then write the string.
CStdioFile file(_T("C:\\test.txt"), CFile::modeReadWrite);
CString text;
text.Format(_T("%d %lf %lf %lf\n"), psn[i], px[i], py[i], pz[i]);
file.WriteString(text, text.GetLength());
file.ReadString(text);
|
|
|
|
|
Thanks for replied. It's can't work. My output result is all wrong.
|
|
|
|
|
I agree with Superman's reply to you, so you need to give more information than "all wrong".
When you use the debugger, was the contents of the intermediate string object correct?
If so, is the text file full of the right stuff, but with NULL's in between? In which case you have a unicode vs ascii issue.
"All wrong" is bad answer to just about anything, whether it's a coding question, or from your doctor.
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/[ ^]
|
|
|
|
|
|
Hi, I am trying to work out how to darken the Windows Desktop and then display a rectangular portion of the desktop normally (not darkened). This is for a screen area capture program. You can see the precise effect I am after in Jing http://www.jingproject.com/[^].
I understand how to make a window transparent, but that's not what I'm after.
Fading the background in a Web page is also commonly done. Any tips/pointers/C++ source much appreciated. Google has not helped so far.
modified on Monday, October 19, 2009 10:33 PM
|
|
|
|
|
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.
|
|
|
|
|