|
OnMouseMove is a message handler, you need to read the MSDN understand the messaging. The messages come out of the queue and get handled...
Drawing has to be done in OnPaint().
Greetings from Germany
|
|
|
|
|
OMG , I didn't realized about it. I thought he was calling the OnPaint when mouse moved. I need to buy me glasses :P
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
|
|
|
|
|
When moving the mouse, WM_PAINT won't be sent, is it sure?
I think it is, so I draw in OnMouseMove, just like scratch in the client when press the left button and dragging in mspaint.
|
|
|
|
|
followait wrote: When moving the mouse, WM_PAINT won't be sent, is it sure?
Like KarstenK said, you need to read documentation about painting and message handling. Stop typing questions in forums and READ
|
|
|
|
|
I had read it.
WM_PAINT
WM_MOUSEMOVE
But no answer.
And I read the example Scribble in msdn, it draws in OnMouseMove, but no blinking. I don't know why, maybe the drawing in simple enough.
I also made a test, it shows that in OnMouseMove, OnDraw will not be called.
The problem is I bitblt from memory dc to real dc only once, though slow, it should not blink, then why does it blink?
|
|
|
|
|
followait wrote: And I read the example Scribble in msdn, it draws in OnMouseMove, but no blinking. I don't know why, maybe the drawing in simple enough.
I am almost sure that for the scribble example, they only store points coordinates in the OnMouseMouse message and they only draw things (meaning calling to MoveTo and LineTo) in the OnPaint handler (and they probably call Invalidate so that the window gets repainted).
At least, that's they way they should do it .
|
|
|
|
|
It is not sent if you dont send it.
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
|
|
|
|
|
The screen is erased before being repainted (at least in the most of the cases). If you are calling UpdateWindow (), pDoc->UpdateAllViews (), OnPaint (), OnDraw () or whatever other function that causes a screen update when you move the mouse...
I find totally logical that the screen blink. The computer must delete and repaint all the screen for every and every detected move of the mouse.
if you want to avoid it... just update a little region around the cursor, and dont the whole client area.
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
|
|
|
|
|
Not only blink, but also slow, the cross lines can't followait the mouse quickly.
What's the way?
|
|
|
|
|
You update the screen twice, with a very large amount of drawing between the two blits to the screen.
To reduce flicker, you should remove the first dc.BitBlt call. Also, playing around with the mapping modes and viewport extents causes the GDI queue to be flushed to the graphics card, IIRC, which is a slow operation in itself. You would be better off performing your calculations at the top of the code yourself rather than reconfiguring the DC just in order to get it to perform viewport corrections for you (which are simply a case of scaling the results).
As others have said, you get much better drawing performance from only drawing those areas of the window that have actually been updated.
It's generally recommended that you do all your drawing in WM_PAINT because if you don't, typically your WM_PAINT handler draws over whatever was done in your other code. This is typically a problem when switching between applications. Windows Vista DWM (Aero Glass) may give different results here, but DWM also expects you to do all your drawing in response to WM_PAINT messages (see here[^] for problems when drawing outside WM_PAINT).
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
I am trying to communicate (send and receive ASCII-characters) with a USB-barcode printer. In order to get a handle to the device I believe I have to call CreateFile and it has the following prototype:
HANDLE WINAPI CreateFile(
__in LPCTSTR lpFileName,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwCreationDisposition,
__in DWORD dwFlagsAndAttributes,
__in_opt HANDLE hTemplateFile
);
How do I determine what the first parameter should be? I guess it should be something similar to
"\\\\.\\xxxUSBxxx"
Where can I look for clues on what this string should be?
|
|
|
|
|
arnold_w wrote: How do I determine what the first parameter should be? I guess it should be something similar to
"\\\\.\\xxxUSBxxx"
No, USB is different than serial port on that point. It is not just "USB" and the number of the port.
The string you need to pass to the CreateFile function depends on the driver. Normally you should find it out in the documentation supplied with the device.
|
|
|
|
|
No such information was included in the documentation. Can I find out what it is somehow (looking in the device manager, searching the registry, find in files in system32/drivers, etc)?
|
|
|
|
|
|
Thanks for your replies. If I use the WinObj tool and select Device in the tree structure to the left, I am able to detect one entry which disappears when I unplug my USB-printer and appears when I connect it. However, the strange thing is that its name is not fixed. At first it was 000000C0, then after unpluggang and plugging it in again it was 000000C1, then 000000C2, etc. Thus, it appears to be incrementing each time I unplug and plug it in and if I use the current value as the first parameter to the call to CreateFile I get an error (GetLastError gives me error code 2). Is there any hope that I will be able to get this work?
|
|
|
|
|
|
Have a C++ routine, need to get the current month value, any ideas? Sid Kraft
Sid
|
|
|
|
|
|
There are plenty of date-related functions available for which you can obtain the month. For example, localtime(), time(), gmtime().
"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
|
|
|
|
|
Hi,
I have to restrict mouse clicks on the activex controls of
Windows media player or else say I want to allow only Menu Commands ,Maximise ,Minimise and Close messages to
the application.
For this I have used hooking to trap the windows messages
sent to the WMP application.
I hooked my procedure in to that WMP application and now I
can receive all messages before there are passed to window
procedure of the actual application.
I used the following code in my application to hook my procedure in to another appln.
HOOKPROC dllmsgFunction = (HOOKPROC)::GetProcAddress(m_HookDll, "MyMessageHook");
m_mymsgHook = SetWindowsHookEx(WH_CALLWNDPROC,dllmsgFunction,m_HookDll,dwThreadId);
"MyMessageHook" function is in a seperated Dll.
LRESULT CALLBACK MyMessageHook(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPSTRUCT* msg = (CWPSTRUCT*)lParam;
return ::CallNextHookEx(sg_hHook, nCode, wParam, lParam);
}
If I restrict WM_LBUTTONDOWN message , clicks on Menu bar and the complete application are also disabled
as for every mouse click there will be OnLbuttonDown.So, Iam unable to figure out the messages to restrict.
I need an approach to do this. Any suggestions or links would be helpful.
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
In lParam of mouse messages are also the coordinates included (packed)...
Greetings from Germany
|
|
|
|
|
Hi Friends,
My windows service spawns one child process.
While stopping this service my child process does not gets killed/
terminated as expected.
I do not have child process handle as this child process is created
by a third party library in my process.
Is there any good way to kill this child process?
I want to avoid process enumerations !
|
|
|
|
|
vikrams wrote: While stopping this service my child process does not gets killed/
terminated as expected.
Why would you expect it to happen?
Anyway, you can get the handle of the child process by using EnumProcesses
|
|
|
|
|
I am aware of that. But need more elegant solution.
|
|
|
|
|
I am looking for a way to correctly sort CStrings under Unicode.
Input:
Zéro
Ça
Cabane
Ouptut I get:
Cabane
Zéro
Ça
Output should be:
Cabane
Ça
Zéro
I have seen articles on the Unicode Collation Algorithm - Unicode Technical Standard #10, but how can I implement correct sorting with existing tools in Microsoft C++ MFC in a Unicode project? CompareNoCase and CollateNoCase do not give the expected correct result.
__________________
Peter M.C. Werner
Siscad SA
Route de l'Etraz 2
1183 Bursins, Switzerland
www.cadelec.com
|
|
|
|