|
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
|
|
|
|
|
You could do it like this:
int datatype;
unsigned char *value;
int sizeofvalue;
if(RegEnumValue(hKey,i,achValue,&cchValue,0,&datatype,value,&sizeofvalue) == ERROR_SUCCESS){
switch(datatype){
case REG_DWORD:
printf("%d",*((int*)value));
break;
case REG_NONE:
printf(...);
break;
case REG_EXPAND_SZ:
printf(...);
break;
case REG_SZ:
printf(...);
break;
case REG_MULTI_SZ:
printf(...);
break;
default:
printf(...);
break;
}
}
Where datatype will identify the type of information, achValue the name of the value, value the actual value and sizeofvalue the size of the value.
I added an example printf for REG_DWORD.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
As mentioned in my response, this still will not get the values since the variables datatype , value and sizeofvalue need to be initialised before each call to RegEnumValue() .
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I am interested in using my static lib to create a dll (implicitly linking). which means I need to (in vs2008) create a dll project that should generate the following:
1. header file (which have exported function declarations. These are simple wrappers to actual functions in the static lib and are using __declspec(dllexport) which are in the dll centric .cpp file)
2. import lib which will be made as a result of creating the dll
3. the actual dll which is created.
Now this is what I have:
I have made a test program that will utilize the above dll(including the import lib/header files) to test it. in this I have included all the three items. now the exe compiles/links without issue. however in the main.cpp when i call the exported functions they seem to see the exported dlls...but can't seem to execute the static library functions which they wrap.
i have tested the static lib against the exe and it works fine.
but when i put the dll in between the wrappers just dont seem to run the static library functions... i am at a loss.
there are no compile/link errors. no warnings. i am just thinking hhow do i find out if the static lib is properly being used by the dll? i have no way of knowing that i guess in vs2008. any help would be most apprecaited
|
|
|
|
|
Android Lava wrote: when i call the exported functions they seem to see the exported dlls...but can't seem to execute the static library functions which they wrap.
I'm not sure I understand what you mean here. Are you saying that the functions inside the DLL are supposed to call functions inside the static library? If that is the case then the static library needs to be linked in to your DLL when it is built.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
How do you know it's not calling the functions? Is the output wrong? Are you using breakpoints in the static library and seeing that you are not getting there?
If I get what you are doing, you should have TWO copies of the static library functions in your final memory image, one copy accessed by the main code and linked in when the main.exe is built and one copy inside the DLL itself that was linked in when the DLL file was created.
So, you say "can't seem to execute the static library functions". How have you determined that?
|
|
|
|