|
Thanx a lot...
birajendu
CyberG India
Delhi
India
|
|
|
|
|
You can use of ShowWindow and you need to a handle to another program for again show it
|
|
|
|
|
thanx..
birajendu
CyberG India
Delhi
India
|
|
|
|
|
Hi,
I'm facing a problem with the COM Dll that is also written by us.
I have a COM Dll, which uses another two dlls. And for UI I have another application which uses the COM Dll(The application is a Win32 application without MFC Support).
When the COM Dll is built in the release mode, CoCreateInstance method causes the message box "User breakpoint called" to be popped up.
In fact the CoCreateInstance does so many other things like initializing the communication, initializing the drive..etc.
When the Dll is built in the release mode, it causes no problem.
The problem I've identified is in the statement where delete <someobject> was being called.
The interesting fact is that the problem does not araises with the applications with MFC Support. My one perticular application is without MFC Support. The COM Dll is built with Static MFC support.
Another thing is that, to make tha applicaion up the COM Dll should be built with the Shared MFC Dll support. But when I make COM Dll with shared MFC, other applications(those were built with MFC support earlier) does not work.
I'm confused how the MFC support for the COM Dll affect the behaviur of the applications. Please provede me with a solution.
Thanks and regards,
Raja Pratap Reddy
|
|
|
|
|
Hello Friends.
When I click on the Item in the listCtrl, next Item should also be selected.
I did it by using SetItemState() method.
When I select item it works fine i.e next item is also selected but when
I click on that selected item,ideally,the item next to it shld be selected.
But it only flashes...I mean it is selected and next moment it gets deselected by itself.
Here is my code ..
Its written in the function of NM_CLICK Message.
CODE :
BOOL l_bRet = 0;
POSITION pos = m_SelList.GetFirstSelectedItemPosition();
int index = (int)pos;
for(int j=(index-1); j
|
|
|
|
|
Hi All,
I have a snap-in application which was wriiten for MMC 2.0 using MMC
2.0 SDK. On porting the sample application on Longhorn which has MMC
3.0 by default, I get the snap-in error asking whether I need to
shutdown mmc application.(" MMC has detected an error in snapin.....").
I was not able to find any C++ samples along with MMC 3.0 SDK. Are
there any additional callbacks that I need tp include to provide
support for MMC 3.0? If yes, where from I can get them? Any pointers to
the C++ samples for MMC 3.0? Any help on this would be appreciated.
Regards
Uthra
Uthra ragavan
|
|
|
|
|
Hi,
I have implemented in the code for wmi.
It works just fine for cimv2 workspace and Win32_OperatingSystem class.
It is not working for any other class (i need Win32_CDROMDrive) in cimv2 namespace. Not even working for root/wmi namespace.
part of my code is :
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if (FAILED(hr)){
AfxMessageBox("Failed");
}
if(0 == uReturn)
{
break;
}
}
It successfully connects to the namespace but later, it gets uReturn as zero always and breaks.
I tried BeginEnumeration as well before executing 'next'.
(For wmi namespace, 'hr' fails after connecting to the namespace.)
Is there anything else that I need to do?
Please help.
Thanks ,
Manasi
|
|
|
|
|
Here[^] is an example of Win32_CDROMDrive of course in C# (I think you can understand it)
only see (foreach(datatype variablename in Arrayname) )
(1)datatype is type like char/int,...
(2) variable name for detect elemets in array
(3) arrayname name of Array
|
|
|
|
|
|
I hope it solved your problem
|
|
|
|
|
I am doing a windows form application in ms VC++ . I am using MS Visual C++ Express Edition 2005 IDE. I am not able to get a standalone application when I compile the code.The compiled code only works on comps which have the IDE installed. Cant i get a standalone application that requires .NET Frame work only to be installed and not on the IDE?
SBK
|
|
|
|
|
You need to ship dependent dlls, to work your application.
|
|
|
|
|
Your app will create a manifest file, or embedd one. This tells windows what else your program needs. There's a VC++ redistributable that sets up all the WinSXS stuff you may need, that will probably solve the problem.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Would somebody be so kind as to show me exactly how to create a non-named event with an EVENT_MODIFY_STATE access rights. This is to be used with a multimedia timer but my events are never being triggered. All the examples I can find are for named events
|
|
|
|
|
I always just use CreateEvent().
hTimerEvent = ::CreateEvent(NULL, false, false, NULL);
and pass (LPTIMECALLBACK)hTimerEvent to ::timeSetEvent() with the TIME_CALLBACK_EVENT_SET timer
event type.
Mark
|
|
|
|
|
Mark Salsbery wrote: I always just use CreateEvent().
Strange, I can't get it to work for me. Here's the layout
I create the Event and the timer from my main thread, I launch a seperate thread which calls WaitForMultipleObjects(). I then call ResetEvent() and inform the main thread the evvent has occured. But! the event doesn't occur no matter what paramaters I call the various functions with.
Could this be some sort of thread related problem?
|
|
|
|
|
WalderMort wrote: I then call ResetEvent()...
Reset? It's a manual reset event then?
WaitForMultipleObjects() never returns?
|
|
|
|
|
I have tried both manual and auto resets, neither work. I have also tried named events, they don't work either. WaitForMultipleObjects() doesn't indicate that the event is set, but then it's on a 500ms timeout to prevent locking the handles.
Everything works perfectly if I use a callback function, but that's not what I want.
From MSDN:
"Any thread of the calling process can specify the event-object handle in a call to one of the wait functions.
So my code should be working.
|
|
|
|
|
Some sample code...
UINT wTimerRes = 0;
MMRESULT mmTimerId = 0;
HANDLE hTimerEvent = ::CreateEvent(NULL, false, false, NULL);
TIMECAPS tc;
if (::timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR)
{
wTimerRes = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
::timeBeginPeriod(wTimerRes);
mmTimerId = ::timeSetEvent(500, wTimerRes, (LPTIMECALLBACK)hTimerEvent, (DWORD_PTR)0,
TIME_PERIODIC | TIME_CALLBACK_EVENT_SET);
}
int n = 0;
while (n < 10)
{
::WaitForSingleObject(hTimerEvent, INFINITE);
n++;
}
if (mmTimerId)
{
::timeKillEvent(mmTimerId);
mmTimerId = 0;
::timeEndPeriod(wTimerRes);
wTimerRes = 0;
}
::CloseHandle(hTimerEvent);
hTimerEvent = NULL;
|
|
|
|
|
Just an update. I never could get the multimedia timers to work with more than one event. I ended up changing the code slightly.
I now create an event for each timer just as before, but I create the timer using a callback function. Within this function I set the event ( which is what MMtimer is supposed to do! ). I then run a thread which waits on these events and does whatever the user intended.
|
|
|
|
|
hmmm beats me. I tested the code I posted before posting it.
Here's how I wait in many of my thread procs...maybe there's something that's different than
yours...
while (1)
{
#define EVENT_TIMER 0
#define EVENT_TERMINATE 1
HANDLE Events[] =
{
hTimerEvent,
hTerminateEvent
};
DWORD dwEventIndex = ::WaitForMultipleObjects(sizeof(Events) / sizeof(HANDLE),
Events, FALSE, INFINITE);
if (dwEventIndex == WAIT_FAILED)
{
break;
}
dwEventIndex -= WAIT_OBJECT_0;
if (dwEventIndex == EVENT_TERMINATE)
{
break;
}
... timer event occurred - do something
}
|
|
|
|
|
The only real difference is that I use dynamic arrays, but on watching through the debugger, the correct values are being passed in. Thinking that may be the problem, I instructed the thread to copy the handles to it's own 'stack based' array, the problem didn't go away.
I then thought that the events may be being set at exactly the same time ( Wait... returns only 1 index in such a case ) and tried a manual set and reset, no luck. Even with wait INFINITE for all objects.
I must try the same with other object like mutex's, it may be a bug within windows vista.
One question though, the docs say a timer is run in it's own thread. I set two timers and 1 worker thread. The 'task manager' states my exe has only 3 threads. So I'm guessing MMtimer creates a single thread to watch all timers, is this correct?
|
|
|
|
|
WalderMort wrote: I then thought that the events may be being set at exactly the same time
( Wait... returns only 1 index in such a case )
That's definitely a possibility. If you need to differentiate between which timer event occurred
then you'd have to use separate events instead of sharing one event. I would think sharing
an event would kind of negate the need for the precision of a multimedia timer anyway.
WalderMort wrote: I set two timers and 1 worker thread. The 'task manager' states my exe has only 3 threads.
So I'm guessing MMtimer creates a single thread to watch all timers, is this correct?
I know nothing about the internals of the multimedia timers, sorry I would guess that none
of the timer threads are in your/our process though (kernel?), so maybe they don't show up...
From this article: Results from a Latency Study of Windows NT[^]
"Multimedia timers are implemented by spawning a high-priority thread that sets a kernel timer
and then blocks. Upon awakening the thread executes a callback routine provided by the user,
schedules its next wakeup, and then goes back to sleep."
It's interesting that it's not working as advertised for you. I've never had any probs with the
multimedia timers but I do hope my software runs on Vista
Does the first code sample I posted work for you? That code can be inserted anywhere - it
doesn't need a separate thread.
Mark
|
|
|
|
|
I am currently working on a 2D shooter game, and I would like to be able to include enemy turrets that will be able to rotate towards the player to be able to fire at the player. The turrets have an angle variable, which stores which angle they are currently being rotated by (so which direction they're facing), and I want them to be able to track the player and determine which direction to turn to face the player the quickest. Let me attempt to explain this graphically
--------
Player
--------
--------
Turret -----> Current Firing Direction
--------
In this situation, assuming the player is 135 degrees from the turret, and the turret's rotation is 0, how can I make the turret understand that the best way to track the player is by rotating counterclockwise instead of clockwise? I have tried several methods, including attempts at using the dot products of the 2 vectors, etc. If anyone has any suggestions all help will be appreciated! Thanks!
-Steve
|
|
|
|
|
You could use the cross product[^]. To cut a long story short use this formula:
dir = x1.y2-x2.y1
Note that "." means multiply and only the sign of "dir" is of interest: +ve means anticlockwise and -ve clockwise, or the opposite if you're using a 4th quadrant coordinate system (which is probably the case here). (x1, y1) is the coordinates of the end of the turret on the firing ship, relative to the base of the turret. (x2, y2) is the point you're aiming for, relative to the base of the turret on the firing ship.
Steve
|
|
|
|