|
Hi guys,
As the subject points out I'd like to restrict the movement of an (owned ?) WS_POPUP to the client area of its owner. Contrary to the behaviour of a WS_CHILD which is clipped when it hits the boundaries of its parent (you can push the child under the borders) - I'd like my window to "bounce" of the borders (you can not push it under the borders, it should behave as hitting a wall). Is this possible ? If yes how can I tackle the problem ? Based on my pretty meager windows programming knowledge I'd say I need to trap/catch/grab some windows messages ( but which ones ? ) and then do something with them (probably subclassing the windowproc of the WS_POPUP ?). I can truly say I have no idea where to start. Can anybody provide some hints ? Maybe you have already done what I would need and can furnish same coding example ?
Sorry child windows are completely out of the question - not for the clipping behaviour but for other reasons as well!
thanx,
codingworm
|
|
|
|
|
WM_MOVING [^] [^] looks interesting.
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
modified on Tuesday, April 29, 2008 9:12 AM
|
|
|
|
|
Globalization?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Oops, went out-of-synchro while doing multiple answers...
Now fixed, thank you.
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
|
|
|
|
|
CodingWorm wrote: Is this possible ?
Yes. See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thank you both very much
hope i can check it out now
br
codingworm
|
|
|
|
|
I write client/server code in MFC and now need to create a class for it. Because I write this code in Asynchronous manner, I dont khow how can I deliver message from packet arrival to one procedure of this class.
|
|
|
|
|
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
|
|
|
|
|
mmj wrote: I write client/server code in MFC and now need to create a class for it.
why do you code the WIN32 way in MFC, when MFC already have wrapper class, CAsyncSocket.
|
|
|
|
|
I want to create an avi file.
I am having only device context handle.
I need to create a HBITMAP from hdc and add that to AVI file.
Any help?
|
|
|
|
|
|
|
I am using gdi plus to display the image. now i want to mask the
particular color of the image . is there any gdiplus api
for doing this .
Trioum
|
|
|
|
|
|
Hello,
I have this piece of code which i am using in my application developed on VS2003. i have migrated the code to VS2005 and have cleaned the code, but now i have to port it to Vista.
The code uses SHFILEOPSTRUCT and SHFileOperation which are nwo deprecated and a new interface IFileOperation has been introduced for Vista. I did a lot of head banging but still i could not figure out how to modify my code except the use of SetOperationFlag() function of IFileOperation. So please see if you could help.
Here are the snippets
<br />
SHFILEOPSTRUCT shfileop;<br />
<br />
shfileop.hwnd = NULL;<br />
<br />
shfileop.wFunc = FO_DELETE;<br />
<br />
shfileop.pFrom = pstrfrom;<br />
<br />
shfileop.pTo = NULL;<br />
<br />
shfileop.fFlags = FOF_NOCONFIRMATION;<br />
<br />
shfileop.fAnyOperationsAborted = 0;<br />
<br />
shfileop.hNameMappings = 0;<br />
<br />
shfileop.lpszProgressTitle = 0;<br />
<br />
SHFileOperation(&shfileop);
I get the pFrom and pTo from LPCTSTR type strings. I would also like to know about the double null termination of strings.
Thanks and regards,
Mustanseer
|
|
|
|
|
What does your code snippet have to do with using SetOperationFlag() or IFileOperation ?
Mustanseer M S wrote: The code uses SHFILEOPSTRUCT and SHFileOperation which are nwo deprecated...
But it should still work.
Mustanseer M S wrote: SHFileOperation(&shfileop);
What does this return?
Mustanseer M S wrote: I get the pFrom and pTo from LPCTSTR type strings.
Are they double-null terminated?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi Davis,
The code presented above was the one being used by me till i had my application compatible with XP or earlier. For Vista and later releases of Windows it is recommended to use IFileOperation interface instead of SHFileOperation(). That is why i want to replace SHFileOperation with IFileInterface.
As for the strings i am not sure whether they are double null terminated or not as i get them from a third party renderer. but i could double null terminate them using string maipulations if possible.
Any other suggestion will be welcomed.
Thank you for the trouble.
Regards,
Mustanseer
|
|
|
|
|
Mustanseer M S wrote: That is why i want to replace SHFileOperation with IFileInterface.
Ok, so what have you tried so far, and what results are you seeing?
Mustanseer M S wrote: As for the strings i am not sure whether they are double null terminated or not...
SHFileOperation() will not work otherwise.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David,
I got this code from a MSDN newsgroup
<a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vc.mfc&mid=eccb8144-68e3-4cc8-8457-73725d857019">http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vc.mfc&mid=eccb8144-68e3-4cc8-8457-73725d857019</a>[<a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vc.mfc&mid=eccb8144-68e3-4cc8-8457-73725d857019" target="_blank" title="New Window">^</a>]
<code>//=======================================================================
//
// Deletes a file given its name (with full path).
//
// Uses new Vista IFileOperation COM interface
// (works in both ANSI/MBCS and Unicode builds, thanks to internal
// string conversion).
//
// Check HRESULT return value to see if operation was successful
// (SUCCEEDED( DeleteFile(...) )).
//
//=======================================================================
HRESULT DeleteFileWithIFO( LPCTSTR szFilename )
{
//
// Check input parameter
//
ASSERT( szFilename != NULL );
if ( szFilename == NULL )
return E_POINTER;
//
// Convert from TCHAR to wchar_t
// because IFileOperation::DeleteItem works only
// with Unicode UTF-16 strings.
//
CT2W wszFileToDelete( szFilename );
//
// Initialize COM engine
//
HRESULT hr = CoInitializeEx(NULL,
COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hr))
{
//
// Create COM instance of IFileOperation
//
IFileOperation *pfo = NULL;
hr = CoCreateInstance(CLSID_FileOperation, NULL,
CLSCTX_ALL, IID_PPV_ARGS(&pfo));
if (SUCCEEDED(hr))
{
//
// Set parameters for current operation
//
hr = pfo->SetOperationFlags(
FOF_SILENT | // do not display progress dialog-box
FOF_NOERRORUI // do not display error message to the user
);
if (SUCCEEDED(hr))
{
//
// Create IShellItem instance associated to file to delete
//
IShellItem *psiFileToDelete = NULL;
hr = SHCreateItemFromParsingName(
wszFileToDelete, NULL,
IID_PPV_ARGS(&psiFileToDelete));
if (SUCCEEDED(hr))
{
//
// Declare this shell item (file) to be deleted
//
hr = pfo->DeleteItem( psiFileToDelete, NULL );
}
// Cleanup file-to-delete shell item
psiFileToDelete->Release();
psiFileToDelete = NULL;
}
if (SUCCEEDED(hr))
{
//
// Perform the deleting operation
//
hr = pfo->PerformOperations();
}
}
// Cleanup file operation object
pfo->Release();
pfo = NULL;
}
//
// Cleanup COM
//
CoUninitialize();
//
// Return operation result
//
return hr;
}</code>
|
|
|
|
|
Hi, do you know how to delete multiple files at once? Thank you!
|
|
|
|
|
Hi,
what is the difference between MF_BYPOSITION and MF_BYCOMMAND in DeleteMenu() function of CMenu class.I have problem with MF_BYCOMMAND is not working properly.
|
|
|
|
|
From MSDN [^]:
MF_BYCOMMAND
Identifies menu item position by command.
[...]
MF_BYPOSITION
Identifies menu item position by zero-based relative position.
[...]
i.e. if you need to access the menu via its ID (like, for instance, IDM_EXIT ) then you have to specify MF_BYCOMMAND . Viceversa, if you want to specify the menu item via its position inside the menu then use MF_BYPOSITION )
Is it clear enough?
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
|
|
|
|
|
Hi,
I created a file in append mode using CreateFile();.But if I reopen the file add add string to it, it is appending from the starting of the file.
But it should be added from the end of the file.
What is wrong?
|
|
|
|
|
can u send ur code...so that i can get clearly.
Born to win...!
|
|
|
|
|
AFAIK CreateFile has no 'append' option: you have to go to the end of the file
(via SetFilePointer ) after opening it correctly for append (i.e. depending on your needs, with OPEN_ALWAYS or OPEN_EXISTING as dwCreationDisposition parameter) and start writing there.
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
|
|
|
|