|
I like to do a “printscreen” on a window. Can I use the windows HWND to accomplish that in some way?
All tips are welcomed.
_____________________________
...and justice for all
APe
|
|
|
|
|
search for "screen capture" in articles of the forum, u can find some samples - also in VC CD (samples).
A nice hyper tool for optimizing your Microsoft html-help contents.
A best image tool for Windows C++ programmers, don't miss it!.
Includeh10
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I have the below code:
There is a classs"CPaintDC".
Can anyone please tell me what is the difference between the following 2 statements:
1.)CPaintDC *pDC = new CPaintDC(this);
2.)CPaintDC* pDC=new CPaintDC;
|
|
|
|
|
1. calls the CPaintDC contructor which receives a CWnd* parameter, and initializes it with the this pointer passed,
2. calls the CPaintDC default constructor...
|
|
|
|
|
DC is related to Window, in other words, we say "a DC of a window".
1) the DC of "this" window - similar to ::GetDC(this->m_hWnd);
2) the DC of screen - similar to ::GetDC(0).
A special image tool for Windows C++ programmers, don't miss it!
A nice hyper tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
Hi all
I have such question :
I often see following things in other people's code :
object.SomeFunction(BS_STYLE1 | BS_STYLE2 | BS_STYLE3)
and then after execution all those three styles are set to
the object .
How is this implemented inside the function ?
Can anybody clarify, or bring an example ?
thank you.
PS. For example this API uses such thing too :
ListView_SetExtendedListViewStyle(m_list, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
|
|
|
|
|
Actually it is a DWORD in the function:
void ListView_SetExtendedListViewStyle(HWND hwndLV,DWORD dwExStyle);
And this one is:
#define LVS_EX_FULLROWSELECT 0x00000020
this is this.
|
|
|
|
|
thank you khan, but my question was how is it achieved inside the function that after writing
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES
both styles are set.
And if I write only LVS_EX_FULLROWSELECT then only this style is set.
|
|
|
|
|
Actually it is just a parameter like any other. The actual code inside the function handles the values passed, which can be anything.
It maybe like:
void func(DWORD dwStyle)
{
m_dwStyle = dwStyle;
RedrawWindow();
}
//some draw function for the control:
void Draw()
{
if (m_dwStyle & LVS_EX_FULLROWSELECT)
{
}
else
{
}
}
this is this.
|
|
|
|
|
It's called BitWise. CP has loads of articles on it if you do a search, however this is[^] a particulary good one.
All the function is doing is something like:
void SomeFunction( DWORD dwFlags )
{
if( dwFlags & BS_STYLE2 )
{
DoSomething( );
}
}
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
i don't exactly get you ; however, if i understand well, you want to know this :
let go deeper in the instruction BS_STYLE1 | BS_STYLE3 | BS_STYLE6 .
firstly, we need to know what are defined those constants like.
let's consider they're declared this way :
enum {
BS_STYLE1 = 1,
BS_STYLE2 = 2,
BS_STYLE3 = 4,
BS_STYLE4 = 8,
BS_STYLE5 = 16,
BS_STYLE6 = 32
};
to understand why these constants' values are chosen, we must go in binary representation to understand :
1 -> 0b 00000000 00000000 00000000 00000001
2 -> 0b 00000000 00000000 00000000 00000010
4 -> 0b 00000000 00000000 00000000 00000100
8 -> 0b 00000000 00000000 00000000 00001000
16 -> 0b 00000000 00000000 00000000 00010000
32 -> 0b 00000000 00000000 00000000 00100000
notice that for those special values that are multiples of 2, only one bit is set at a time, all the others are equal to 0 .
the interrest in this is that each bit is a flag for a functionnality (style here), and we can mix them in once variable to avoid using as many booleans as we need flags.
for example, see the following case :
0b 00000000 00000000 00000000 00100101
Flags of <code>Style6</code>, <code>Style3</code> and <code>Style1</code> are set
now, as we don't handle binary directly in C++, we use bitwise operators instead.
what you see as that vertical bar | is the bitwise OR operator.
the OR operator works like this :
x y |
--------
0 0 0
0 1 1
1 0 1
1 1 1
in the case of the instruction BS_STYLE1 | BS_STYLE3 | BS_STYLE6 , it so OR s like this :
0b 00000000 00000000 00000000 00000001 <- BS_STYLE1
0b 00000000 00000000 00000000 00000100 <- BS_STYLE3
0b 00000000 00000000 00000000 00100000 <- BS_STYLE6
-----------------------------------------------
0b 00000000 00000000 00000000 00100101 <- BS_STYLE1 | BS_STYLE3 | BS_STYLE6
Now, the "mix value" is constructed, we can pass it to a function.
but how does the function know which bits are set, and which are not ?
easy... follow me !
Lets say we want to know if the bit of BS_STYLE1 is set from the mix we get in parameter (let's call it MIX_VAR.
we must create a maskwhich we'll AND with the :
STYLE1_MASK = 0b 00000000 00000000 00000000 00000001
as you see, the mask is the same as the STYLE constant, so in practice, you'll never see defined such mask :
MIX_VAR -> 0b 00000000 00000000 00000000 00100101
MASK1 -> 0b 00000000 00000000 00000000 00000001
----------------------------------------
<code>Bitwise AND</code> 0b 00000000 00000000 00000000 00000001
if the result is equal to the STYLE1, then it is because the bit was set. otherwise, you get 0 .
ok, now, in practice, here is how you'll often see it :
void fooFunc(DWORD dwMix) {
if (BS_STYLE1 & dwMix) == BS_STYLE1) {
}
else if (BS_STYLE2 & dwMix) == BS_STYLE2) {
}
else if (BS_STYLE3 & dwMix) == BS_STYLE3) {
}
}
wow, that's very long finally... hum, well, i hope it will help, truly !
|
|
|
|
|
Nice !
VuNic
|
|
|
|
|
Excellent explanation!
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
i think you should write an article on this thanks
|
|
|
|
|
ok, in the todo list
thanks
|
|
|
|
|
Thanks
modified 28-Sep-16 7:28am.
|
|
|
|
|
Have you tried posing this question here, or downloading the latest version from here? Do you have access to an SMTP server?
Oliver Shikaloski wrote: ...I can only send mails that are the same type like mine.
Do you mean in your same domain?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Message Closed
modified 28-Sep-16 7:28am.
|
|
|
|
|
oliver_mak wrote: How do I fix this problem?
By trying my other three suggestions perhaps.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hello
I have Visual studio 2005. I have created a Win32app project with a dialogbox containing a treeview control. As I would like to have the dialogbox in the client part of my window i have added the handle of WM_CREATE message in the MainWndProc like this :
switch (message)<br />
{<br />
HANDLE_MSG(hWnd, WM_CREATE, WndProc_OnCreate);
and I have wrote :
BOOL WndProc_OnCreate(HWND hwnd,LPCREATESTRUCT ct)<br />
{<br />
HWND g_hViewDir;<br />
g_hViewDir = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SHOWDIR), hwnd, ShowdirDlgProc);<br />
if(g_hViewDir != NULL)<br />
{<br />
...<br />
}<br />
else<br />
return FALSE;<br />
return TRUE;<br />
}
No compilation error. When i launch the app the dialog does not appear. I have investigate and found that the error message comes out of the CreateDialog function and says : Error 1407 : Unknown window Class ????
Could someone help.
|
|
|
|
|
Check your linking into the Common Control library comctrl32.lib and calling InitCommonControlsEx[^] to initialize the library, finally also check your passing ICC_TREEVIEW_CLASSES as a flag so it knows to load the correct classes.
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Thanks a lot that solved my problem. But in the documentation of InitCommonControlsEx it says that it is not necessary to use it if we use a manifest. In that case i do not understand.
|
|
|
|
|
Hi together,
I have a big problem. I hope somebody can help me:
I implemented a service that runs under the local system account and checks if any screen blanker is activated. I use the following code:
bool result = false;
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (LPVOID) &result, 0); This works fine on Win XP, but on Win 2000 the function always return true. It is a known bug according to article number 318781 on MSDN.
The suggested workaround is to look for the entry "SCRNSAVE.EXE" under the registry key "HKCU\Control Panel\Desktop" using the following two lines:
RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ, &hKeyScrSave);
RegQueryValueEx(hKeyScrSave, "SCRNSAVE.EXE", NULL, NULL, (LPBYTE) szData, &dwData); Now the problem arises: As my service runs under the local system account, access to "HKEY_CURRENT_USER" is redirected to "HKEY_USERS\.DEFAULT".
So the result refers to the logon screen saver, which is (usually) always activated. But I only want this result if no user in logged in.
Therefore my question: Does anybody has a solution, how to check if a screen saver is active under 2000 like SystemParametersInfo(SPI_GETSCREENSAVEACTIVE) does it for XP? An idea how to access data under "HKEY_CURRENT_USER" from the local system account would also be very valuable for me.
Thank you very much for any hints,
Marcus.
|
|
|
|
|
Two quick things - first SystemParametersInfo(...) does not use C++ types, so you should be passing the address of a BOOL (an int , or 4-bytes under 32-bit MS), not a bool (1-byte under 32-bit MS).
Second, I am pretty sure that screen savers run on a separate desktop, the "screen saver desktop". Search MSDN for information on Window Stations and Desktops for more information.
If I am correct, you might be able to determine which desktop is active, and from that determine if a screen saver is running.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|