I know how to code a catch block, I was just wondering whether you had posted in the correct forum. When you catch the exception it should contain sufficient information for you to discover what went wrong in your code.
One of these days I'm going to think of a really clever signature.
To my knowledge, MFC does not contain tools for managing task transactions. There is no common framework for managing undos, redos, etc...
The try / catch mechanism is a simplistic implementation of such a system, built into C++ that allows a program to gracefully unwind from an aborted task. the Afx classes that support exception handling, simply build upon this framework.
I have seen articles that discuss transaction processing for the windows file system and other kernel elements, coming up in future releases, but at this time, I don't know much about it.
You'll likely find that you'll need to roll your own Transactional Tasks manager for your application.
I have a dll developed in c#, which does some interactions with a web service, this all seems to be fine. I have made the dll visible to COM. I then register the dll using regasm passing it a /codebase /tlb argument. Again all this works fine. I now get a tlb file. From here i reference the tlb in my VC6 project like so:
// Import the type library.
Once i compile the VC++ project i get a tlh file generated, which has the following contents (edited there is much more in this file just showing what is needed here):
I create COM earlier in the program so i have not included it in the code below.
Then i Create an instance of the c# class, to call the methods i need. Now this all works fine and i can call these methods and they work correctly.
Code in my Main.c file
IMyLinkPtr iPtrMyLink; //Global Variable
IChVRspPtr iPtrCheckVRsp; //Create the Interface to The CheckVoucher Response
short blnRetVal = 0; //Set to False Initially, return value from dll
IChVReqPtr iPtrCheckV(__uuidof(CChVReq)); //Create the Interface to The Method1 Class. This is another class in the dll
HRESULT hrRetval= E_FAIL;
hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink)); //This is the main class in the dll, a wrapper to call methods from.
// Pass to the method the request class, a reference to the response class and a reference to the return value.
iPtrMyLink->CallMethod1(iPtrCheckV, &iPtrCheckVRsp, &blnRetVal);
The problem i am having is that my program crashes after some time where the memory has grown to 32mb, which to me is quite low. The crash occurs on a CreateInstance line, not necessarily the one above but some other method i have to another .net dll. My main question is about memory, before calling this line:
The memory in the VC6 app is 12mb, once this line is called the memory jumps to 24mb. Is this down to loading the .net Framework and if i have another dll that does the same the memory will jump to 32mb and will crash shortly after when attempting to create an instance again. I am releasing the objects so im not sure what is going on here.
OK, this is a bit of a long shot, but any help would be appreciated...
I have a CWnd that contains a CHeaderCtrl and CTreeCtrl within a CDialog within a CScrollView within a CSplitterWnd within a CControlBar.
All works very well except the CWnd border (ClientEdge) is not redrawn (just seems to leave whatever was underneath) when splitter bar is moved, and CWnd is resized and invalidated. However, the edges ARE redrawn properly when the whole app is resized which also resizes panes in CSplitterWnd and subsequently CWnd in excatly same way as above. In other words, both scenarios call CSplitterWnd::RecalcLayout() which trickles down and drives all resizing of child view/dialog/window/tree control. The only difference I can really see is that one was generated by resizing whole app, while other was generated by StopTracking() of the CSplitterWnd. All other controls (buttons, group boxes, etc. resize and redraw fine).
A lot of web crawling suggests perhaps that it's something to do with being on a CControlBar which may result in some notify commands not getting to all children? But
I've tried trapping the paint messages, but am a bit confused as OnPaint seems to be being called...I'm now assuming that the window border isn't actually drawn by OnPaint? If it's not, where is it drawn and by whom?
Just playing around with painting in OnEraseBkgnd, I've noticed something very strange...if I get client rect and paint the background red, in the case where it's not repainting correctly, only an area at either end of the scroll bars to the right of the tree control are being painted red, where as in the case where it is working, the whole control is being painted red - the client rects are always same size.
Invalidating the CWnd doesn't fix the problem. Calling InvalidateRect(NULL) invalidates the whole screen which does fix the repainting, but is not a viable solution as there are graphs on the other bits of the screen that can take several seconds to redraw and shouldn't be redrawn any time the splitter bars are moved.
Anyone ever seen anything like this? I'm extremely confused and any pointers as to things to try would be much appreciated.
BTW - dialog in view in splitter wnd in ccontrol bar is part of a function panel down one side of the app.
"He is no fool who gives what he cannot keep to gain that which he cannot lose.
OK, while I've no idea why this happens, I've found a solution.
I've read up that OnNcPaint handles the borders (NC being Non-Client area). And it's this WM_NCPAINT message that never arrives in the situation where the border isn't painted. While I've no idea why this message isn't sent, sending a WM_NCPAINT message to the control after it's been resized ensures the frame is always repainted. Success!
"He is no fool who gives what he cannot keep to gain that which he cannot lose."
This does not make a lot of sense but at a guess the bottom five bits of the number are supposed to represent the seconds, although that allows for a maximum of only 31 seconds. You will also get invalid values for minutes as you do not mask out the hour value. Perhaps you could explain where these values, and the shift constants, are derived from.
One of these days I'm going to think of a really clever signature.
Now I have build my application like this: it runs in the container of Internet browser(IE, FireFox, Chrome and so on). There is a modeless dialog in my program, the dialog contains one CEdit control.
Here is my problem: when user activate the Edit control to type into something, the edit control get the focus. When the edit control loses the focus, I must check whether the input is valid. If not, I will display a model dialog with
. But now I cannot determine whether my edit control loses in my own application. Because the edit control may loses focus by a lot of means, for example, when user close the browser, when user open a text program. In these cases, I will just skip the invalidation check.
Any one can tell me how to find that in which way my edit control loses focus.
A common way to disable window closing is returning zero from WM_COMMAND. This is the place where ppl usually put the "Really wanna exit?" dialogs and they don't call DestroyWindow() if the user doesn't want to exit or has unsaved work (etc...). Some ppl like hiding the window more than destroying it on WM_CLOSE because this way it keeps the gui state. As for Ctrl+Alt+Del, and other ways to kill your process... If I guess right and you wanna prevent your program from closing/killing than instead of blocking Ctrl+Alt+Del it would be better to hide your process from process enumeration, I did that only on older windows systems and its quite windows version dependent how to do it, search a recent article about it with google.
EDIT: If you wanna block the Ctrl+Alt+Del to prevent windows shutdown, thats a useless idea because ppl use the power button from reflex in that case.
Hello all. I am new to image processing and am having trouble with CreateDIBSection. I have been reading other threads on this topic and code snippets for several days now, so I was hoping at this point to get specific help with my code rather than a link to a previous explanation or code.
I have a dialog based app. I want to take a screen shot, change some of the pixel colors and BitBlt it back. In my attempt to make a rectangle of red pixels (or any color) that is 800 pixels in width and 900 in height, I end up with 4 rectangles that are 200 pixels in width and 225 pixels in height, that are separated by 36 pixels and that are alternating is color between red a blue. I'm guessing that this has something to do with the padding.
A good advice for the future: The size in bytes occupied by one row of pixels in memory is called stride. Its important that in bitmaps stride is always a multiple of 4 bytes. In your cases this condition is true in all cases regardless of the bitmap width because 1 pixel occupies 4 bytes. But for example in a 8 bit bitmap (256 colors) with width==3 the stride would be 4 bytes regardless of the actual size being 3 bytes, there would go 1 byte extra padding.
I have designed a digital controller in matlab. The continuos s domain controller is as follows:
1.16e006 s^2 + 6.287e006 s + 2.436e006
s^2 + 10 s
The discretised z domain version (with a sampling rate of 100Hz) is as follows:
1.16e006 z^2 - 2.26e006 z + 1.1e006
z^2 - 1.905 z + 0.9048
Now i have managed to program this in C++ and it "sort of" works. However the code is by no means optimal and therefore does not execute as quickly as it should. The code basically looks like this:
float dencoeff ;
numcoeff = 1160000;
numcoeff = -2260000;
numcoeff = 1100000;
dencoeff = 1;
dencoeff = -1.905;
dencoeff = 0.9048;
SpeedError = MeasuredGeneratorSpeed - SpeedDemand;
xprevious = SpeedError; //current input value
y = xprevious*numcoeff; // get it started
y += ((xprevious*numcoeff)+(xprevious*numcoeff)-(yprevious*dencoeff)-(yprevious*dencoeff));
xprevious = xprevious; //Shift the values down
xprevious = xprevious;
yprevious = yprevious;
yprevious = y; // Current Output
Where xprevious,yprevious are arrays that i define earlier in the program. They are used to store the previous input and output values. X is the input and Y is the output. The numbers stored in the numcoeff and dencoeff arrays correspond to the coefficients in the z domain transfer function shown at the top. Is there a faster way to do this calculation in c++, perhaps by using a circular queue!!??. Unfortunately my programming knowledge is not great(I'm a Matlab guy). If there is a better way to do it that would speed up the calculation perhaps someone could give me an eample of how to do it. By the way all the variables and arrays are floating point. Any help or advice would be much appreciated.
that looks pretty straightforward. i doubt a circular buffer is going to give you much improvement - you're just copying some floats around, after all. no matter where they reside or how you abstract your data structure (array, circ buffer, etc), you're still copying floats.
you could probably speed it up a bit using vector processing - execute those four multiplications in one call. you could do the addition/subtraction in one call, too. search here for "SIMD" or "SSE". though that stuff might look a little scary, if you're coming from MatLab...