|
Hi A.R.
Your solution to Rob's recursive call problem is of course absolutely correct. However, I don't think Rob's got a re-entrance problem.
>On the other hand, the timer has been set to signal every one second, and in the code where you are handling this event, there is no way to stop the messaging system sending the signal every one second, and here is where meanwhile you are decrementing your variable and formatting your display, another call has been made and so on.
Rob is handling the WM_TIMER message, and while the program is in OnTimer it will not get new messages from the message queue and hence OnTimer will not be called again. Only when Rob returns from OnTimer will a new WM_TIMER message be dispatched. So while a steady stream of WM_TIMER messages will certainly make the application seem unresponsive, it will not lead to any concurrency issues. Furthermore, WM_TIMER messages are handled in a similar manner to WM_PAINT - they are low-priority and will only be handled if the message queue is empty, and multiple WM_TIMER messages in the queue will be merged into one message. And there is no way to find out just how may WM_TIMER messages got zapped. That's why you cannot use timers to make a good clock - you'll have to read the system time inside OnTimer, and cannot rely on exactly 1 second between WM_TIMER messages (not even on average over a period of time). And don't take my word for it - it's all described in Petzold chapter 7.
>One good rule is if your timer's handler do a lot of work and the timer's period is short, you have to tell the messaging system "give me a break".
This is actually very good advice, but only for responsivity-reasons, not for concurrency.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Whenever I try to call DoModal() for a dialog it gets an access violation in LoadResource(...). I tried rebooting thinking my computer was low on resources. No luck. I tried making a new dialog, with no code and calling DoModal() on that one. Same thing happened. I tried the Resourde ID Organizer utility I got from this site. Still no luck.
This just started happening to my project. Other dialogs that I created before today come up fine.
Pleeeeeaaase hellllp meeeeee!!!!!!!!!!!
|
|
|
|
|
It sounds like your resource script has troubles. Have you tried going into the debugger to see what the problem is, and stepping back to see at what stage the function is being called ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Never mind.
I am an idiot. I forgot to do AFX_MANAGE_STATE(AfxGetStaticModuleState());
Sorry for bothering you.
|
|
|
|
|
No bother at all. I find often verbalising a problem helps me to find it. FWIW I was not going to suggest that, so I guess I wasn't going to be much help anyhow
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
My app has a console that redirects stdout and stderr, but
apparently it doesn't capture OutputDebugString() messages
or any internal messages from DX8. Is there a way to do it?
Steve The Plant
|
|
|
|
|
To get OutputDebugStrings you'd have to call WaitForDebugEvent. However, this function is apparently designed to be used by debugger running in separate process. I have no idea if this is possible from within the running program itself - this would be a self-debugging configuration
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
With a help of VxD or Kernel Mode Device Driver, you can monitor any messages for debug output. Grab exellent utility at;
http://www.sysinternals.com/ntw2k/freeware/debugview.shtml
Utility looks like single binary but they embedded device drivers for Win9x and NT/Win2k. (They are kind of an alien, not human.)
reiko
|
|
|
|
|
As the other comments stated, you probably want to do it using by debug events.
But since it's in the same app, just blast a new address into the jump table for OutputDebugString (it's in the IMPORT section of your PE (at runtime). If you also wan't to "steal" GetProcAddress() usage you'll have to patch the first few bytes of OutputDebugString() to be a "jmp X", where X is the address of your (stdcall!) replacement function. Either way, you would have to know some IA32 assembly to know what's going on.
|
|
|
|
|
Hello, I'm new to dealing with graphical user interfaces and currently I am working on a program that would need to display an acquired image onto the screen. The image is an array of unsigned char buffer containing the RGB values. Would anyone know how I may display it effeciently in my view? Currently, I am doing a nested for loop inside OnDraw() and I don't believe this is the correct way.
Don't laugh , but here's what I've got--
BYTE R, G, B;
for (unsigned long y=0; y "less than" imageHeight; y++)
{
for (unsigned long x=0; x "less than" imageWidth; x++)
{
R = imageBuffer[(y*imageWidth*3)+(x*3)];
G = imageBuffer[(y*imageWidth*3)+(x*3)+1];
B = imageBuffer[(y*imageWidth*3)+(x*3)+2];
cDC->SetPixel(x, y, RGB(R,G,B));
}
}
Thanks in advance!
Jerry
|
|
|
|
|
the quickest way to do this is to create a DIB from your RGB buffer.
a DIB is a rather complex data structure that holds a Device Independent Bitmap.
but, to make a 24-bit DIB out of an RGB buffer you need to do the following:
1. allocate enough memory for the DIB. this is a BITMAPINFOHEADER plus the pixels. pixels in a 24-bit DIB are 3 bytes per pixel with 1-3 bytes at the end of each row so that the number of bytes in a row is multiple of 4.
2. fill in the member of the BITMAPINFOHEADER struct
3. copy the RGB pixels into the DIB so that the DIB is vertically flipped compared to the RGB buffer and R and B are swapped.
4. call StretchDIBits.
if you want a working sample of all this, see JpegFile. this is a JPG read/write class that deals with RGB images (from/to JPG) and DIBs (for display).
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Maybe when the image is first aquired you could create a CBitmap and us the SetBitmapBits method. Then in your OnDraw you could render the bitmap instead of processing the the array each time. Just a possiblity, don't know if it will work for you.
Also, for future you can use the <pre> or <code> tags for any code snippets. Or at least use the HTML encoding < rather than "less than"
|
|
|
|
|
Whats the easiest way to pass the Parameter BSTR pkMbtID to the stored procedure "Values(pkMbtID....."
Must i use crateparameter method or what.
STDMETHODIMP CMBT::ADDMBT(BSTR pkMbtID, BSTR MbtType)
_bstr_t ProcMBT (L"Alter proc sp_AdoTest"
L"as "
L"INSERT INTO MBT (pkMbtID, MbtType) Values Values(pkMbtID, MbtType)");
L"return");
/Bigge
|
|
|
|
|
Just use it. If your stored proc is expecting a varchar, or the like, a BSTR will work. This is COM after all.
|
|
|
|
|
if you are going to use the CreateParameter method via ADO then you will need to supply the value as a varaint. The best way to do this is to use the wrapper classes _variant_t and _bstr_t
e.g.
_variant_t vValue(_bstr_t("Hello"));
|
|
|
|
|
What is the easiest way to set tooltips for static-controls (or any other controls such as buttons etc.)?
thanks in advance
|
|
|
|
|
You will have to use the CToolTipCtrl class, see msdn for more info
|
|
|
|
|
I tried out
It works with buttons, but the tooltips do not seem to work in my static-controls
|
|
|
|
|
This is the first time I've ever had to do printing within the MFC framework. I have a CRichEditView that does not stop spewing out pages. I started debugging in OnPrint and I notice that the CRichEditView calls GetTextLength() to get the length of the text in the control, it then compares it to the amount of text printed PrintPage(), but those numbers never match. The return from GetTextLength is ALWAYS greater by a couple hundred bytes than the call from PrintPage. Has anyone else seen this problem? I tried doing my own pagination, but I never know when the end of the document is because of the seeminly erroneous return from either GetTextLength or PrintPage. Are the RTF formatting characters in the control being counted as characters in the GetTextLength call and PrintPage?
Any help is appreciated.
Bill
http://www.ratebeer.com
|
|
|
|
|
I write a program which used database and use Multi View in splitter window,
when I switch the view,I must check if the database is empty first.If so, how can I show a message,such as the database is empty ..
|
|
|
|
|
How about ....
AfxMessageBox("The Database is empty");
Some how, I don't think this is the answer you want, but thats how I read it
|
|
|
|
|
When should I show this message when I switch the view?
|
|
|
|
|
What about showing it when the view gets the focus ?
Or better showing it directly in the view. And disabeling any edit buttons handled
by the view.
In general ist much better to disable operations not possible at the moment, instead
of popping up message boxes all over the app.
The user hates to click them away and doesn't read the text in the message box
(Most usrers I know of)
|
|
|
|
|
I have a simple Win32 program that creates an overlapped window containing an edit control. Can somebody please tell me the correct way to set the focus on the edit control when the main application window is selected. I have tried to call SetFocus(hEdit) in response to the WM_ACTIVATEAPP message but this doesn't work.
Thanks for any information you can provide.
Steve.
|
|
|
|
|
Call SetFocus(hEdit) when the main window gets a WM_SETFOCUS.
Oliver
|
|
|
|