|
found why. I put the "#include <string>" before #include "stdafx.h". after I updated it. it's working.
|
|
|
|
|
When you are posting #includes... put a space between the < and the header itself. If not... the site will try to get it as a HTML tag and the line will not full visible.
#include < header.h > //A space between brackets and header
#include //Without spaces
Or click on "Ignore HTML tags in this message (good for code snippets)" below your message
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
In addition to NELEKs suggestions, you can wrap your code-snippets with the pre-Tag, or use the < >
You find both below the edit-field when writing the message.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
hello , i am trying to write a bmp to file , sometimes works sometimes it doesn't work properly . i am making recorder for ymsg.
i tried to snapshot the whole screen and look what happens when the webcam window is present in the snapshot , the image is clear before the webcam window , why ? i don't have a clue. and CreateDIBSection returns ERROR_NOT_ENOUGH_MEMORY. and after all this i've written a tester to see when CreateDIBSection returns ERROR_NOT_ENOUGH_MEMORY.
i am thinking that this problem may have 2 issues , 1. my code is wrong , 2. bug in windows and of course this api function.
here is the sample snapshot image:
http://www.rohitab.com/discuss/index.php?act=attach&type=post&id=1658[^]
tester to see when CreateDIBSection return an error
#include <stdio.h>
#include <windows.h>
DWORD error=0;
BOOL test(int nWidth, int nHeight)
{
HDC memDC = CreateCompatibleDC(NULL);
BITMAPINFO i;
ZeroMemory(&i.bmiHeader, sizeof(BITMAPINFOHEADER) );
int extrabytes = (4 - (nWidth * 3) % 4) % 4;
i.bmiHeader.biWidth = nWidth;
i.bmiHeader.biHeight = nHeight;
i.bmiHeader.biPlanes = 1;
i.bmiHeader.biBitCount = 24;
i.bmiHeader.biSizeImage = (nWidth * 3 + extrabytes) * nHeight;
i.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
i.bmiHeader.biClrUsed = 0;
i.bmiHeader.biClrImportant = 0;
VOID *pvBits;
error=0;
HBITMAP h = CreateDIBSection(memDC, &i, DIB_RGB_COLORS, &pvBits, NULL, 0);
error=GetLastError();
if (h==NULL)
{
DeleteDC(memDC);
return 1;
}
DeleteObject(h);
DeleteDC(memDC);
return 0;
}
int main()
{
for (int k=1;k<100000;k++)
{
test(k,k);
printf("\n%u eror:%d", k,error);
}
return 0;
}
|
|
|
|
|
csmanul wrote: 1. my code is wrong , 2. bug in windows and of course this api function.
I Know the Sentiment, Contemplated this question for about 1000 times over the last 20 years. Always turned out to be Option 1 though, (Well, except for 2 occasions, which have now been fixed).
Without investigating in detail, your code constructs up to 100000 objects, and keeps the oject when successfull9 Deletes the DIB, but keeps the Object). When it finally fails, it complains. Seems quite natural to me that it behaves as it does! Why would you want 100000 empty DIBSections anyways.
Regards
Bram van Kampen
|
|
|
|
|
this is only a tester , even if i remove the call from for cycle not even one single call succeeds
|
|
|
|
|
You seem to use incredably large numbers for a tester, and, seeing it is a tester, did you try it with small numbers such as 1 and 2, or even 0?
It occurs to me that you simply exhausted all your resources, (which are large but not infinite)
Regards
Bram van Kampen
|
|
|
|
|
It's not mysterious at all. You have to have enough contiguous virtual address space available to allocate the bitmap. An image 100,000 x 100,000 pixels at 24 bit colour depth requires about 30GB. You've only got 2GB virtual address space to play with and large chunks of that are taken up by loaded DLLs and other memory allocations. If you really need an image this large you will have to come up with a way to do manage it in smaller pieces.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
not even an 1x1 image works , i've already told you , i remove the function call from for cycle and it doesn't succeed , i've also rebooted windows and made a single function call 1x1 image , failed with same error : not enough memory.
|
|
|
|
|
I am a amateur programmer trying to print the contents of a richedit control as suggested by the article "how to print the contents of a rich edit control" by Roger Allen.
Since my richedit control is in a modeless dialog (instead of a SDI) I am unable to simply use the control variable of the richedit control and the SetTargetDevice and FormatRange members of the RichEditCtrl class in MyView::OnPreparePrinting as suggested: "m_Control.FormatRange(NULL, FALSE)" etc.
I have tried a number of (crazy?) things to gain access to the dialog and richedit control that I want to print without success including:
CWnd* qDlg;
qDlg=CWnd::FindWindow(NULL,_T("Dialog Title"));
then trying to access the control etc. Perhaps (probably) this is something simple that I do not yet understand and hope that others can help me solve (and understand) this problem.
Any suggestions?
Thanks.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
If you have code running in a view class then the modal dialog must be on another thread, right?
If so, you should be able to post app-defined messages to the dialog (instead of accessing the
control directly from a separate thread).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: If so, you should be able to post app-defined messages to the dialog (instead of accessing the
control directly from a separate thread).
It's such a shame there is no way to maintain the application session data in a single location we might call, oh I don't know... a model. That sort of design would negate having to tightly couple different user interface views being that their requirements could change in the future. Wait..... 
|
|
|
|
|
|
Mark Salsbery wrote: Am I the only one not getting email notifications when someone replies to my posts here?
No, I'm not getting any either.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks
I got a few today - yay!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Am I the only one not getting email notifications when someone replies to my posts here?
No, I never got this one. 
|
|
|
|
|
Thanks man. Did you get this one?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Leave me alone dude, I have emails from CodeProject to read.... wait.... 
|
|
|
|
|
Thanks for responding led mike.
You state,
led mike wrote: It's such a shame there is no way to maintain the application session data in a single location
Is this true?
Or is there a way to accomplish maintaining the session data in a single location – perhaps the model and design you refer to.
At the beginning of my project, I spent a great deal of time “Applying UML and Patterns.” However, a serious illness permanently interrupted the collaboration I had with an expert programmer who encouraged me to develop expanded use cases, flow charts and a “conceptual model” of my program.
Recognizing that your message might be sarcastic, I reviewed these documents and realized that my program already contains series of functions that provide access to the user and internal data the program employs in its operation.
It appears that the interruption of the collaboration with the expert programmer may have occurred at a critical moment in that I had not yet, and still do not, fully understand what I have been doing as I worked to continue the development of my program without my expert collaborator. Perhaps if I had studied programming in college as my collaborator (and many others) did, my task might be easier.
However, the modeless dialog I mentioned is the interface to a flat file database I created and from which I hope to print information from numerous records I have synthesized into single record. Therefore, returning transient data present in the richedit control at a certain point in time remains useful (although the advantage of this was not evident during the design of the program).
If I understood how to solve my problem (or had correctly anticipated future needs in my model and design) there would no reason to turn to experts like you or a site like CodeProject for a bit of help, a friendly conversation or an educational response. Working in isolation can be a challenge in any discipline (physical biochemistry is a personal favorite), and it is good to have a place where you can ask questions and receive accurate, precise, concise and information rich responses. It is easy to laugh at those who seek to learn from you (and even misdirect them as a means of providing future entertainment), so a community like CodeProject in which shared enjoyment of programming, interpersonal respect and dedication to mutual aid trumps petty personal attacks is critically important.
Thank you again for your response, which suggests that one or more of the functions my program currently employs in numerous locations for the manipulation of data might be useful in achieving my goal. While this was already apparent, your response has spurred me to explore my design as a means of achieving my goal.
Thanks again.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: Recognizing that your message might be sarcastic
Yes, and my reply was to Mark. Mark and I joke around some in the forums. At that time in the thread there was no indication that you would be interested in anything other than what Mark suggest, as many here on CodeProject are not.
I am happy to see that you are and that you have help. Things will go well for you given the track you are on. Don't worry about not having a formal education. With your attitude, the availability of information on the internet and your colleagues you will do fine.
It is very likely that your colleague helped you implement a Model-View-Controller[^] pattern. If so you will find that it satisfies all your requirements.
|
|
|
|
|
Thanks for responding Mark.
Please assist me by educating me when I am not saying things correctly. I am trying to learn through this process, and working alone and without [programming] training (or any level of programming talent ) can make programming a challenge.
By “code running in a view class” I assume you are referring to the OnPreparePrinting virtual function I mentioned in my question (or perhaps one or more of the other virtual functions associated with printing from the view class such as OnPrepareDC).
Similarly, I assume your reference to “modal dialog” in your response refers to the modeless dialog I mentioned in my question.
You suggest that I might accomplish my by sending a message to the dialog (such as EM_FORMATRANGE), which is not directly accessible to the view because it is running in a different thread.
One of my problems is that I am not sure that I have correctly created my dialog and my access to it appears inconsistent. In one part of my program (immediately after dialog creation) statements such as
mDlg->OnDialogFunction();
appear to work fine, while in other parts of the program (such as OnPreparePrinting) this tactic fails.
This may be embarrassingly bad programming practice; however, it accomplishes my goal which is important in the absence of continuous cognizant collaborators.
I will explore this clue.
Thank you for your assistance.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
Well my reply didn't make sense. Your post clearly states "modeless" -
I don't know where I got "modal" from
I'll try again...
Where are you trying to access the rich edit control from? Within the dialog class
or from another class?
You shouldn't need to find the window. You should be able to keep a CRichEditCtrl
member variable in the dialog class. From within the dialog class, you can use that
variable directly to manipulate the control. From outside the dialog class, you
can either make the control variable public and directly access it through the
dialog object, or better yet, add methods to the dialog class which internally use
the control member variable to access the control.
lctrncs wrote: In one part of my program (immediately after dialog creation) statements such as
mDlg->OnDialogFunction();
appear to work fine, while in other parts of the program (such as OnPreparePrinting) this tactic fails.
You'll need to make sure your mDlg variable is accessible from wherever you need it.
Where (what class) is mDlg located?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I would like to include in my program a dialog with a control to plot out an (x, y) position over time.
Every Class/ActiveX I have downloaded has give me compile or build faults. I then gave up.
Can someone suggest either a Class or ActiveX to download for VS 2005. I am planning to use it in a MFC application.
Many thanks,
Andy.
|
|
|
|
|
|
I confirm, it is a good one
EDIT: it seems that the link is bad. I'll need to update my sig too.
modified on Thursday, December 06, 2007 2:06:53 PM
|
|
|
|
|