|
Trollslayer wrote: case uses ordinal values...
Did you mean integral here?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi.
i would like to get the content (graphics) of a window whose HWND i have, but it is not visible (meaning, visible as in WM_VISIBLE, but not to the human eye i.e. concealed by other windows).
And i would like to do this without bringing the window to the front, as this takes too much time.
i tried the following:
<pre>
HDC hdcWind = GetDC(windowHWND);
HDC hdcComp = CreateCompatibleDC(hdcWind);
HBITMAP hbmWind = CreateCompatibleBitmap(hdcWind,
GetDeviceCaps(hdcWind, HORZRES),
GetDeviceCaps(hdcWind, VERTRES));
SelectObject(hdcComp,hbmWind);
BitBlt(hdcComp,0,0,100,100,hdcWind,0,0,SRCCOPY);
</pre>
Then to display the result i did:
<pre>
HDC hdcScreen = CreateDC("DISPLAY",NULL,NULL,NULL);
BitBlt(hdcScreen,0,0,100,100,hdcComp,0,0);
ReleaseDC(hdcWind);
</pre>
It draws an image onto the left top corner of my screen. The size is correct and the top left corner of the drawing is even taken from the correct point (top left corner of the windowHWND !!). But the contents of the drawing is the background at the moment of execution. As if he gets the window, uses its position to take the "picture", but the window is "invisible" and gets only the background.
Every and any help will be much appreciated.
Thank you
imran
|
|
|
|
|
I am not sure but try sending the WM_PRINT meesage to the window.
In ur case pass the hdcComp as the wparam of the message. i think u will get the screenshot of the window in that dc.
nave
|
|
|
|
|
I tried it just now. But the drawing is all completely black. It doesnt even print the NONCLIENT area.
I tried:
<pre>
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CLIENT | PRF_NONCLIENT);
</pre>
and
<pre>
SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT);
</pre>
Shouldnt it always be able to print the title bar etc. no matter which app. made the window? What does that mean, if everything is black.
thanks again
imran
|
|
|
|
|
i tried it here, Its just working fine. see the code below( sorry that its mfc )
ShowWindow( FALSE );<br />
CWindowDC dc(this);<br />
CRect WindRect;<br />
GetWindowRect( WindRect );<br />
m_MemDC.CreateCompatibleDC( &dc );<br />
m_bmp.CreateCompatibleBitmap( &dc, WindRect.Width(), WindRect.Height());<br />
m_MemDC.SelectObject( &m_bmp );<br />
SendMessage( WM_PRINT, (WPARAM)m_MemDC.m_hDC,PRF_CLIENT | PRF_NONCLIENT|PRF_ERASEBKGND);<br />
CWindowDC Desk(0);<br />
Desk.BitBlt( 0,0,WindRect.Width(), WindRect.Height(), & m_MemDC,0,0,SRCCOPY );
The above code paints the window to the desktop.
nave
|
|
|
|
|
hmmm....sorry to ask you this, but i am really a beginner at windows programming
-my ShowWindow doesnt just take 1 parameter
-what is m_MemDC ?(what kind of object, DC or what?)
-must i work with CWindowDC ? how do i create a CWindowDC with a HWND ? i dont have a 'this' in this program
thanks alot
imran
|
|
|
|
|
hi..
i have tried alot the whole day, with no success
basically, using the SendMessage function, gives me a completely black image. always. bitblt works, but only if window is visible.
i copied your code, got it working (i know what mfc, CWindowDC and all that is now ).
but still the returned image is all black.
have you got any clue what the problem could be?
thanks alot
imran
|
|
|
|
|
here is a non-mfc version of the code. this code will draw the image to the desktop.If u have any other windows in the desktop plz minimize them before testing this code.
::ShowWindow( m_hWnd, FALSE );<br />
HDC hdc = ::GetDC(m_hWnd);<br />
RECT WindRect;<br />
::GetWindowRect( m_hWnd, &WindRect );<br />
HDC MemDC = ::CreateCompatibleDC( hdc );<br />
HBITMAP bmp = CreateCompatibleBitmap( hdc, WindRect.right - WindRect.left, WindRect.bottom- WindRect.top );<br />
SelectObject( MemDC,bmp );<br />
SendMessage( WM_PRINT, (WPARAM)MemDC,PRF_CLIENT | PRF_NONCLIENT|PRF_ERASEBKGND);<br />
HDC DeskDc = ::GetDC(0);<br />
BitBlt( DeskDc,0,0,WindRect.right - WindRect.left, WindRect.bottom- WindRect.top , MemDC,0,0,SRCCOPY );
astabasta wrote: but still the returned image is all black.
how do u verify the image in the dc? I mean how u came in to conclusion that the images is black?
nave
|
|
|
|
|
hi nave
thanks for the reply again
your code goes exactly the same thing too. actually almost exactly. basically it draws a black rectangle onto my screen excatly the size of the window in question. usually the whole rectangle was completely black. with your code, there's a 'hole' in the black rectangle, where i can see the desktop background and around it all is black.
any ideas?
cheers mate
imran
|
|
|
|
|
give me ur email id. I will send a sample..
nave
|
|
|
|
|
hey i found out the function PrintWindow() will work in your case.
nave
|
|
|
|
|
astabasta wrote: i would like to get the content (graphics) of a window whose HWND i have, but it is not visible (meaning, visible as in WM_VISIBLE, but not to the human eye i.e. concealed by other windows).
The screen does not have "thickness". When Window A is covered by Window B on the screen, you won't be able to get the portion of A right behinde B. If you really want it, you have to maintain a double buffer (memory DC) for each window. Then, you may retrieve any portion of a window from its double buffer.
Best,
Jun
|
|
|
|
|
Jun Du wrote: The screen does not have "thickness". When Window A is covered by Window B on the screen, you won't be able to get the portion of A right behinde B. If you really want it, you have to maintain a double buffer (memory DC) for each window. Then, you may retrieve any portion of a window from its double buffer.
i see. so what can i do? its a window from another app. not mine. i just want to take shots of it without bringing it up front.
thanks
imran
|
|
|
|
|
If the window is not yours and covered by another window, there is no way to get the content behind. You still can take a snapshot, but the snapshot will save exactly what you CAN see only.
Best,
Jun
|
|
|
|
|
Hi
I need to write code for 64-bit OS
do anyone has any good document/ebook for it .
I need to use an existing dll(which works fine in 32bit)
to be used in a 64bit machine
Can anyone put some light on this topic
Thanks & Regards
Vikas Amin
EATON
PUNE
|
|
|
|
|
Windows System Programming (Third Edition) by Johnson M. Hart has some chapters about Win64. Maybe you want to have a look.
In general there should not be a great difference between Win32 & Win64 apart from the obvious ones. Search for any conditional compiled code under _WIN32 directive. Consider if such code will work in Win64 and if so (most likely) add the _WIN64 directive there.
Also when you are using pointer arithmetic do not hardwire the sizes but use the sizeof operator. Well, most of us do that anyway so should not be a problem.
Keeping things simple is a great art
|
|
|
|
|
I am developing diagram editor where I am trying to add an inline edit focility. The editor is a CScrollView subclass and on text areas I impose a CEdit view subclass to permit inline change of the text.
I observed the following on Windows Explorer. Assume you start renaming a file. Type an invalid file name (e.g. a dublicated one)and then try to select another window. The explorer does not leave you to do that. It will prompt that the filename is invalid and then it will keep the window on top. Thus, you cannot go away with an invalid name.
How does it manages to stay on top if the name is not valid? It is necessary for me to achieve that if I want to have a consistent behaviour with the explorer (i.e. to comit changes if the input focus is lost). I know that must be done upon the receival of the EN_KILLFOCUS message. I 've tried that code
BOOL
U_W_SCROLL_VIEW::OnCommand( WPARAM wParam, LPARAM lParam )
{
if( m_pEdit->GetSafeHwnd() == (HWND) lParam )
switch(HIWORD(wParam)) {
...............
case EN_KILLFOCUS:
if( this->IsIconic() )
cancel_edit();
else {
confirm_edit(); // This will delete the CEdit subclass if the code is invalid
if( m_pEdit != (U_W_Edit *) NULL ) {
this->BringWindowToTop();
this->SetActiveWindow();
m_pEdit->SetFocus();
}
return TRUE;
.....................
}
return FALSE;
}
|
|
|
|
|
The jist of it: I am trying to draw some lines and text over another window (which is actually an ActiveX control).
More details: Since I cant get the ActiveX control to draw to a memory device context so I can add lines in a nice way then blt to screen, I am trying a bit of a no-so-nice way of just drawing over the control. So I created a window that is a child of the ActiveX control window in the hopes that it will be drawn after the ActiveX control, but without erasing the background to effectively form a transparent overlay. Despite my logic, the windows do not seem to drawn in the expected order so I dont see the lines and text drawn in the child!
Q1: Am I just wasting my time trying to do it this way? Or is there something else I should be doing?
Q2: Would drawing the lines and text as a transparent DirectDraw overlay surface do what I want (I have zero knowledge in the area of DirectDraw, so forgive me if I am talking like a crazy man!)
Many thanks.
|
|
|
|
|
http://www.codeproject.com/wtl/splitpane.asp
i have dowloaded a project for splitting my sdi window from thw above url.but when i compile it it gives error
Could not find the file atlres.h
How to remove this error
When i simply comment this line
it gives 4 errors more
thanxs
|
|
|
|
|
|
neha.agarwal27 wrote: Could not find the file atlres.h
Does the file exist on the development machine?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I wanted my exe to be started as soon as the system starts and i have placed its path the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
as value name myexe
and value as g:\myfolder\myexe.exe; .
I made this using CRegKey functions.
Its getting added in the registry well and also getting sarted when my system restarts. But the path which i have specified in the registry is being changed from
g:\myfolder\myexe.exe; .
to
c:\myexe.exe
Can you please tell me why its happening like that?
Thank you.
KIRAN PINJARLA
|
|
|
|
|
What does your code look like that is adding the key/value pair? Are you remembering to use two backslashes?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes David. Everything is ok. I am taking care of those all things and the value is also being set fine. and my application is also being executed when my system restarts. but the exe path which i have given given in the registry is being changed only after restart of the system.
KIRAN PINJARLA
|
|
|
|
|
My code is
CString data = app->appPath+"\\"+AfxGetAppName()+".exe";<br />
CRegKey reg;<br />
reg.SetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run",<br />
data,<br />
AfxGetAppName()<br />
);
this is executing fine.
KIRAN PINJARLA
|
|
|
|
|