|
Hello!
I have hwnd of a window I found using FindWindow(), and I want to wait until the user will close this window.
I can think of 2 approches:
(1) better one - get a callback or wait (like waitforsingleobject) until the user closes the window.
(2) not as good as I want - recheck a function that returns the window's state.
I'm looking for a while for a function that does one of these, but with no luck...
Anyone can help me with that???
Thanks a lot in advance!
|
|
|
|
|
SetWindowsHookEx using the WH_CBT hook and looking for the HCBT_DESTROYWND flag. See MSDN for more info.
|
|
|
|
|
try this:
SetTimer(...., TimerProc);
.
.
.
... TimerProc (...)
{
if(IsWindow(hWnd)
}
Thank you masters!
|
|
|
|
|
|
Hi,
I am using the following method to get the scancode for the keyboard keys.But it fails to give me the scancode for F1 to F12 keys. Please tell me what can i do to retrieve the scan code for the above said keys.
UINT lKey = (MapVirtualKey(key, 0) << 16) | (1 << 24);
Thanks in advance,
John.
|
|
|
|
|
This
UINT scancode = ::MapVirtualKey(VK_F1, MAPVK_VK_TO_VSC);
gives me a scan code of 0x3B. Isn't that the F1 scan code?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I try to resize a Custom Control in the OnSize Function of my Views OnSize Function. There is no Error, but nothing happens:
afx_msg void CCustomView::OnSize(UINT nType, int cx, int cy) {
if (::IsWindow(m_datagrid)) {
m_datagrid.SetWindowPos(&wndTopMost, 12, 48, 500, 500, SWP_NOZORDER | SWP_NOMOVE);
}
CView::OnSize(nType, cx, cy);
}
What am I do wrong? m_datagrid.SetWindowPos is executed, I checked it by debugging.
Thank you for your help,
Johannes
|
|
|
|
|
What are you wanting to happen?
You use wndTopMost but it's ignored because of SWP_NOZORDER.
You use x and y positions but they're ignored because of SWP_NOMOVE.
That leaves resize
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, it would have been better if I posted the code without the flags.
When I do not use the Flags it`s the same thing: My Custom control is not be resized and not moved, and this is what I want it to do...
|
|
|
|
|
If you want to move and resize, just use MoveWindow().
The other problem may be where you're doing it from.
The view may not get a WM_SIZE message after the child window
you're moving is created (until the next time the view is resized).
Put a breakpoint on the SetWindowPos() call to check.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
thank you. With MoveWindow() it works!
|
|
|
|
|
I have two programs that share a pipe, a server and a client.
The server creates the pipe and then calls
ConnectNamedPipe(pipe_name, NULL);
The client opens the pipe
CreateFile(
pipe_name,
GENERIC_READ |
GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
But I need to know if the pipe exists even if the server has not called ConnectNamedPipe. Then I need the client to wait forever until the server calls ConnectNamedPipe. But if the pipe is not there at all, it should skip. Any way to do that?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Why don't you try calling CreateFile without the server running and see what you get? I bet that CreateFile returns something like ERROR_FILE_NOT_FOUND since the pipe doesn't exist yet and you are correctly specifying OPEN_EXISTING. Once you have that "doesn't exist" error, simply loop and repetitively call it until it returns success.
Judy
|
|
|
|
|
Hi, my problem is that if the pipe doesn't exist my program shouldn't call anymore. But CreateFile might fail because the server has not called ConnectNamedPipe yet, in which case I should wait until it does, and there lies the problem - the client program is called by third party software which in turn might be requested by my server program or not. If not, then it means that my server program will never create that pipe.
My problem is that the client has to distinguish between 1) the pipe not existing, and 2) the pipe existing but not waiting for connection.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: My problem is that the client has to distinguish between 1) the pipe not existing, and 2) the pipe existing but not waiting for connection.
To do that, the client has to make some API call. Make that call be CreateFile and examine the return value and/or the error code. If the call succeeds and you don't want to use the pipe, simply close it after you open it via CloseHandle .
Judy
|
|
|
|
|
I'm in process of moving a large app from VS 2003 to 2008 (also moved to Vista).
Seems my tree controls are no longer receiving WM_NOTIFY messages (particularly TVN_SELCHANGED) through my message map in my main dialog window. They worked fine in 2003.
I've been searching all over, and also looking for any good tutorials on porting apps to the new platform, but haven't come up with much.
Anybody have any ideas...?
Thanx,
Rick
|
|
|
|
|
What code are you using to handle the messages?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Pretty standard stuff in my main dialog:
ON_NOTIFY(TVN_SELCHANGED, TREE_MYCOMPUTER, OnTvnSelchangedMainFoldertree)
That worked fine in VS 2003, but doesn't work with 2008 and the latest SDK/Framework.
It's a skin based app, so all controls are created dynamically, and there are defines for each control, and a multitude of maps to contain everything.
So, what I did:
My tree is a class derived from the standard CTreeCtrl. I put a handler in that class for ON_NOTIFY_REFLECT, and it will get the notification now.
What worries me, is I have hundreds of hand coded handlers in my main message map, and now I'm going to have to test them all, and try to find workarounds, or just go back to building on 2003...
|
|
|
|
|
Here's the wizard-generated code for a TVN_SELCHANGED handler.
Any differences from yours?
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, &CMyDlg::OnTvnSelchangedTree1)
afx_msg void OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult);
void CMyDlg::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<lpnmtreeview>(pNMHDR);
*pResult = 0;
}</lpnmtreeview>
Note the way the method pointer is passed in the message map entry
(this change and its effect is still being debated on other forums).
Also make sure you don't have a OnNotify() override that's not calling the
base class OnNotify().
That's all I can think of at the moment.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi everyone!
I want to make a C++ service (that runs constantly in the background) and what it does is every few seconds, it checks the content of a folder. If the folder is empty it does nothing and if it has some files in it it will execute a script (that will be written, a batch file)
Can anyone help me make something like that? It's supposed to be quite simple.
Thanks!
Jonathan
|
|
|
|
|
|
|
Hai every one ,
I am developing an application in vc++ for video conversion.I need to convert mpeg to mpeg4.Please any one help me to find a solution.I searched a lot for some third party libraries .But i didn't yet found a solution.I know no free libraries will be available ,please any one help me.
Thanks in advance.
sree
|
|
|
|
|
Have you checked if Media Coder[^] could be of help to you?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|