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...
I guess I know what you mean: You press down the pan mouse button while the cursor is over the view and then you pan by moving the mouse cursor until you release the pan mouse button. This panning basically scrolls the visible portion of the stuff you can see in your view. There is no API to do that, you have to implement it by yourself by handling primitive mouse events like mouse button down, mouse move, and mouse button up events. Custom implementation makes sense because its totally dependent on the program which parameters should be modified by the panning operation. In a 2D pdf viewer the program stores some position data about which part of the pdf should be drawn to the view. This position is changed when you are panning. In a 3D CAD program there is a 3d world in which you can find an active camera as well with a position and rotation parameter (and also with horizontal and vertical fov). This camera is used by the rednerer to decide which part of the world should be rendered, the camera is like an eye and you see in the view what this eye looks at in the 3d world. This camera has an up and right direction that defines a plane. When you pan with your mouse you basically calculate a 2D offset from the mouse movement and you add this 2D offset to the camera position on the plane that is defined by the up and right vectors of the camera rotation (maybe not right but left if you are using left handed coordinate system...). Even if you are not good at 3D, the answer to your question is: Those pan functions are implemented by those programs, its custom code in them and not some operating system provided api function calls.
How to implement panning: When panning starts (mouse button down) you store the actual pan-start position of the mouse cursor, and also the position value (the 3d cam pos, or the 2d pos in the pdf file) in your program to some variables that wont change during panning. When a mouse move event comes you always calculate the delta between the pan-start mouse pos and the current moved mouse cursor pos, and you use this 2D offset to calculate the pan offset in your world (you can leave it as it is, or any simple transform can do the job, for example multiplying it with something to set panning speed...). When you have your pan offset you add the resulting pan-offset to the stored pan-start position and set the result as the current position.
You have to do exactly the same. You handle the mouse events, and depending on the offset of the mouse move you change an internal variable in your program. In my example program the internal variable to change was the position of the window, but it could be anything else, for example the offset in your picture or pdf file for drawing on the client area of your window. All you have to do is using/changing something else, not the window position, for example the position where you draw your picture on the client area.
What do you mean on moving the client area? You can't move it. All you can do is drawing something on it and changing some of the parameters of the drawing when you are panning. Alternatively you could change the positions of some child controls on the window but that has not much usefulness.
I am working on an application where I have to change the text in a text box while user enters from the keyboard. I have an edit box on a dialog in MFC. I want when user enters any character in the edit box, a text box should be created on the dialog and the typed character should also be displayed in the text box. As user types the characters, at the same time it should be displayed in the text box. And how to make that text box movable after user has entered the text.
You need to capture the EN_CHANGE[^] notification, and copy the text from the edit box to the text box. I'm not sure about moving the text box, something along the lines of capturing the mouse (using WM_LBUTTONDOWN[^]) and then using MoveWindow() as the mouse moves.
One of these days I'm going to think of a really clever signature.