|
As Far CsingLeObject Being Distructed I can always Create on the Heap as it will exist for the Life time of the app
Since threads are always Coming and going it may not be a bad idea to have to around
|
|
|
|
|
I think you need to redesign a bit your architecture. You first have the problems explained by Joe but it also feels completely wrong: your class IS a CSingleLock object and IS a CSyncObject ? This is akward. I guess you are trying to make something without really understanding what you are doing.
Maybe if you explain what you are trying to do (conceptually I mean, not low level code like here), we could help you design a better solution...
|
|
|
|
|
As far as what Joe Pointed the Csync Object getting destroyed before the Lock Object
the thread is in constant loop while(1) waitting to get signalled so it never ends
What I was trying to do since a CSingleLock needs a CsyncObject pointer make it all part of
one SuperClass
as said my code is a thread waitiing to get signaled when it does I single thread via the Lock
until the code finishes executing
thnakx
|
|
|
|
|
Following Cedric's response (which is quite correct) that your class shouldn't be both a lock and a sync object, here's a further suggestion that avoids both that confusion and the use of this in constructor calls.
Look at this page from Boost[^] describing the 'base-from-member' idiom.
Now, you could re-factor your code as:
struct mylock_pbase
{
mylock_pbase() : syncObject(NULL) {}
CSyncObject syncObject;
};
class mylock : private mylock_pbase, public CSingleLock
{
public:
mylock(BOOL bInitialLock) : mylock_pbase(),
CSingleLock(&syncObject, bInitialLock)
{
}
BOOL Unlock();
};
You could use the boost::base_from_member class, but it would only remove the need to declare mylock_pbase .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I understand your just mylockphase create a CsyncObject named syncobject
IS there a need for the : syncobject(NULL) wont the CsyncObject get created without it
btw what does the "explicit" qualifer in Font of the CSyncObject signify
|
|
|
|
|
ForNow wrote: syncobject(NULL)
I put that there because you had it in your original post
ForNow wrote: btw what does the "explicit" qualifer in Font of the CSyncObject signify
That the constructor can't be used (by the compiler) to perform implicit type-casts. It only really matters for single parameter constructors and should probably be used for most single-parameter constructors just to make sure you don't create objects unless you really meant to. Look at the documentation for it[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Thursday, April 2, 2009 3:33 AM
|
|
|
|
|
|
Hello. I have an application in VC++6.0 with MFC. I use ADO for Read/Write on file *.mdb.
When I link in DEBUG mode is OK.
When I link in RELEASE mode I get this error.
Which *.lib I must adding in link parametr? Or I must adding line code in my code source?
Thanks
error LNK2001: unresolved external symbol __imp__CoUninitialize@0
error LNK2001: unresolved external symbol __imp__CoInitialize@4
error LNK2001: unresolved external symbol "void __stdcall _com_issue_error(long)" (?_com_issue_error@@YGXJ@Z)
error LNK2001: unresolved external symbol "unsigned short * __stdcall _com_util::ConvertStringToBSTR(char const *)" (ConvertStringToBSTR@_com_util@@YGPAGPBD@Z)
error LNK2001: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(unsigned short *)" (?ConvertBSTRToString@_com_util@@YGPADPAG@Z)
error LNK2001: unresolved external symbol "void __stdcall _com_issue_errorex(long,struct IUnknown *,struct _GUID const &)" (?_com_issue_errorex@@YGXJPAUIUnknown@@ABU_GUID@@@Z)
error LNK2001: unresolved external symbol __imp__CLSIDFromProgID@8
error LNK2001: unresolved external symbol __imp__CLSIDFromString@8
error LNK2001: unresolved external symbol __imp__OleRun@4
error LNK2001: unresolved external symbol __imp__CoCreateInstance@20
fatal error LNK1120: 10 unresolved externals
Error executing link.exe.
|
|
|
|
|
Antonio2929 wrote: When I link in DEBUG mode is OK.
When I link in RELEASE mode I get this error.
Check your linker settings to make sure Debug and Release match.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
In DEBUG mode I use default libreries.
In RELEASE mode I must check "Ignore all default libreries" otherwise I get other error: type redefinition, ecc ecc..
|
|
|
|
|
Antonio2929 wrote: In RELEASE mode I must check "Ignore all default libreries" otherwise I get other error: type redefinition, ecc ecc..
No - you must not check Ignore all default libreries - you must work out why those other errors are occurring and then fix them. I suspect a mixing of C runtime libraries.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello everyone,
I want to set a break point and wants it to be triggered when a piece memory (begin address and length are known) are changed. I am working on Windows Server 2003 x64 platform. Either solution in Windbg or solution in Visual Studio are fine. My purpose is to monitor when the memory content is changed.
thanks in advance,
George
|
|
|
|
|
George_George wrote: ...solution in Visual Studio are fine.
Which version?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
In VS2008 (possibly previous versions), you want to create a new data breakpoint. That will watch a block of memory and break when any of it changes.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have posted this a few days ago in connect microsoft but apart from an automatic reply I had no more feedback and I was wondering if anybody here had already found this bug before.
It seems the WM_NCCALCSIZE message is not being correctly processed by Windows Vista when Desktop Composition is enabled. The identified behavior was only detected when Desktop Composition is enabled. If Desktop Composition is disabled, everything works fine. It also works fine on XP.
The idea behind the tests that lead to the bug was to use the WM_NCCALCSIZE message and the NCCALCSIZE_PARAMS structure to implement a window client area preservation scheme, in order to minimize flickering due to unnecessary processing of WM_PAINT messages. The window style was registered without the (CS_HREDRAW | CS_VREDRAW) flags.
The goal was to avoid having to process the WM_PAINT message when the window was being resized due to the dragging of the window left border to the right. The usual procedure, in most applications (e.g. Notepad), would be to keep the client area content aligned left. In my case a bitmap is being displayed on the client area and the intention was to keep it right aligned (not left aligned) when the window left border was being dragged. So, dragging the left border to the right would cover some portion on the left part of the bitmap, originally displayed on the client area. The remaining part of the bitmap (the part on the right) could be completely preserved and processing the WM_PAINT message could be avoided.
The rectangles on the NCCALCSIZE_PARAMS structure were processed so that the system would copy the window image that is within the source rectangle and clips the image to the destination rectangle. In this case both source and destination client area rectangles refer to the same coordinates (the bit map right portion, not covered by the drag of the left border to the right). As the result of processing the WM_NCCALCSIZE message (and NCCALCSIZE_PARAMS structure), WVR_VALIDRECTS was returned, according to the documentation.
If Windows Vista Desktop Composition is enable the content of the NCCALCSIZE_PARAMS structure seems to be ignored and the bitmap on the client area is kept left aligned (dragged to the right as the window left border is dragged to the right). Everything works fine if Desktop Composition is disabled.
An identical bug can be reproduced by resizing the window dragging the top window border in the bottom direction (the bottom part of the bitmap should be preserved and instead it is top alligned and dragged down).
The following steps describe a small sample code intended to demonstrate the behaviour previously described and nothing else.
A new empty win32 project was created.
A global variable was created to accommodate the bitmap handle:
HANDLE g_hBitmap;
The window style is registered in MyRegisterClass as
wcex.style = CS_DBLCLKS ;
In InitInstance a bitmap is loaded after CreateWindow:
g_hBitmap=LoadImage(0,
TEXT("bitmap.bmp"),
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION|LR_LOADFROMFILE);
In the WndProc callback the following variables and references were defined to support the following code:
HDC hdcMem;
RECT rect;
LONG& width=rect.right;
LONG& height=rect.bottom;
In the WndProc callback the following code was inserted:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd,&rect);
hdcMem=CreateCompatibleDC(hdc);
SelectObject(hdcMem, g_hBitmap);
BitBlt(hdc,0,0,width,height,hdcMem,0,0,SRCCOPY);
DeleteDC(hdcMem);
EndPaint(hWnd, &ps);
break;
case WM_NCCALCSIZE:
if(wParam==TRUE)
{
RECT r, ro;
NCCALCSIZE_PARAMS& s=*((NCCALCSIZE_PARAMS*)lParam);
r.left=s.rgrc[2].left+(s.rgrc[0].left-s.rgrc[1].left);
r.right=s.rgrc[2].right+(s.rgrc[0].right-s.rgrc[1].right);
r.top=s.rgrc[2].top+(s.rgrc[0].top-s.rgrc[1].top);
r.bottom=s.rgrc[2].bottom+(s.rgrc[0].bottom-s.rgrc[1].bottom);
s.rgrc[0]=r;
if(IntersectRect(&ro,&r,&s.rgrc[2]))
{
s.rgrc[1]=s.rgrc[2]=ro;
return WVR_VALIDRECTS;
}
return 0;
}
else
return DefWindowProc(hWnd,message,wParam,lParam);
break;
|
|
|
|
|
hi,
I have a packet filtering driver. How can i do url level filering?
aks
|
|
|
|
|
Looking for an efficient way to do this with out getting duplicates.
int XLOW = 0;
int XHIGH = 10;
do
{
n = rand()% (XHIGH - XLOW + 1) + XLOW;
XHIGH--;
} while (XHIGH != 0);
|
|
|
|
|
Are you simply wanting 10 unique numbers?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
|
Since you want numbers in a predefined range (0-10), the "secret" is to go ahead and fill an array with those numbers, and then just randomly swap those numbers around.
int array[10] = {0};
int n = 10;
for (int i = 0; i < n; i++)
array[i] = i;
for (i = 0; i < n; i++)
{
int j = rand() % n;
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
|
I would do (to mimic the extraction of random number from a bag)
void swap (int & a, int & b)
{
int t=a;
a=b;
b=t;
}
int array[10];
int n = 10;
int i;
for (i = 0; i < n; i++)
array[i] = i;
for (i = n; i > 1; i--)
{
int j = rand() % i;
swap( array[i-1], array[j] );
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm very new to audio. I stumbled across the following code and I'm using the it to play audio .mp3s in my DX9.0 app. ( Nov 08 SDK )
::CoInitialize(NULL);
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&g_pGraphBuilder);
g_pGraphBuilder->QueryInterface(IID_IMediaControl, (void **)&g_pMediaControl);
g_pGraphBuilder->AddSourceFilter(L"../Media/Audio/Music/Artifact_CharMain.mp3", L"../Media/Audio/Music/Artifact_CharMain.mp3", &pSource);
pSource->FindPin(L"Output", &pPin);
g_pGraphBuilder->Render(pPin);
pPin->Release();
g_pMediaControl->Run();
How can I make the .mp3 loop?
Thanks!
|
|
|
|
|
Fordfanboi wrote: How can I make the .mp3 loop?
I've never worked with the media control. That said, if the COM interfaces provide a feature that you can use to have the control loop the resource that would be the best approach. If it does not, then you will have to code a loop yourself, I guess.
|
|
|
|
|
Fordfanboi wrote: How can I make the .mp3 loop?
See here, about 3/4 of the way down.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|