|
the msdn inof on it is here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/tsref_8d66.asp
now I try and call that function, the first parameter it takes is
hWnd
[in] Handle of the window to receive session change notifications.
What handle is that? I tried making a class of CMyProg and putting it there but I get some external error that says
traytest2Dlg.obj : error LNK2001: unresolved external symbol _WTSRegisterSessionNotification@8
Debug/traytest2.exe : fatal error LNK1120: 1 unresolved externals
I don't know if it has to do with the parameter i'm passing or not. Any help is very appreciated
|
|
|
|
|
This routine works by sending a window message to the window you specify. So if you have a main frame window, you can say something like pMainFrm ->GetSafeWnd (). (It has been a while since I did MFC, so this might be slightly wrong.)
If you don't have a window, you will have to create one.
As far as the link error goes, you need to link to wtsapi32.lib.
Word of warning: This routine is only supported on XP. So if you don't use runtime late binding, your program won't even start on 9x/ME/NT/2000 systems.
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?
|
|
|
|
|
is pMainFrm something like CTrayTestDlg?
|
|
|
|
|
how do I link to it I keeo getting that same error, I included the microsoft sdk\lib into the directories under library files
|
|
|
|
|
n/m I got it I had to actually add it to the project
|
|
|
|
|
You can link to it without adding it to the project by using Project Settings (alt+f7) - but if you do it either this way, or the way that you have used, you will have linked at compile-time, meaning your program will only work on Windows XP.
--
Andrew.
|
|
|
|
|
i'm running xp and the program is only gonna be for xp it changes an xp setting
|
|
|
|
|
How can i clean the RS 422 input buffer????
i want to start running in a specific time and ignore all the data that is
already been stored in the RS 422 buffer.
How can i do that???
Thanks
|
|
|
|
|
PurgeComm
It has been a while since I worked with 422, but if you are concerned about receiving the output in the input, I would still code for ignoring any message you sent out. WIN32 just doesn't give you enough control to know when a message has been fully sent out of the comm port. You only know when output buffer is empty. There still could be characters waiting on the FIFO.
But, if you are just looking to kill any characters in the input buffer, PurgeComm works great.
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?
|
|
|
|
|
hi, i would like to do something like that:
the website targeted use PHP to login with a username and a password.
and then, some menu is shown, (all using .php or .php3 extension for viewing pages.)
the fact is, if i do not log with my user/password within internet explorer, i can't even retrieve files i want using internet explorer.
but, even after logging in, and when i am able to download any file ending with .php3?someparam=somevalue&another=anothervalue etc...
when i use a offlinebrowser application to save all pages i want, the external application finally download a page which says i'm not logged on. although i can still download that page opening an internet explorer windows... (and setting the offline browser 'spider' to identify itself as IE doesn't solve the problem.)
so i have figured out that i need something, which will log in using a specified username/password, and then, will download all files linked from a single url. (and that need to work with either .php or .php3?x=1&pass=2 files...)
how can i do that?
|
|
|
|
|
Hi.
I would like to know how to determine when the user presses, say, 'z' *while* holding down one of the virtual keys, say Ctrl.
For example
// Ctrl + Z
I can use either OnKeyDown(...) and/or OnChar(...) to determine *either* Ctrl or z, but not both.
I am trying to implement an "undo" feature.
Thanks,
Kuphryn
|
|
|
|
|
|
Thanks.
// if(GetKeyboardState(VK_CONTROL) & 0x8000)
Are you ORing it with the integer 8? Why?
I know that works similarly to check if a key is down while clicking a mouse button. I could not get it to work with a character (OnChar).
Kuphryn
|
|
|
|
|
& is the bitwise AND operator. GetKeyboardState() returns a short (16-bit integer). Check the docs and you'll see that the high bit is 1 if the key is pressed. The high bit of a 16-bit int can be expressed at 0x8000 which is hexadecimal notation.
--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é.
|
|
|
|
|
Okay. Thanks.
Members at other forums mentioned this functions:
GetKeyState(...);
GetAsyncKeyStat(...);
GetKeyboardState(...); // Your recommendation
What are the differences?
Kuphryn
|
|
|
|
|
Sorry, I mistyped. GetKeyState() is the API I'd use. There's probably no difference that you could see between the three APIs. GetKeyState() returns the state of one key, which is what you want, so that's the best one to use from a code readability standpoint. GetAsyncKeyState() will work as well, it just works differently internally.
--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é.
|
|
|
|
|
I want one of my resource bitmaps to appear as the background of my dialog window upon runtime. Can someone please let me know how to go about doing this?
Thanks!
|
|
|
|
|
Handle the WM_ERASEBKGND message. The WPARAM will contain an HDC, you should use this value to create a memDC that you can select your bitmap into, then blt the bitmap into the HDC from WPARAM.
Here is an example assuming that you have the bitmap preloaded in hBitmap, and the dimensions of your bitmap have been cached in a BITMAP structure called bm.
HDC hdc = (HDC)wParam;
HDC hdcMem = ::CreateCompatibleDC(hdc);
::SelectObject(hBitmap);
::BitBlt(hdc, 0,0, bm.bmWidht, bm.bmHeight, hdcMem, 0,0,SRCCOPY);
::DeleteDC(hdcMem);
::SetWindowLong(hWnd, DWL_MESGRESULT, TRUE);
return TRUE;
If you have any more questions feel free to ask.
|
|
|
|
|
void CInterceptDlg::OnPaint()
{
PAINTSTRUCT ps;
HDC hdc
hdc = ::BeginPaint(hWnd, &ps);
...
}
If you are using MFC or WTL, then replace hWnd with m_hWnd in order to get access to the HWND member variable for your window.
|
|
|
|
|
dear all,
How can i restrict Multiple Instance of Mfc Dialog based application?
thanks in advance.
|
|
|
|
|
One way is to use a named mutex.
HANDLE hMultiMutex = CreateMutex (NULL, FALSE, "DSSIOmniServerMutex");
if (hMultiMutex == NULL) { }
DWORD dwWaitResult = WaitForSingleObject (hMultiMutex, 0L);
bool fDuplicate = dwWaitResult == WAIT_TIMEOUT;
It isn't 100% fool proof, but it should work for GUIs.
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?
|
|
|
|
|
hello. i am currently writing a program tictactoe for windows. i got mostly everything working. i got the program to draw the board and draw the X's and O's. the game start by beginning with the player then wait for the computer to move. i got the part where the player clicks on the board and an X is drawn in the grid. i only have to make the computer move but Everything seems to work OK, until last nite when I created a function CheckForMoves which returns an integer and also returns the row and column which is best move. inside the function CheckForMoves, i created a Board then i assigned it to a pointer to Board like this:
CBoard board = *pBoard;
pBoard is the Board i am using to draw my X's and O's for the game. i am copying it to a new board so i can try out all the possible moves in a new board without touching the board i am using in the game. because my board class was implemented dynamically, i wrote my own assignment operator and my own copy constructor. in my assignment operator function, i delete what ever the pointer is point to, then call new then point it to whatever is in the right of the operator. Copy constructor, because it is empty, i just point the pointers to what ever is on the right side. i went along and debugged it using the VC++ debugger then when i was walking through the code i saw that it was calling the Copy constructor. then as i walk over the Copy Constructor everything seems fine. by using asserts, if found out that all the pointers are being copied right. the cells where i store the X's and O's are copied right too. i tried using TRACE statements but i cant find the bug causing the BOARD TO BE EMPTY. i tried using MessageBox before and after calling the copy constructor. as i moved the MessageBox i saw my move X on the Board. but as soon as i clicked the MessageBox that Outputs "After" called after the copy constructor was called. the X in the board disappears. MY CONCLUSION IS THE BOARD I AM USING IN THE GAME IS BEING CHANGED SOMEHOW IN THE COPY CONSTRUCTOR. the copy constructors parameters is like this:
CBoard& CBoard::CBoard(const CBoard& Copy)
I Hope this helps explain my problem. sorry if its very long, i just want to explain it with much detail so i can tell you whats going on. Can anyone tell me whats wrong wid my program and how i can fix it? i would appreciate any method on how to find the bug. Thank you very very much.
John
|
|
|
|
|
John Cruz wrote:
CBoard& CBoard::CBoard(const CBoard& Copy)
I am not sure if this is causing you problems, but this is not what a copy constructor looks like a copy constructor has no return value.
CBoard::CBoard(const CBoard& Copy)
{
...
}
Maybe the compiler is generating the copy constructor for you and that is where your problem is.
|
|
|
|
|
Oh, i am very sorry... i made a mistake in typing my copy constructor... my copy constructor does look like the one u have. here it is and this is whats inside.
CBoard::CBoard(const CBoard& Copy)
{
// Create new objects
mpPen = new CPen;
mpFont = new CFont;
// Set the values to the new values
mpPen = Copy.mpPen;
mpFont = Copy.mpFont;
// Set the values to default for now
mpDefaultPen = NULL;
mpDefaultFont = NULL;
// Sets the rectangle to a certain point, width and height
for (int r = 0; r < MAXROW; r++)
for (int c = 0; c < MAXCOL; c++)
{
mCell[r][c] = Copy.mCell[r][c];
mpGrid[r][c] = new CRect(mLeftTopPt,CSize(mCellWidth,mCellHt));
mpGrid[r][c] = Copy.mpGrid[r][c];
}
}
thank you very much.
|
|
|
|
|
Hello John,
I am not sure what your real problem is and if what I am telling will give you an answer to your solution.
But from your code I draw the conclusion that mpPen are created on the heap.
When you do:
John Cruz wrote:
// Create new objects
mpPen = new CPen;
mpFont = new CFont;
you create two pointers on the heap. Then on
John Cruz wrote:
// Set the values to the new values
mpPen = Copy.mpPen;
mpFont = Copy.mpFont;
you equal the pointers not their values. Futhermore you allocate memory (new CPen) and you do not use it because you assign the pointer to the memory referenced my the source CBoard object (myPen = Copy.mpPen).
When the source copy goes out of scope the destination Pen and destination Font will point to rubbish.
Try *mpPen = *Copy.mpPen; But since these are GDI object you must take into account the handles (HPEN, HFONT), I am not sure, but I think you just cannot copy these objects as the predefined types.
I hope this helps,
Best regards,
Alexandru Savescu
|
|
|
|