|
Do you mean when the user logs on/off Windows or your program ?.
If it's windows, i think you'll need to write a GINA, a replacement to the windows security access (the logon dialog, shutdown, etc..) I've written one a few weeks ago for Windows NT 4/2000
There is an example on msdn, search for GINA.
Is not an easy task, I'm not sure this is the of solution you are looking for.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Yes For WIndows, I WIll look it up thanks
|
|
|
|
|
No I don't want to do that, I just need to know if the user who is , logged on and when they log on, or switch to another user.
|
|
|
|
|
Sorry, I don't get it, could you explain more ?.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Do a search on MSDN for WTSRegisterSessionNotification
Michael
|
|
|
|
|
Can't Find anything on that
|
|
|
|
|
I did.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Got me a little closer, thx, I see how to declare the program to recienve the notification, but how do I actually recieve the notification? do I have to make a loop or something to check for a notification every few seconds?
|
|
|
|
|
I'm trying to write an undo feature for a drawing program. I have an array of CPoint's called ShapePts[100]. I made another array of CPoint's Undo[100]. When the program deletes a point it finds the closest point to the mouse. So, I was thinking just store the point in another array before it gets deleted.
/* This is the MainFrame.h declaration */
CPoint Undo[100];
int nUndo;
void CMainFrame::OnLButtonDown (UINT nFlags,
CPoint MousePt)
{
int ShortDist;
if (nFlags & MK_SHIFT)
{
// Shift key down. So delete closest point.
if (nPts > 0) // - only if have one
{
// Step: Find point closest to MousePt
Pos = ClosestPoint (MousePt,ShapePts,nPts, ShortDist); <-- returns int
Undo[nUndo] = ShapePts[nPts]; // nPts and nUndo were initialized to
// zero in MainFrame contructor
// Step: Shift points down one array component index
for (int i = Pos + 1; i < nPts; i++)
{
ShapePts[i-1] = ShapePts[i];
}
nPts--; // adjust count
} // end if
}
else
{
if (nPts >= 99) // array full
return; // do nothing
else
{
ShapePts[nPts] = MousePt;
nPts++;
CString s;
s.Format("Last pt d, %d)",MousePt.x, MousePt.y);
myStatusBar.SetText (s,1,SBT_NOBORDERS);
}
}
Invalidate();
}
void CMainFrame::OnRButtonDown (UINT nFlags, CPoint MousePt)
{
CPoint ScreenPt;
int ShortestDist, i;
// Step 1: Find position of closest pt in array
Pos = ClosestPoint (MousePt, ShapePts, nPts, ShortestDist);
if(nFlags & MK_SHIFT)
{
ShapePts[nPts] = Undo[nUndo];
nPts++;
for(i = 0; i < nUndo; i++)
{
Undo[i-1] = Undo[i];
}
nUndo--;
}
else
{
SetCapture();
// Step 2: Move the cursor to that position
ScreenPt = ShapePts[Pos];
ClientToScreen (&ScreenPt);
SetCursorPos (ScreenPt.x, ScreenPt.y);
}
}
Where am I going wrong. If you need more info please let me know.
-CDudd
|
|
|
|
|
I don't get why your undo is a collection of points, but why not use a deque, then you can upll undos from one end, and drop them from the other as you push them in when you reach the size you want.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
There isn't a point at Undo [nUndo]. All the points exist between 0 and nUndo - 1. You can correct this problem by decrementing nUndo prior to the Undo [nUndo] line. Also, since you are getting the top element off the undo stack, there is no need for that block of code shifting the undo stack down.
After you get it working, look into std::deqeu. It would really simplify the code.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Could you help me ?
I need that user can save a orders as RTF or DOC file without using the CRichEdit. ??
Wiizi
|
|
|
|
|
AFAIK, RTF is a text format, so it shouldn't be too hard to write. Check http://www.wotsit.org/, there's prolly a description there.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
|
Does Visual C++ have any support for regular expressions? Or do I need to find someone else's regex code? Any suggestions?
~Cam Desautels (BinaryUprising.com)
|
|
|
|
|
Try BOOST (www.boost.org).
From what I hear it has a good regex that is being considered for the new standard.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I trying to figure out how to suppress all user input for a certain period of time (while a function executes). What's happening now is: I'm using PreTranslateMessage() to ignore all mouse and keyboard commands, but the mouse and keyboard messages are stored in the queue and my trapping misses them because they get executed after my function stops. Any way to flush the message queue after my function stops so all those click messages are ignored?
|
|
|
|
|
You can directly dequeued all of messages by function GetMessage. You should call PeekMessage and GetMessage in iteration till queue will be empty IMHO. But may be some backside will occur, I don't know
|
|
|
|
|
I want to be able to have functionality like in VC++ 6.0 where the user can pick and choose which toolbars to display and which ones to hide. I have all of my toolbars created and added to a CReBar in the MainFrame class of my app. I can't figure out where to have the message handler for the WM_RBUTTONUP message to bring up the menu listing the toolbars to display/hide. Anyone know the answer to this? I tried deriving a ReBar class of my own from the CReBar class and adding the message handler to it, but it didn't enter the OnRButtonUp function of my new class.
Any help would be greatly appreciated.
|
|
|
|
|
Firstly, you should probably use WM_CONTEXTMENU for popup menus, as it supports using your keyboard's popup menu button (where applicable) as well. I don't know if either if these messages will be available to the Rebar class, you might need to use Spy++ to determine where these messages are handled. My guess is that you'll need to handle them in the MainFrame, and then determine whether or not the cursor is currently located over a toolbar.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Hey guys
I want to create a simple program to generate a sound frequency to play through my speakers. I would ideally like to be able to be able to generate a different frequency in each speaker ie 3Khz in right speaker and 3Khz in left speaker. So my question is what is teh easiest and fastest way of doign this.
Peter
|
|
|
|
|
Can any one suggest me good book that overs the topic of "OCR" (optical character recognition). I've searched Amazon, where certain small number of books are present on the topic of image processing and OCR, but i can't figure out which is best. So please suggest me the book you think is best as far as the knowledge of OCR is concerned
Nida Ali
|
|
|
|
|
Hi,
I read the MSDN online and get the following sample of using AfxBeginThread:
UINT MyThreadProc( LPVOID pParam )
{
CMyObject* pObject = (CMyObject*)pParam;
if (pObject == NULL ||
!pObject->IsKindOf(RUNTIME_CLASS(CMyObject)))
return 1; // if pObject is not valid
// do something with 'pObject'
return 0; // thread completed successfully
}
// inside a different function in the program
.
.
.
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
.
.
.
I understand that.....but :
I need to create 50 separate threads (liked 50 different transactions). Since my program is going to simulate the DBMS behavior, in the MyThreadProc() there should be some algorithm to choose whether the current operation of this transaction is READ or WRITE. In this case, all 50 threads will use the same MyThreadProc() and i don't need to make 50 different MyThreadProc(). My question is,
1. Can i create these thread by:
for (i=0; i<50; i++)
{
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
}
2. How to identify Xth thread after creating 50 threads?
3. What parameter I need to put in order to suspend/resume/kill the 10th (or Xth) Thread? Because let say, one thread A (transaction) is READING a data object, and another thread B wants to WRITE the same data object. In this case, thread B needs to wait until thread A finish. So I have to suspend thread B......and wait....then resume.
So, should I call AfxGetThread()???? SuspendThread()??? ResumeThread()????
I need sample codes or examples for each of the above questions. Can anyone help me... please?????
Thanks!!!!
|
|
|
|
|
ChiYung wrote:
1. Can i create these thread by:
for (i=0; i<50; i++)
The for loop will work fine, although you will need to save the return value from AfxBeginThread(). It returns a pointer to the newly-created CWinThread which you will need later.
ChiYung wrote:
2. How to identify Xth thread after creating 50 threads?
Keep an array of CWinThread* and fill it with the return values from AfxBeginThread().
As for suspending/resuming, you should use the built-in thread sync objects, instead of suspending threads yourself. Look up critical sections and mutexes in MSDN.
--Mike--
Rollin' in my 5.0
With the rag-top down so my hair can blow.
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
There are many issuies when you're useing multithreading regarding of your question about simultaneous access to data and whether or not you may call SuspendThread(). You should read at least MSDN topics about CriticalSection usage, about functions WaitForSingleObject/WaitForMultipleObjects and some related topics.
Good luck
|
|
|
|