|
I've created an application that paints on the window using GDI functions. It works fine. But because it is still under development it sometimes craches. It seems that if there are certain craches Windows Vista suddenly decides to treat my application in a new way: while drawing on the window it decides it must redraw that was on the screen when i started my application. The effect is that some drawing is lost. Windows continues with this behavour till i reboot my pc. After i booted the same piece of code draws the window correctly. I used Spy++ to find out what's happening. When the window is correctly displayed i see the following:
<00037> 00340626 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:1215 yPos:640
<00038> 00340626 P WM_LBUTTONUP fwKeys:0000 xPos:1215 yPos:640
<00039> 00340626 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:1249 yPos:711
<00040> 00340626 P WM_LBUTTONUP fwKeys:0000 xPos:1249 yPos:711
(I press the mousebutton to start drawing, it draws the window, i press the mousebutton again to close the window)
When things go wrong Spy++ reports the following:
<00037> 00340626 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:1219 yPos:643
<00038> 00340626 P WM_LBUTTONUP fwKeys:0000 xPos:1219 yPos:643
<00039> 004904B2 S WM_WINDOWPOSCHANGING lpwp:0012FE20
<00040> 004904B2 R WM_WINDOWPOSCHANGING
<00041> 004F0646 S WM_WINDOWPOSCHANGING lpwp:0012FE20
<00042> 004F0646 R WM_WINDOWPOSCHANGING
<00043> 00340626 S WM_WINDOWPOSCHANGING lpwp:0012FE20
<00044> 00340626 R WM_WINDOWPOSCHANGING
<00045> 004904B2 S WM_WINDOWPOSCHANGED lpwp:0012FE20
<00046> 004904B2 R WM_WINDOWPOSCHANGED
<00047> 004F0646 S WM_WINDOWPOSCHANGED lpwp:0012FE20
<00048> 004F0646 R WM_WINDOWPOSCHANGED
<00049> 00340626 S WM_WINDOWPOSCHANGED lpwp:0012FE20
<00050> 00340626 S .WM_SIZE fwSizeType:SIZE_RESTORED nWidth:1280 nHeight:770
<00051> 00340626 R .WM_SIZE
<00052> 00340626 R WM_WINDOWPOSCHANGED
<00053> 004904B2 S WM_WINDOWPOSCHANGING lpwp:0012FE20
<00054> 004904B2 R WM_WINDOWPOSCHANGING
<00055> 004F0646 S WM_WINDOWPOSCHANGING lpwp:0012FE20
<00056> 004F0646 R WM_WINDOWPOSCHANGING
<00057> 00340626 S WM_WINDOWPOSCHANGING lpwp:0012FE20
<00058> 00340626 R WM_WINDOWPOSCHANGING
<00059> 00340626 P WM_PAINT hdc:00000000
<00060> 00340626 S WM_ERASEBKGND hdc:D1011D9A
<00061> 00340626 R WM_ERASEBKGND fErased:False
<00062> 00340626 S WM_GETICON fType:True
<00063> 00340626 R WM_GETICON hicon:1CA203B1
<00064> 00340626 S WM_GETICON fType:False
<00065> 00340626 R WM_GETICON hicon:00000000
<00066> 00340626 S WM_GETICON fType:True
<00067> 00340626 R WM_GETICON hicon:089A0417
<00068> 00340626 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:1252 yPos:726
<00069> 00340626 P WM_LBUTTONUP fwKeys:0000 xPos:1252 yPos:726
The big difference is lines numbered 39-67. Does anyone understand what's happening here? And what is a correct solution for this problem? What causes it? It seems that i have to intercept the paint message to tell Windows to shut up. But what worries me is that the hdc is 0.
Any help will be appreciated..
|
|
|
|
|
That just looks like the window position is getting changed. Hard to say what may be wrong from just looking at the messages that Windows is sending your applications window. You probably need to post some of the applicable code.
|
|
|
|
|
I read about Secure erase command that has been implemented in HDD firmware after 2006, under T13 commitee authority. Can this command be invoked from a MFC program?
|
|
|
|
|
C/C++ programs can call any API exposed either via the OS or other applications.
They can also invoke assembly. Even if the MS compilers do not support embedded assembly (I didn't look) one can still invoke assembly via a function pointer cast.
So basically if your equipment supports it then it can be called in C/C++. Doesn't mean it is easy though.
|
|
|
|
|
As jschell suggested, you can probably get tricky and get it accomplished one way or another, but by default, you should assume that the functionality will not be easily accessible unless made available by the hardware driver. Look for a drive that supports it and see if they have their own driver (as opposed to a generic HDD driver which is likely not to have this function) and have an API that allows you to access it.
|
|
|
|
|
1. Can anybody show me an example on running multiple threads from an MFC application?
2. Is this possible in VS6?
...
Thanks in advance
|
|
|
|
|
There are many examples on the net and here like this one: Introduction to Multi-threaded Code [^].
|
|
|
|
|
|
|
Hello all,
I'm coding CFront, the very first form of C++, I have the .pdf file and using the compiler Code::Blocks, but I'm confused, should I use a project or just code it as file(s) individuality.
Also, how do I "identify" all the source code, in other words, what do I call which file what in order to avoid programming errors, like the .pdf has all the info in it, but as you can see I'm a "precise" person, and don't like to have errors OR tend to make errors a lot.
|
|
|
|
|
Brandon T. H. wrote: as you can see I'm a "precise" person
Who posts vague questions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Just telling you, I tend to make errors a lot, and I need help to see if I'm doing this right (coding CFront).
|
|
|
|
|
Have another look at this section[^] with particular reference to point 2.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: particular reference to point 2
Yeah, you have to be specific, I'm trying to make this clear as much as possible.
The .pdf file has code in it along with other stuff (like file names, heading names, comments, images, pictures, etc.), All I'm asking for is where do I find the header names and all the configuration in all that jargon, so I'm coding this right (because all that code does not go into one header). Please be aware I'm typing 300 pages, manually or one-by-one.
Simple Regards,
Brandon
modified 18-Mar-12 12:56pm.
|
|
|
|
|
Brandon T. H. wrote: The .pdf file has code in it
What exactly are you trying to create from this? I've had a quick look in this file and it looks like the listing of a complete C/C++ library. It's also dated 1985 so I guess it's out of date.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
A CFront compiler
Simple Regards,
Brandon
|
|
|
|
|
Pass the PDF file through an OCR[^] program to convert it into plain text, then split the file into individual source files, remove page headers and footers, fix scanning and OCR errors and you end up with files that might be acceptable to a C compiler.
|
|
|
|
|
Thanks, I'll try doing that.
Simple Regards,
Brandon
|
|
|
|
|
Hello,
Over the past year, I have been gathering dev kits for classic consoles from around the net, fixing them up to get them in a working state, and then wrote small game samples for each. The samples will compile out of the box.
You can find them at
http://sebastianmihai.com/ccd
I am currently up to 14 different systems.
Enjoy!
|
|
|
|
|
smccd wrote: Enjoy!
Probably not something that I would be interested in but I do approve of the effort.
You might want to look for a more standard place for them though such as sourceforge.
|
|
|
|
|
Not a question... so not really the appropriate forum for this post... probably better suited for the Lounge or Free Tools.
|
|
|
|
|
Hi guys, i wonder how to make my programm work in mode without debugging(Ctrl+F5). When i start my programm that captures video and audio to asf file from web-cam in debug (F5) it works good i can see a video in small window and everything is good. But when i start it in Ctrl+F5 it still writes a video and audio to file, but i can't see a preview video in small window (the window is getting wite and not responding) Please help me to find the problem
My programm code:
int main(int argc, char* argv[])
{
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
ICaptureGraphBuilder2 *pCaptureGraph = NULL; IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; IFileSinkFilter *pSink = NULL; IBaseFilter *pAudioInputFilter = NULL; IBaseFilter *pVideoInputFilter = NULL; IBaseFilter *pASFWriter = NULL;
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return hr;
}
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void **)&pCaptureGraph);
if (FAILED(hr)) {
printf("ERROR - Could not create the Filter Graph Manager.");
return hr;
}
hr = pCaptureGraph->SetOutputFileName(&MEDIASUBTYPE_Asf,
L"C:\\MyWebcam.ASF", &pASFWriter, &pSink);
hr = ShowFilterPropertyPages(pASFWriter);
hr = pCaptureGraph->GetFiltergraph(&pGraph);
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
if (FAILED(hr))
{
printf("ERROR - Could not create the Media Control object.");
pGraph->Release(); CoUninitialize(); return hr;
}
hr = EnumerateAudioInputFilters((void**) &pAudioInputFilter);
hr = EnumerateAudioInputPins(pAudioInputFilter);
hr = pGraph->AddFilter(pAudioInputFilter, L"Audio");
hr = GetVideoInputFilter(&pVideoInputFilter, L"HP Webcam");
if (SUCCEEDED(hr)) {
hr = pGraph->AddFilter(pVideoInputFilter, L"Video");
}
IBaseFilter *pIntermediate = NULL;
hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
pVideoInputFilter, NULL, NULL);
hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
pVideoInputFilter, NULL, pASFWriter);
hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio,
pAudioInputFilter, NULL, pASFWriter);
if (SUCCEEDED(hr))
{
hr = pControl->Run();
if (SUCCEEDED(hr))
{
wprintf(L"Started recording...press Enter to stop recording.\n");
boost::chrono::duration<double> sec = boost::chrono::system_clock::now() - start;
std::cout << "took " << sec.count() << " seconds\n";
char ch;
ch = getchar();
}
hr = pControl->Stop();
wprintf(L"Stopped recording.\n");
SaveGraphFile(pGraph, L"C:\\MyGraph.GRF");
}
pSink->Release();
pASFWriter->Release();
pVideoInputFilter->Release();
pAudioInputFilter->Release();
pControl->Release();
pGraph->Release();
pCaptureGraph->Release();
CoUninitialize();
return 0;
}
|
|
|
|
|
How to check whether a 100 digit no is prime or not using strings and classes in c++
khan
|
|
|
|
|
The first thing you need is a mathematical formula, or algorithm that will give you the answer. Without that it is impossible to write the code.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I wrote some code using the visual c++ 6, now I need to convert to visual stutio 2010 professional.
I am new and need to get guidance from Gurus. What I have to change the code ? how to convert ? what is the best way to convert?
Thanks
|
|
|
|