|
Well, if that's the case then the interlock between the scroll and the update should be relatively easy to manage. The thread that is doing the updates (assuming you move the update code out of the message loop) grabs a "lock" (an EVENT) before updating the cells and releases it when it's finished. The "scroll" message processing grabs the same "lock" before processing the scroll and releases it after. Neither should collide.
I assume you have worked out the issues with having a stock symbols location moving between any two bursts of input data due to scrolling as you do have scrolling working at all.
So, as I said in a previous post, it would seem to be better to process and update the control in one process away from the GUI message loop, something you've tried before and saw a performance improvement (reduced cpu usage) and probably enhanced responsiveness to the updates.
|
|
|
|
|
If the visible part of the control only represents some of the data, then can you maintain a sort of database of data, updated every .5 seconds, but only display a small part of the data at a time, depending of course on the scroll position?
==============================
Nothing to say.
|
|
|
|
|
As a possible step to improve performance, have you tried using LockWindowUpdate on the control while you are adding the new data to it, and then calling UnlockWindowUpdate after?
This stops the control trying to redraw itself on each event that modifies its content. Untill all the modifications have been done.
If you vote me down, my score will only get lower
|
|
|
|
|
Good tip.
==============================
Nothing to say.
|
|
|
|
|
I have a very small form on to a property page. If the user have not save the modification, I want to prevent closing property page ... but I can't do that.
Here is the code where I start the property page :
CTestSheet PropertySheet(_T("Test"),NULL,0);
PropertySheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
PropertySheet.AddPage(new CTestPage);
PropertySheet.DoModal();
delete PropertySheet.GetPage(0);
and I override OnClose handler in property page, in property sheet, I override OnDestroy in property sheet ... in vain ... doesn't function ... why ?
|
|
|
|
|
The Big [X] or system menu (in the icon) of Close (Alt+F4) comes in through "ON_WM_SYSCOMMAND". In your processing look for "SC_CLOSE". If you don't have one, you'll need to add
ON_WM_SYSCOMMAND() to your Message Map.
void YourClass::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == SC_CLOSE)
{
}
}
Once you've seen the SC_CLOSE message, you can check with the PropertyPages to see if it is OK to proceed or to popup a message about saving data.
|
|
|
|
|
Flaviu2 wrote: If the user have not save the modification, I want to prevent closing property page ... but I can't do that.
Have you considered calling the page's SetModified() method, overriding the page's OnKillActive() method, or handling the TCN_SELCHANGING notification?
"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
|
|
|
|
|
I solve the problem, overriding OnKillActive event. Thank you very much !
|
|
|
|
|
Hi all,
i am playing a video in my application using directx.
i have made a dialog based application and on that i have put a static control in which i am showing video.
My problem is after playing my video when i minimize my window my static control becomes empty. And if i again move the window the video starts displaying again i.e. there is problem in refreshing.
But i am not getting how to resolve it?
Can anybody please help me in this??
thanks in advance
|
|
|
|
|
Just a quick guess: try toggling the 'clip children' style of the hosting dialog.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
I'm writing some port forwarding code and don't have control over the size of the data being sent/received. So I need to always have a recv queued even though I may possible be in the middle of a write (since my overlapped sockets are reading and writing to and from each other whenever recv gets new data on either side).
How do I allow for the possibility that an unblocked worker thread could be processing a read or a write? IOW how do I know if GetQueuedCompletionStatus was unblocked for a pending WSARecv or WSASend?
thanks.
---jt
modified 16-Nov-11 15:47pm.
|
|
|
|
|
I would do it by using separate event handles for the read and the write, and then inspecting the return value from your wait function to see which event handle was signaled.
EDIT ==========
OK, I see what you're doing. You're polling GetQueuedCompletionStatus, right? Well that's not the optimum model to use with completion ports, as you see.
You're much better off using the OVERLAPPED structure when you call WSARecv and WSASend, and then seeing which event handle is signaled.
Here's the pseudo code:
ORecv = new OVERLAPPED struct;
Set ORecv's event handle to your Recv event;
call WSARecv with ORecv;
OSend = new OVERLAPPED struct;
Set OSend's event handle to your Send event;
call WSASend with OSend;
Wait on the two handles;
See which handle was signalled,
and then call GetQueuedCompletionStatus;
The difficult we do right away...
...the impossible takes slightly longer.
modified 16-Nov-11 16:45pm.
|
|
|
|
|
Thanks. I'm not polling, I am using the overlapped structure in send and recv but hadn't thought to use separate structures for send versus recv. That should work...thanks.
|
|
|
|
|
I personally don't like the idea of waiting on OVERLAPPED handles. I'd much rather not introduce more (or any) synchronization objects to the IOCP handler threads but instead let the IOCP do its magic with all threads waiting on GetQueuedCompletionStatus.
I take advantage of the fact that the same overlapped structure pointer you pass to an overlapped function will be returned to you so I use extended OVERLAPPED structures like the one in this article[^]
typedef struct _OVERLAPPEDPLUS {
OVERLAPPED ol;
SOCKET s, sclient;
int OpCode;
WSABUF wbuf;
DWORD dwBytes, dwFlags;
} OVERLAPPEDPLUS;
The opcode can be used to indicate read or write (and many other things including non-I/O tasks you
want to queue on the IOCP). Also gives you a handy place to keep buffers associated with the operation.
Mark Salsbery
|
|
|
|
|
Wow. That's a great tip. Thanks for sharing!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello,
Does someone tried to recompile the class CSimpleDate with visual studio 2010 without error?
Is there an equivalent class for managing dates and compile under Visual Studio 2010?
|
|
|
|
|
|
xylo wrote: Does someone tried to recompile the class CSimpleDate with visual studio 2010 without error?
You might ask the author, since it was initially created with VS6.
"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
|
|
|
|
|
(I'm such a good boy)
it compiles ok when you fix the 2, 3 _very_ simple compilation errors (VC6 was a crappy compiler); and fix the unsafe functions (I did not fix them).
The project crashes because there are memory overruns (could be fixed by replacing unsafe functions with their safe variants.
Watched code never compiles.
|
|
|
|
|
|
Hi All,
I know there are a lot of people over here who have a diverse set of knowledge.
Why not we collaborate and start some C/C++ tools/application development that can benefit us and others also.
We can list out our skills, what tools are required and go about developing it and posting it out in CodeProject.
Please let me know your views on this.
~Thanks
Shakti
India, Bangalore
I am experienced in C/C++.
|
|
|
|
|
Shakti Misra wrote: Please let me know your views on this.
The question belongs here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks. I have moved it there. I am not able to delete this post. So may be close it.
|
|
|
|
|
from msdn.microsoft.com - Enumerating Registry Subkeys:
http://msdn.microsoft.com/En-US/library/ms724256.aspx
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define MAX_KEY_LENGTH 255
#define MAX_VALUE_NAME 16383
void QueryKey(HKEY hKey)
{
TCHAR achKey[MAX_KEY_LENGTH]; DWORD cbName; TCHAR achClass[MAX_PATH] = TEXT(""); DWORD cchClassName = MAX_PATH; DWORD cSubKeys=0; DWORD cbMaxSubKey; DWORD cchMaxClass; DWORD cValues; DWORD cchMaxValue; DWORD cbMaxValueData; DWORD cbSecurityDescriptor; FILETIME ftLastWriteTime;
DWORD i, retCode;
TCHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
retCode = RegQueryInfoKey(
hKey, achClass, &cchClassName, NULL, &cSubKeys, &cbMaxSubKey, &cchMaxClass, &cValues, &cchMaxValue, &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
if (cSubKeys)
{
printf( "\nNumber of subkeys: %d\n", cSubKeys);
for (i=0; i<cSubKeys; i++)
{
cbName = MAX_KEY_LENGTH;
retCode = RegEnumKeyEx(hKey, i,
achKey,
&cbName,
NULL,
NULL,
NULL,
&ftLastWriteTime);
if (retCode == ERROR_SUCCESS)
{
_tprintf(TEXT("(%d) %s\n"), i+1, achKey);
}
}
}
if (cValues)
{
printf( "\nNumber of values: %d\n", cValues);
for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++)
{
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retCode = RegEnumValue(hKey, i,
achValue,
&cchValue,
NULL,
NULL,
NULL,
NULL);
if (retCode == ERROR_SUCCESS )
{
_tprintf(TEXT("(%d) %s\n"), i+1, achValue);
}
}
}
}
void __cdecl _tmain(void)
{
HKEY hTestKey;
if( RegOpenKeyEx( HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft"),
0,
KEY_READ,
&hTestKey) == ERROR_SUCCESS
)
{
QueryKey(hTestKey);
}
RegCloseKey(hTestKey);
}
how can i modify that code at:
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retCode = RegEnumValue(hKey, i,
achValue,
&cchValue,
NULL,
NULL,
NULL,
NULL);
if (retCode == ERROR_SUCCESS )
{
_tprintf(TEXT("(%d) %s\n"), i+1, achValue);
}
to output to the console all the values that RegEnumValue function can return, function at msdn: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724865%28v=vs.85%29.aspx i want to output these vars too:
__out LPTSTR lpValueName,
__inout LPDWORD lpcchValueName,
__out_opt LPDWORD lpType,
__out_opt LPBYTE lpData,
__inout_opt LPDWORD lpcbData
i have tried different things but everytime i change any of NULL var from that function:
retCode = RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL);
i even don´t get achValue
thanks a lot
PD using windows 7 64 bits visual studio 2010 ultimate
|
|
|
|
|
You need to initialize your parameters as described in the documentation[^], so that the API knows how long your buffers are and what values you want returned. Using NULL as the input parameter tells the API to ignore that part of the request.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|