|
Yes, I just want to invalidate the drawing area that I am moving.
What I am doing is:
(1) while "mouse moving", I send out "InvalidateRect".
(2) do the Invalidating job
I think the problem coming from the delay "InvalidateRect" and actual paint. I also tried "RedrawWindow" without any success.
Thank you for your reply!
|
|
|
|
|
InvalidateRect() does what it is supposed to do. If you are leaving mess on the screen, it is because your rectangle is wrong / too small / etc. Or if your Invalidate / Paint rectangle is mismatched. What I mean is, if you move the mouse fast, you might erase 0,0,100,100, but by the time you get to the paint, you are working on rectangle 10,10,110,110. Also, how are you getting the rect to paint? The one that comes in through GetUpdateRect() is often wrong / slightly off.
|
|
|
|
|
Thank you very much for your reply.
I calculated the drawing rectangle that I need to move. AND I also enlarge the rectangle by 1.3 factor. I am sure the problem is not from the region that needed to be updated.
The problem is that when I move the drawing slowly, everything is OK, but a little faster, there will be some mess on screen.
Thanks again!
|
|
|
|
|
transoft wrote: I am sure the problem is not from the region that needed to be updated.
Then you would be highly mistaken sir!
Win32 drawing is message based (WM_ERASEBKGND & WM_PAINT). When you move slowly, you are getting all the messages point by point and your painting works correctly. When you are moving quickly, you MAY NOT get all messages. Windows is not going to send you a message for every single point when you are moving the mouse around like a crazy person! It compensates for that by skipping points.
What I indicated in my original response is your issue. 100% guaranteed.
You draw something at 0,0,100,100 and then move the mouse so quickly, the system never sends you an erase / paint cycle for 0,0,100,100 because you are already at 10,10,110,110.
For example:
Enlarging the rectangle by 0.0 may work for moving the mouse up to "10MPH"
Enlarging the rectangle by 1.0 may work for moving the mouse up to "20MPH"
Enlarging the rectangle by 2.0 may work for moving the mouse up to "50MPH"
So you get excited and enlarge the rectangle by 3.0 and everything works perfectly, right? NO. Everything works perfectly on YOUR machine which is a super duper gaming machine with a high end video card.
Then you take your app over to Bobs machine which has a lousy graphics card, anti-virus app running in the background and is cluttered with spyware from all his porn sites.
On Bob's machine, your app only works for moving the mouse up to "7MPH" and you get furious and start foaming at the mouth all angry!
True story .
I have been doing Win32 GUI apps for 16 years and am a custom control master. I am fully aware of how the system works and all the nuances .
BOTTOM LINE: if your update rectangle was correct, you wouldn't be here posting your question, now would you?
Over the years, I have learned that painting by update region is often a practice in futility and you will never get it perfect across machines at every mouse speed / video card combo.
You **MUST** double buffer your screens and keep track of what you drew on. DO NOT RELY ON WINDOWS TO SEND YOU ALL POINTS!!!
One other option is to realize that today is the year 2012 and move on to a "big boy" architecture like WPF where we don't worry about such nonsense anymore . MFC was fine in 1986. Sorry , had to be said . I don't program in Win32 / MFC anymore after all these years because I refuse to deal with crap like pixel droppings anymore and instead focus on the application .
But my response still stands. Your update rectangle can NOT be correct or your app would be working. It is not necessarily your fault... Win32 just doesn't feel like sending you all the information you need to do your "optimized" drawing.
|
|
|
|
|
Several things come to mind:
1. The parameter "rect" refers to only the "area" that will be invalidated. If the objects you're moving occupy the entire client area, try using the function as follows: InvalidateRect(NULL);
2. With a little more work you may want to "buffer" output for speedier and flicker free operation.
3. Examine GDI+ as an alternative
|
|
|
|
|
I am getting a 0 Return Code from CAsynSocket::connect doing GetLasterror I am getting
WSAEWOULDBLOCK 10035 (waitting for connection to complete)
However my CAsynSocket::Onconnect overridable is never called to complete the connection
Any Suggestion would be helpfull
|
|
|
|
|
Please post the OnConnect function that you've written.
|
|
|
|
|
My CAsynsocket clas lives whitin a CWIinThread Class
class SockCLeintThread : public CWinThread {
public:
DECLARE_DYNCREATE(SockCLeintThread)
// DECLARE_DYNAMIC(SockCLeintThread)
// IMPLEMENT_DYNAMIC(SockCLientThread)
public:
CWnd *sendwindow;
CWnd *call_wnd;
CString buffer;
char thread_id[15];;
SockClient thisocket; // Socket to do ocommunication
virtual BOOL InitInstance(); // Just for starters
virtual int Run(); // keep on moving
// virtual int ExitInstance();
void receive_work(WPARAM , LPARAM);
void Sendit(WPARAM, LPARAM);
void Receiveit(WPARAM, LPARAM);
void sockoper(WPARAM, LPARAM);
LPCTSTR ipaddr;
UINT port;
BOOL idle; // looking for work
SockCLeintThread();
~SockCLeintThread();
struct {
unsigned int is_connected : 1;
} flags;
protected:
DECLARE_MESSAGE_MAP()
};
My CASynsocket defination
class SockClient : public CAsyncSocket
{
public:
SockClient();
char *sockbuffer;
int num_buff;
CWnd *send_wnd;
int thread_no;
protected:
virtual void OnReceive(int nErrorCode);
virtual void OnSend(int nErrorCode);
virtual void OnConnect(int nErrorCode);
virtual void OnClose(int nErrorCode);
};
In the initinstance for the CWinThread I do a create a get a good return code "1" howver for the connect I get a 0 GetLastError return
WSAEWOULDBLOCK
10035
OOL SockCLeintThread::InitInstance()
{
int error_code;
CHERC_CMDApp* main_app;
main_app = (CHERC_CMDApp *)AfxGetApp();
SockCLeintThread* current = dynamic_cast<SockCLeintThread*>(current);
SetThreadName(m_nThreadID,thread_id);
if(thisocket.Create(port,SOCK_STREAM,FD_READ|FD_WRITE|FD_CONNECT,NULL)== 0)
{
error_code = thisocket.GetLastError();
}
main_app = (CHERC_CMDApp *)AfxGetApp();
if( thisocket.Connect(ipaddr,port) == 0)
{
error_code = thisocket.GetLastError();
}
else
current->flags.is_connected = 1;
return TRUE;
}
here is my ::OnConnect overridable
void SockClient :: OnConnect(int nErrorcode)
{
CHERC_CMDApp* main_app;
main_app = (CHERC_CMDApp *)AfxGetApp();
SockCLeintThread* current = dynamic_cast<SockCLeintThread*>(current);
current = (SockCLeintThread*)AfxGetThread();
UNREFERENCED_PARAMETER(nErrorcode);
CAsyncSocket::OnConnect(nErrorcode);
current->flags.is_connected = 1;
AsyncSelect(FD_WRITE);
}
Thanks
|
|
|
|
|
sometimes the operation of the non-blocking (a nonblocking) sockets, can not be completed immediately, it will return this error code. This error is not a serious error, the operation will again after some time try to perform. Since the establishment of the connection will inevitably take some time, so sometimes a nonblocking SOCK_STREAM socket call CONNECT back to the WSAEWOULDBLOCK (10 035) error code
|
|
|
|
|
Thatszthe reason to have the ::onConnect overridable in Place
However it is not being called
P.S it was working for sometime
|
|
|
|
|
Hi,
I am looking for a simple Asymetric Encryption method, preferably implemented via the Crypto API, to encrypt a block of approx 4K Data. The Data consists of an End User Licence Structure, to be encrypted with my Private Key. The (Public) Decryption key is to be stored in one of the Core DLL's for the suite, which will be responsible of de-crypting the licence, and starting the Appilcations.
CAPICOM deals with key-stores, and other remote Items that invest themselves in the Registry. I am looking for something far simpeler.:
- A Basic Method of generating a Key Pair, to be stored in some Binary Format,
- A Basic Encryption/Decryption method using those keys.
Has anyone any ideas,
Thanks,
Bram van Kampen
|
|
|
|
|
|
Today I received the source code for a DLL developed by a small company for us. The source code was part of the deal, and one of it's purposes was that we should be able to continue maintenance efforts once the main functionality of the library is done, and no more big issues remain.
Unfortunately, I've found the source code to be written auto-generated as CWEB, using a Literate Programming tool. That means these files cannot be directly read by the compiler, nor interpreted with the integrated tools of the IDE. I've requested the 'tangled' C++ source files (i. e. processed by ctangle.exe into .h and .cpp files), to be able to at least read them into my UML tool, but that code has all comments and blanks removed, so is not in a suitable form to be read in the IDE either.
In the UML tool I now have several hundred classes, structs, typedefs and enums all entangled into one huge diagram. The information I get from this is nicely summarized into one word: HELP!
What I currently have is:
- 359 auto- generated CWEB files (.w extension, some with a .hw extension, and a few others), in one and the same directory (actually I believe some of these are in fact not generated and don't belong there)
- these CWEB files have comments and proper formatting, but are unreadable by my tools
- alternately 245 C++ files (no idea why there are less of these)
- C++ files have no comments or blanks or tabs (but do have linebreaks at least)
- There's no 1-1 relation between source files and classes (neither for the CWEB files nor the C++ files): the total number of classes is around 300-500. Apparently some files contain dozens of classes, others none at all.
In short, it's a total mess.
I'm now at a loss what to do about it: I can no longer trust the original programmer to maintain it (there already has been significant doubt before), but I have no idea how to take care of it myself either. Since the whole of it is just generated code, I'd have to look at the original code used to generate the .w files, but I am neither familiar with Literate Programming, nor with the tools available for them. Also I have the nagging feeling that I won't be able to use any of the tools that I know if I wanted to work with that code.
I don't see any sense in refactoring the generated code into managable packages. But what else can I do? At this point the only alternative I see is rewrite the entire library from scratch
Maybe someone with experience in Literate Programming can give me an estimate as to how much time it would take for me to get into it, to a point where I would be able to clean up on the higher level?
|
|
|
|
|
Are the .w and .hw files needed to rebuild the DLL?
Can you run the C++ files through some sort or beautifer to put indentation and spaces back in?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
1. No. The only additional 'information' they contain are the comments. But then I would be better served by the original files used to generate them: they too are illegible to my tools, specifically as they do use lots of symbols that may not even be printed correctly without the right editor, but at least that code is at least theoretically meant to be human-readable
2. Yes: manually I can just press Ctrl-A, Ctrl-K, Ctrl-F. it's just that I don't feel like doing that for 245 files, and definitely not again when there is an update and the entire set of files gets regenerated. But even if there will be no updates, reformatting does not add the comments back in, nor remove the annoying compiler directives that make VA Outline all but unreadable in larger files. Besides, even formatting doesn't change the fact that the code wasn't generated with readability in mind...
|
|
|
|
|
Was there a specifications or requirements document agreed upon by this other company and yours? In other words, were you expecting to receive "plain" C++ files in the end?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
The contract just says that we should be able to build it with our IDE. We're still on a friendly basis, so I suppose we could ask for some help, but I'm afraid we need a lot more than 'some' help.
|
|
|
|
|
Stefan_Lang wrote: using a Literate Programming tool.
Why can't you just learn and use that tool?
|
|
|
|
|
I considered it. I really did, although I wasn't happy about that. I spent several hours to learn about it, skimming articles on the issue, with a special focus on the things I knew to be a weakness in the current library. As matters stand, every single article I've specifically searched for either didn't address the keywords I searched for, addressed them in a different context, or put a rather negative view on the whole context of LP.
I am now pretty sure that
1. LP is detrimental to team development
2. ignores interoperability with most modern SW development tools and therefore in the long run will in fact produce low quality code by modern standards, in spite of it's proclaimed goals to produce high quality.
3. Has no consideration whatsoever regarding performance, and in fact, due to automated code generation makes it near impossible to care about that. (performance is crucial for our purposes, and we made a point of that)
4. Does not prevent the programmer to produce bad code: It didn't take me long to spot some pretty horrible things in the code we got. I've yet to find out if these come from generated code or are in fact coded into the original algorithm. But in the end that does not matter.
Judging by the articles I looked into, I got the impression LP never really got outside universities. And it seems for very good reasons. I'm not going to put effort into changing that.
|
|
|
|
|
Stefan_Lang wrote: 1. LP is detrimental to team development...I got the impression LP never really got outside universities
Possible I suppose. However Literate Programming is an idiom, not a tool. The problem here is the tool.
Stefan_Lang wrote: 4. Does not prevent the programmer to produce bad code: It didn't take me long to spot some pretty horrible things in the code we got.
Not sure what that means.
Generated code doesn't have to be pretty. Myself I prefer that it makes an attempt to be so, but it isn't a requirement. And actually there are specific things that I expect from generated code, such as repeating the same code over and over again in different places.
Now it could be that the tool generates bad code (nothing to do with pretty.) Or it could be that the use of the tool in the first place was incorrect. That latter problem can be corrected by learning how the tool works and then correcting the input source so the generated code is better. The former problem can normally only be solved by fixing the tool.
Stefan_Lang wrote: 3. Has no consideration whatsoever regarding performance, and in fact, due to automated code generation makes it near impossible to care about that. (performance is crucial for our purposes, and we made a point of that)
That is a process problem not a technological problem. If your company contracted performance critical code to a third part and didn't stipulate performance criteria then then failure is in the outsourcing process and has nothing to do with the implementation. The performance failure could have resulted regardless of the implementation methodology and actually, with no performance criteria in the contract, probably would have (presuming not trivial code.)
|
|
|
|
|
jschell wrote: Generated code doesn't have to be pretty.
As it turned out the .w files were not generated after all: they're all hand-written just as they are. But I was talking about code quality anyway, not prettyness.
jschell wrote: failure is in the outsourcing process
Agreed. I could elaborate on that, but I'm not here to complain over past failures (ok, that as well, but I'm almost done on that part ), but to get advice what I could do to fix it.
|
|
|
|
|
Hi,
It Is 'UnLearnable' as I understand it, This OP was presented for his employer by one of those 'Intermediate' File Generators, produced by one of those intractable .NET,C#, Matrix, or other devilish software tool.
The File is written in CPP, but Un Documented.
Written in a format, easy to generate by a code generator, not intended for Human Consumption.
Example:
<br />
class ABCDEF110{ABCDEF110();~ABCDEF110();protected: V ABCDEF110(PQR ST){V=ST,YZ}<br />
};<br />
It deserves a Decent Decompiler before you start on this one.
That will take a Lot of Time and Efford. Someone is on the Take Here, probably Not the OP,Probably the Outside Contractor.
Bram van Kampen
|
|
|
|
|
Ouch!
One of our guys suggested some 3 years ago, that we should specify what Tools, and Platforms should be able to handle the Documentation provided for a Project. In the end, we included it reluctantly in our Doc Spec. (It may do No Good, but it doesn't do any harm, except from possibly adding a bit to the price.) I suspect that you now wish that that guy worked for you.
I Suggest you still speak to the programmer (small company). If he is half decent, and is looking for new business, and is interested in keeping up a reputation, he should be willing to assist. If at the otherhand, he takes the attitude of 'Gotche by the Goolies, I have the Real Source Code, Come to me for Ever and Ever for mantenance', that would be deception.
I take it that you have already 'at least' Part paid him.
I do not know under what jurisdiction the contract was signed. Here in the UK you would have various legal options. If you specified in your Contract that you require the source code for software maintenance purposes, you can reasonably expect to receive them in a format that 'your' tools can accept. Seeing that in this relationship he would be classed as the 'expert', it would be incumbent on him (her?) to discuss with you at an early stage as to the format details of the documentation provided.
It may also not be possible to generate Human Readible Source Code that can be loaded into an IDE, from the Source Script your developer wrote for his Code Generator. In that case, Cut your Losses (and Sue if Possible).
Best to speak to a Solicitor at this stage.
Sorry to hear about your Trouble,
Regards,
Bram van Kampen
|
|
|
|
|
Thanks for your response.
I'm afraid that legal action won't get us anything much - what we need most is get our work done, and no amount of jurisdiction will help us achieve it. And anyway, that's something my superiors will have to decide.
In the meantime I'm still stuck with the problem of making things work. That's why I posted here, in the hopes someone with experience in LP might have an idea about how to deal with it.
|
|
|
|
|
Hi,
Well, At Least you have Superiors. (I've Not). That means that your paycheck is secure. Well, look at this one, You're given an impossible problem, (which you cannot solve), You're sacked because of incompetence. In walks this stranger after you're sacked, looks at the documents provided by the contractor, and says, 'YESS' I can Work with this!, and Solves the Problem. Take care, that that was not a Stooge, planted to look for your job!
I Don't know your Circumstances, who you are or what you do!. My first reaction on reading your post was 'Shurely SoMeOne is trying to pull a Scam' 'Literal Code' essentially comprises a Program, still compilable under 'C' or 'CPP', which would be produced as an intermediate file to the final compiler.
It should come with a header File.Equally Abstract. It is Human Readible to the extent that it can be reproduced in print( it does not contain 'Awquard' Characters, such as \b(bell) etc.
Human Readible Text means just that.: That if it is printed, you can read all chars. It does not mean that what is printed makes Human Sense
Bram van Kampen
|
|
|
|
|