|
Didn't you say that you can get the main window DC before 9~10 hours? I suggest that you can save your HDC as a member of your main window by calling pDC->GetSafeHdc() when you can get pDC that is still not NULL, and pass the member HDC to ::BitBlt(). Maybe that will work? Good luck!
|
|
|
|
|
thanks, I have done as you suggested. it works well longer,But i must test it several days.
|
|
|
|
|
Can someone tell me how to open the other application, for instance, notepad.exe, in a Visual C++ project? Thanks.
|
|
|
|
|
start menu -> Run
enter "notepad.exe" in the edit box (or just "notepad"
hit enter, or click "Ok"
bryce
---
To paraphrase Fred Dagg - the views expressed in this post are bloody good ones.
--
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
Our kids book :The Snot Goblin
|
|
|
|
|
I'm sorry, but what I mean is how to open the other application( process ) within my program. For instance, when a button in a dialog was pressed, the notepad.exe will be open automatically.
|
|
|
|
|
Use these Api's
Most Simpler One
-->WinExec()
--->ShellExecute
Little Tough
->CreateProcess
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
You can use ShellExecute(handle, "open", "File name with path", NULL, NULL, SW_SHOWNORMAL); to open othe application. for eg "path+notepad.exe"
|
|
|
|
|
Does anyone have a suggestion on where I can take a Online programming class? Thanks for anyfeedback.
|
|
|
|
|
I am trying to read a text file that is in the same directory as the program. As I am reading it in, I need to edit some of it and put the text from the text file and the edit into an edit box. I am somewhat new to Visual C++. Can someone Help me out?
Thanks in advance for your help!
Chris
|
|
|
|
|
To get you started; search for CStdioFile in the MSDN library. Of course, you can read a text file using basic file streams as well. But if you implementing an MFC application then using CStdioFile will simplify your efforts. You simply construct an object of this type (CStdioFile is a class type). Read the documentation in the MSDN on how to construct it. There are two very basic functions; ReadString and WriteString. It will read the file line by line and fill a null terminated string. Use a CString or std::string or _TCHAR[SIZE] array, or whatever it is you use to process strings. Read up on CString if you aren't familiar with that. Basically, MFC provides some very simple interfaces for doing what you are doing. Obviously, you'll have to write the C++ code to manipulate the strings as you read them but the CStdioFile should make the file I/O pretty simple. There are many ways to get data into an edit control; I assume you already know how to do that part once you have manipulated the data you've read from the file.
Regards,
Shawn
|
|
|
|
|
As has been pointed out, MFC offers some classes to do this. The other option is the standard ifstream/ofstream classes. I have written articles on these on Code Project, you should check both out before deciding which to use.
If you learn to use streams, they will be useful to you in any C++ setting. However, I'm not familiar enough with the MFC alternatives to know if they have significant other benefits.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm trying to port some code I wrote using DirectSound in C# to Visual C++ (managed). I've got most of it done except for this problem I'm stuck at. I understand that this is a newbie question, so please be gentle
The function I'm having a problem with is CaptureBufferObject->Read(arguments) in C++.
In C#, the function protoype is:
public Array Read(
int bufferStartingLocation,
Type returnedDataType,
LockFlag flag,
int[] ranks
);
My code has the following usage of the Read method.
MemBuffShort = (short[])(StreamCaptureBuffer.Read(StreamCapBuffReadPos, typeof(short), LockFlag.None, 50000));
where MemBuffShort = new short[100000];
In C++, the function prototype is:
public: Array* Read(
int bufferStartingLocation,
Type *returnedDataType,
LockFlag flag,
int ranks __gc[]
);
My problem is with the last parameter: int ranks __gc[]
I tried the following:
static System::Int32 CapBuffPara[] = new System::Int32[] { 50000 };
MemBuff = StreamCapBuffer->Read(StreamCapBuffReadPos, __typeof(int), LockFlag::None, CapBuffPara);
However, I get the following error message:
error C2440: '=' : cannot convert from 'System::Array __gc *' to 'int __gc[]'
How do I solve this problem? What needs to be changed?
Thanks for your help!
|
|
|
|
|
Well, since no one is going to tackle this extremely hard problem, here is the answer.
Instead of the line int rank __gc[], try either int rank[] or int *rank.
Bottom line, the C# line "int[] rank" defines an array of integers. The line "int rank __gc[]" wants to recast __gc[] from the class System::Array to an int array, and it won't work. Either "int rank[]" or "int *rank" define an array of integers.
Geez, people, at least pretend to read the books or understand what the definitions of things are.
|
|
|
|
|
The function definition (or should I call it "protoype") was specified in the DirectX SDK, so I can't change it. In C#, the argument reuqired was just an integer. In the C++ implementation, it requires an array of a maximum of 3 elements.
|
|
|
|
|
|
Hey Anonymous... thanks for the reply! I know that this is a very elementary problem, but I'm new to programming in C++ and learning.
I figured out the mistake I was making... I forgot the (System::Int32[]) typecast for MemBuff.
MemBuff = (System::Int32)(StreamCapBuffer->Read(StreamCapBuffReadPos, __typeof(int), LockFlag::None, CapBuffPara));
|
|
|
|
|
Hi,
I am trying to make this:
template<int i="">
void func(char* &c){
c+=i;
}
class Cqq
{
void (*m_ququ)(char* &c);
Cqq(bool b)
{
if(b)
m_ququ=func<1>;
else
m_ququ=func<2>;
}
};
in Visual 6.0 and receive a compilation error.
Any ideas?
Thanx
magicAL
|
|
|
|
|
What was the error? Which line was it on?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I can ShellExecute a rich text format file, but it always
opens in Word. I can change the registry and try to make
the rtf file execute into Wordpad or Wordperfect, but is
there any easier way to ShellExecute a rtf file into a
different processor? Im not really sure how I can programmatically find the Wordperfect executable.
Sincerely,
Danielle Brina
|
|
|
|
|
ShellExecute(NULL,"open", "wordpad.exe", "c:\file.rtf", NULL, SW_SHOWNORMAL);
or
ShellExecute(NULL,"open", "wordpad.exe c:\file.rtf", NULL, NULL, SW_SHOWNORMAL);
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I wrote a program that have some classes one for dialog one for app and on class that drives from CWinThread class
and also one class that represet TCP conection
in this class that create in the CWinApp class not in thread my OReceive never be called
can some one help me??
|
|
|
|
|
I have a Visual C++ 6.0 program which needs to capture the client area bitmap from the window of another running application. I have the window handle of the target window and am able to get the bitmap if the target window is completely visible, but if the window is partially overlayed, then the bitmap capture gets the overlaying windows as well. I have read here and other sites that sending a WM_PRINT message to the target window and providing a device context will do this, but so far I have been unable to get this to work. The code I am using is the following:
-----------------------------------------------------------------------------------------
CRect rect;
CDC memDC;
CWnd* pWindow = CWnd::FromHandle( m_hWindow );
if ( ( pWindow != NULL ) && ( IsWindow( pWindow->m_hWnd ) == TRUE ) )
{
CDC* pClientDC = new CClientDC( pWindow );
CBitmap* pBitmap = new CBitmap();
pWindow->GetClientRect( &rect );
pBitmap->CreateCompatibleBitmap( pClientDC, rect.Width(), rect.Height() );
memDC.CreateCompatibleDC( pClientDC );
CBitmap* pOldBitmap = memDC.SelectObject( pBitmap );
// Adding this line and removing the next line did not work
//SendMessage( m_hWindow, WM_PRINT, ( WPARAM )memDC.GetSafeHdc(), PRF_CLIENT );
// This code captures the overlayed windows
memDC.BitBlt( 0, 0, rect.Width(), rect.Height(), pClientDC, 0, 0, SRCCOPY );
memDC.SelectObject( pOldBitmap );
ReleaseDC( m_hWindow, pClientDC->GetSafeHdc() );
delete pClientDC;
}
-----------------------------------------------------------------------------------------
What do I need to modify in this code so that the target window bitmap is captured even if the window is partially overlayed.
|
|
|
|
|
there is another command u can send too ... i cant remember what it is right now sorry (*scratches head*)
also there is always the possibility that the app in question doesnt handle that message so u cant print it that way
"there is no spoon" biz stuff about me
|
|
|
|
|
why ? are you ashamed ? ( this is a joke ! )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Try one of the available packers on the net (or write your own).
But know that "There's always a crack, that's how the light gets in"
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|